-
Notifications
You must be signed in to change notification settings - Fork 296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add variable Extension support #1328
Add variable Extension support #1328
Conversation
…_support_variable_extension
…d retrieve Variables
…rp/android-fhir into sm/1059_support_variable_extension
Codecov Report
@@ Coverage Diff @@
## master #1328 +/- ##
==============================
==============================
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
datacapture/src/main/java/com/google/android/fhir/datacapture/FHIRPathEngineHostServices.kt
Outdated
Show resolved
Hide resolved
datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireViewModel.kt
Outdated
Show resolved
Hide resolved
datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireViewModel.kt
Outdated
Show resolved
Hide resolved
datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireViewModel.kt
Outdated
Show resolved
Hide resolved
datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireViewModel.kt
Outdated
Show resolved
Hide resolved
datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireViewModel.kt
Outdated
Show resolved
Hide resolved
datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireViewModel.kt
Outdated
Show resolved
Hide resolved
datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireViewModel.kt
Outdated
Show resolved
Hide resolved
Thanks, @jingtang10 for the feedback. PR is updated and ready for review. cc: @maimoonak @f-odhiambo |
datacapture/src/main/java/com/google/android/fhir/datacapture/fhirpath/ExpressionEvaluator.kt
Outdated
Show resolved
Hide resolved
datacapture/src/main/java/com/google/android/fhir/datacapture/fhirpath/ExpressionEvaluator.kt
Outdated
Show resolved
Hide resolved
datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireViewModel.kt
Show resolved
Hide resolved
…fhirpath/ExpressionEvaluator.kt Co-authored-by: Jing Tang <[email protected]>
Thanks @jingtang10 for the feedback. I left some comments for you. Please have a look at it. cc: @f-odhiambo |
IMPORTANT: All PRs must be linked to an issue (except for extremely trivial and straightforward changes).
Fixes #1059
Description
The implemented approach is,
QuestionnaireItems
as we have it forQuestionnaireResponseItems
because we need to go through the hierarchy upwards to trace/evaluate and put the values of variables down in the descendants.ExpressionEvaluator
file which has two different methods one for evaluation of root level variable expressionsinternal fun evaluateQuestionnaireRootVariableExpression( expression: Expression, questionnaire: Questionnaire, questionnaireResponse: QuestionnaireResponse ): Base?
and the other for evaluation of questionnaire item level variable expressionsinternal fun evaluateQuestionnaireItemVariableExpression( expression: Expression, questionnaire: Questionnaire, questionnaireResponse: QuestionnaireResponse, questionnaireItemParentMap: Map<Questionnaire.QuestionnaireItemComponent, Questionnaire.QuestionnaireItemComponent>, origin: Questionnaire.QuestionnaireItemComponent ): Base?
In these methods, we try to calculate/evaluate an expression, if it depends on other variables which probably defined up in the hierarchy, we recursively go through the hierarchy with the help of the child-parent map (questionnaire item level expressions) prepared in step 1 above and get the value of the variable and put it's value into original expression, evaluate the expression and return the result. We will calculate variables recursively on the fly and not storing/calculating variables beforehand.
Alternative(s) considered
Type
Choose one: Feature
Screenshots (if applicable)
More details and screenshots are available here on issue#1059
Checklist
./gradlew spotlessApply
and./gradlew spotlessCheck
to check my code follows the style guide of this project../gradlew check
and./gradlew connectedCheck
to test my changes locally.