-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cqf expression implementation for dynamic question title (#1959)
* CQF Expression implementation for question title * Fix issue with failing tests * Add tests | Fix variables expression logic issue * Remove extra javadoc * Remove function call from questionItem and use response text for dynamic eval * Update datacapture/src/main/java/com/google/android/fhir/datacapture/fhirpath/ExpressionEvaluator.kt Co-authored-by: santosh-pingle <[email protected]> * Update datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireViewModel.kt Co-authored-by: santosh-pingle <[email protected]> * Update catalog/src/main/res/values/strings.xml Co-authored-by: Jing Tang <[email protected]> * Update datacapture/src/main/java/com/google/android/fhir/datacapture/views/QuestionnaireViewItem.kt Co-authored-by: Jing Tang <[email protected]> * rename catalog files | add tests | add to group view item | modify same item check * Update catalog/src/main/res/values/strings.xml Co-authored-by: Jing Tang <[email protected]> * Update datacapture/src/main/java/com/google/android/fhir/datacapture/fhirpath/ExpressionEvaluator.kt Co-authored-by: Jing Tang <[email protected]> * Update datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireViewModel.kt Co-authored-by: Jing Tang <[email protected]> * Update datacapture/src/main/java/com/google/android/fhir/datacapture/views/HeaderView.kt Co-authored-by: Jing Tang <[email protected]> * Update datacapture/src/main/java/com/google/android/fhir/datacapture/views/GroupHeaderView.kt Co-authored-by: Jing Tang <[email protected]> * Move code to MoreElements * Make expression eval generic method * Add android test for cqf --------- Co-authored-by: Benjamin Mwalimu <[email protected]> Co-authored-by: santosh-pingle <[email protected]> Co-authored-by: Jing Tang <[email protected]>
- Loading branch information
1 parent
ab256e0
commit 32939ce
Showing
18 changed files
with
602 additions
and
50 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
catalog/src/main/assets/behavior_dynamic_question_text.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
{ | ||
"resourceType": "Questionnaire", | ||
"item": [ | ||
{ | ||
"text": "Choose an option below", | ||
"type": "choice", | ||
"extension": [ | ||
{ | ||
"url": "http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl", | ||
"valueCodeableConcept": { | ||
"coding": [ | ||
{ | ||
"system": "http://hl7.org/fhir/questionnaire-item-control", | ||
"code": "radio-button", | ||
"display": "Radio Button" | ||
} | ||
] | ||
} | ||
} | ||
], | ||
"linkId": "1", | ||
"required": true, | ||
"answerOption": [ | ||
{ | ||
"valueCoding": { | ||
"code": "option1", | ||
"display": "First Option" | ||
} | ||
}, | ||
{ | ||
"valueCoding": { | ||
"code": "option2", | ||
"display": "Second Option" | ||
} | ||
}, | ||
{ | ||
"valueCoding": { | ||
"code": "option3", | ||
"display": "Third Option" | ||
} | ||
}, | ||
{ | ||
"valueCoding": { | ||
"code": "option4", | ||
"display": "Fourth Option" | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"linkId": "2", | ||
"required": true, | ||
"text": "Option Date", | ||
"_text": { | ||
"extension": [ | ||
{ | ||
"url": "http://hl7.org/fhir/StructureDefinition/cqf-expression", | ||
"valueExpression": { | ||
"language": "text/fhirpath", | ||
"expression": "'Provide \"'+ %resource.descendants().where(linkId = '1').answer.value.display + '\" Date'" | ||
} | ||
} | ||
] | ||
}, | ||
"type": "date" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
catalog/src/main/res/drawable/ic_dynamic_text_behavior.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<vector | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="194dp" | ||
android:height="128dp" | ||
android:viewportWidth="194" | ||
android:viewportHeight="128" | ||
> | ||
<path | ||
android:strokeWidth="1" | ||
android:pathData="M135.5,27V101C135.5,101.828 134.828,102.5 134,102.5H60C59.172,102.5 58.5,101.828 58.5,101V27C58.5,26.172 59.172,25.5 60,25.5H97H134C134.828,25.5 135.5,26.172 135.5,27Z" | ||
android:fillColor="#ffffff" | ||
android:strokeColor="#8AB4F8" | ||
/> | ||
<path | ||
android:pathData="M64,49C64,43.477 68.477,39 74,39L135,39V59L74,59C68.477,59 64,54.523 64,49V49Z" | ||
android:fillColor="#D2E3FC" | ||
/> | ||
<path | ||
android:pathData="M74,49m-10,0a10,10 0,1 1,20 0a10,10 0,1 1,-20 0" | ||
android:fillColor="#1A73E8" | ||
/> | ||
<path | ||
android:pathData="M125,79C125,84.523 120.523,89 115,89L59,89L59,69L115,69C120.523,69 125,73.477 125,79V79Z" | ||
android:fillColor="#D2E3FC" | ||
/> | ||
<path | ||
android:pathData="M115,79m-10,0a10,10 0,1 1,20 0a10,10 0,1 1,-20 0" | ||
android:fillColor="#1A73E8" | ||
/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
datacapture/sampledata/questionnaire_with_dynamic_question_text.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{ | ||
"resourceType": "Questionnaire", | ||
"item": [ | ||
{ | ||
"text": "Choose an option below", | ||
"type": "choice", | ||
"extension": [ | ||
{ | ||
"url": "http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl", | ||
"valueCodeableConcept": { | ||
"coding": [ | ||
{ | ||
"system": "http://hl7.org/fhir/questionnaire-item-control", | ||
"code": "radio-button", | ||
"display": "Radio Button" | ||
} | ||
] | ||
} | ||
} | ||
], | ||
"linkId": "1", | ||
"required": true, | ||
"answerOption": [ | ||
{ | ||
"valueCoding": { | ||
"code": "option1", | ||
"display": "First Option" | ||
} | ||
}, | ||
{ | ||
"valueCoding": { | ||
"code": "option2", | ||
"display": "Second Option" | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"linkId": "2", | ||
"required": true, | ||
"text": "Option Date", | ||
"_text": { | ||
"extension": [ | ||
{ | ||
"url": "http://hl7.org/fhir/StructureDefinition/cqf-expression", | ||
"valueExpression": { | ||
"language": "text/fhirpath", | ||
"expression": "'Provide \"'+ %resource.descendants().where(linkId = '1').answer.value.display + '\" Date'" | ||
} | ||
} | ||
] | ||
}, | ||
"type": "date" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
datacapture/src/main/java/com/google/android/fhir/datacapture/extensions/MoreElements.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright 2022 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.android.fhir.datacapture.extensions | ||
|
||
import org.hl7.fhir.r4.model.Element | ||
import org.hl7.fhir.r4.model.Expression | ||
import org.hl7.fhir.r4.utils.ToolingExtensions | ||
|
||
internal const val EXTENSION_CQF_EXPRESSION_URL: String = | ||
"http://hl7.org/fhir/StructureDefinition/cqf-expression" | ||
|
||
internal val Element.cqfExpression: Expression? | ||
get() = | ||
ToolingExtensions.getExtension(this, EXTENSION_CQF_EXPRESSION_URL)?.value?.let { | ||
it.castToExpression(it) | ||
} |
Oops, something went wrong.