Skip to content

Commit

Permalink
Merge branch 'master' into ak/highlight_required_fields
Browse files Browse the repository at this point in the history
  • Loading branch information
aditya-07 authored Oct 28, 2022
2 parents d174025 + 4cfc307 commit 96804f8
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class BehaviorListViewModel(application: Application) : AndroidViewModel(applica
CALCULATED_EXPRESSION(
R.drawable.ic_calculations_behavior,
R.string.behavior_name_calculated_expression,
"calculated_expression_questionnaire.json"
"behavior_calculated_expression.json"
),
SKIP_LOGIC(
R.drawable.ic_skiplogic_behavior,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package com.google.android.fhir.datacapture.views

import android.text.InputType
import com.google.android.fhir.datacapture.R
import com.google.android.fhir.datacapture.validation.Invalid
import java.math.BigDecimal
import org.hl7.fhir.r4.model.Quantity
import org.hl7.fhir.r4.model.QuestionnaireResponse
Expand All @@ -37,9 +38,11 @@ internal object QuestionnaireItemEditTextQuantityViewHolderFactory :
): QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent? {
// https://build.fhir.org/ig/HL7/sdc/behavior.html#initial
// read default unit from initial, as ideally quantity must specify a unit
return text
.takeIf { it.isNotBlank() }
?.let {
return text.let {
if (text.isEmpty()) {
return null
}
try {
val value = BigDecimal(text)
val quantity =
with(questionnaireItemViewItem.questionnaireItem) {
Expand All @@ -54,7 +57,17 @@ internal object QuestionnaireItemEditTextQuantityViewHolderFactory :
else Quantity().apply { this.value = value }
}
QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent().setValue(quantity)
} catch (exception: NumberFormatException) {
displayValidationResult(
Invalid(
listOf(
textInputLayout.context.getString(R.string.number_format_validation_error_msg)
)
)
)
null
}
}
}

override fun getText(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ internal abstract class QuestionnaireItemEditTextViewHolderFactory(
abstract class QuestionnaireItemEditTextViewHolderDelegate(private val rawInputType: Int) :
QuestionnaireItemViewHolderDelegate {
private lateinit var header: QuestionnaireItemHeaderView
private lateinit var textInputLayout: TextInputLayout
protected lateinit var textInputLayout: TextInputLayout
private lateinit var textInputEditText: TextInputEditText
override lateinit var questionnaireItemViewItem: QuestionnaireItemViewItem
private var textWatcher: TextWatcher? = null
Expand Down
7 changes: 4 additions & 3 deletions datacapture/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
<string
name="max_value_validation_error_msg"
>Maximum value allowed is:<xliff:g id="max_value">%1$s</xliff:g> </string>
<string
name="number_format_validation_error_msg"
>Only use (.) between two numbers. Other special characters are not supported.</string>
<string
name="date_format_validation_error_msg"
>Date format needs to be <xliff:g
id="locale_format"
>%1$s</xliff:g> </string>
>Date format needs to be <xliff:g id="locale_format">%1$s</xliff:g></string>
<string name="submit_button_text">Submit</string>
<string name="button_pagination_next">Next</string>
<string name="button_pagination_previous">Previous</string>
Expand Down
2 changes: 1 addition & 1 deletion kokoro/gcp_ubuntu/kokoro_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function zip_artifacts() {
function setup() {
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
sudo n 16.18.0

wget https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip \
-O ${HOME}/android_sdk.zip -q
Expand Down

0 comments on commit 96804f8

Please sign in to comment.