From a82135f7e3bd2223e09777d431e898fc2e36452d Mon Sep 17 00:00:00 2001 From: maimoonak Date: Fri, 7 Apr 2023 14:59:00 +0500 Subject: [PATCH] Update the title on dependency answer change --- catalog/build.gradle.kts | 1 - catalog/src/main/AndroidManifest.xml | 1 - .../assets/behavior_answer_expression.json | 603 -------- .../behavior_dynamic_question_title.json | 68 + .../src/main/assets/resource_data_bundle.json | 1325 ----------------- .../fhir/catalog/BehaviorListViewModel.kt | 5 + .../fhir/catalog/CatalogApplication.kt | 62 - .../drawable/ic_dynamic_title_behavior.xml | 30 + catalog/src/main/res/values/strings.xml | 5 +- .../fhir/datacapture/fhirpath/FhirPathUtil.kt | 8 + .../views/QuestionnaireViewItem.kt | 3 +- 11 files changed, 115 insertions(+), 1996 deletions(-) delete mode 100644 catalog/src/main/assets/behavior_answer_expression.json create mode 100644 catalog/src/main/assets/behavior_dynamic_question_title.json delete mode 100644 catalog/src/main/assets/resource_data_bundle.json delete mode 100644 catalog/src/main/java/com/google/android/fhir/catalog/CatalogApplication.kt create mode 100644 catalog/src/main/res/drawable/ic_dynamic_title_behavior.xml diff --git a/catalog/build.gradle.kts b/catalog/build.gradle.kts index 44750df319..d103159702 100644 --- a/catalog/build.gradle.kts +++ b/catalog/build.gradle.kts @@ -61,7 +61,6 @@ dependencies { implementation(Dependencies.Navigation.navUiKtx) implementation(project(path = ":datacapture")) - implementation(project(path = ":engine")) implementation(project(path = ":contrib:barcode")) testImplementation(Dependencies.junit) diff --git a/catalog/src/main/AndroidManifest.xml b/catalog/src/main/AndroidManifest.xml index a59865acee..81c03488a7 100644 --- a/catalog/src/main/AndroidManifest.xml +++ b/catalog/src/main/AndroidManifest.xml @@ -28,7 +28,6 @@ /> - CoroutineScope(Dispatchers.IO).launch { - fhirEngine.create(*resources.toTypedArray()) - } - } - } - - override fun getDataCaptureConfig(): DataCaptureConfig = dataCaptureConfig -} diff --git a/catalog/src/main/res/drawable/ic_dynamic_title_behavior.xml b/catalog/src/main/res/drawable/ic_dynamic_title_behavior.xml new file mode 100644 index 0000000000..e47e63e483 --- /dev/null +++ b/catalog/src/main/res/drawable/ic_dynamic_title_behavior.xml @@ -0,0 +1,30 @@ + + + + + + + diff --git a/catalog/src/main/res/values/strings.xml b/catalog/src/main/res/values/strings.xml index fbd6b75847..b275b55ee5 100644 --- a/catalog/src/main/res/values/strings.xml +++ b/catalog/src/main/res/values/strings.xml @@ -43,9 +43,8 @@ If Yes is selected, a follow-up question is displayed. If No is selected, no follow-up questions are displayed. - Enable When Expression + Enable When Expression + Dynamic Question Title Input age to automatically calculate birthdate until birthdate is updated manually. diff --git a/datacapture/src/main/java/com/google/android/fhir/datacapture/fhirpath/FhirPathUtil.kt b/datacapture/src/main/java/com/google/android/fhir/datacapture/fhirpath/FhirPathUtil.kt index 1c14d1da17..5e09997894 100644 --- a/datacapture/src/main/java/com/google/android/fhir/datacapture/fhirpath/FhirPathUtil.kt +++ b/datacapture/src/main/java/com/google/android/fhir/datacapture/fhirpath/FhirPathUtil.kt @@ -37,6 +37,14 @@ internal val fhirPathEngine: FHIRPathEngine = internal fun evaluateToDisplay(expressions: List, data: Resource) = expressions.joinToString(" ") { fhirPathEngine.evaluateToString(data, it) } +/** Evaluates the expressions over list of resources [QuestionnaireResponse] and [QuestionnaireResponseItemComponent] and returns the resulting elements + * FhirPath supplements https://build.fhir.org/ig/HL7/sdc/expressions.html#fhirpath-supplements + * %resource = [QuestionnaireResponse] + * %context = [QuestionnaireResponseItemComponent] + **/ +internal fun evaluateToBase(questionnaireResponse: QuestionnaireResponse, questionnaireResponseItemComponent: QuestionnaireResponseItemComponent, expression: String) = + fhirPathEngine.evaluate(null, questionnaireResponse, null, questionnaireResponseItemComponent, expression) + /** * Evaluates the expressions over list of resources [QuestionnaireResponse] and * [QuestionnaireResponseItemComponent] and returns the resulting elements FhirPath supplements diff --git a/datacapture/src/main/java/com/google/android/fhir/datacapture/views/QuestionnaireViewItem.kt b/datacapture/src/main/java/com/google/android/fhir/datacapture/views/QuestionnaireViewItem.kt index 3b7429694a..37b02a8583 100644 --- a/datacapture/src/main/java/com/google/android/fhir/datacapture/views/QuestionnaireViewItem.kt +++ b/datacapture/src/main/java/com/google/android/fhir/datacapture/views/QuestionnaireViewItem.kt @@ -230,7 +230,8 @@ data class QuestionnaireViewItem( */ internal fun hasTheSameItem(other: QuestionnaireViewItem) = questionnaireItem === other.questionnaireItem && - questionnaireResponseItem === other.questionnaireResponseItem + questionnaireResponseItem === other.questionnaireResponseItem && + questionTitle === other.questionTitle /** * Returns whether this [QuestionnaireViewItem] and the `other` [QuestionnaireViewItem] have the