-
Notifications
You must be signed in to change notification settings - Fork 249
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
Support initial expression extension in questionnaire population #1295
Support initial expression extension in questionnaire population #1295
Conversation
…3_advance_behaviour
… evaluate method.
…3_advance_behaviour
- Add test cases in ResourceMapperTest.kt
Codecov Report
@@ Coverage Diff @@
## master #1295 +/- ##
============================================
+ Coverage 84.53% 84.54% +0.01%
- Complexity 684 688 +4
============================================
Files 148 148
Lines 10687 10699 +12
Branches 826 827 +1
============================================
+ Hits 9034 9046 +12
Misses 1244 1244
Partials 409 409
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you please create an issue in the codebase, so that in the validator API, we will throw an exception if inital value and intial value expression are both present.
reference this url: http:https://build.fhir.org/ig/HL7/sdc/expressions.html
and this sentence: Since both initial.value and initialExpression generate values before the user has access to the form, it is not allowed to have both present on a Questionnaire.item.
.addItem( | ||
Questionnaire.QuestionnaireItemComponent().apply { | ||
linkId = "patient-dob" | ||
type = Questionnaire.QuestionnaireItemType.TEXT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why isn't this DATE type?
val patient = Patient().apply { id = "Patient/$patientId/_history/2" } | ||
val questionnaireResponse = ResourceMapper.populate(questionnaire, patient) | ||
|
||
assertThat((questionnaireResponse.item[0].answer[0].value as DateType).localDate) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assertThat((questionnaireResponse.item[0].answer[0].value as DateType).localDate) | |
assertThat((questionnaireResponse.item.single().answer.single().value as DateType).localDate) |
val patient = Patient().apply { id = "Patient/$patientId/_history/2" } | ||
val questionnaireResponse = ResourceMapper.populate(questionnaire, patient) | ||
|
||
assertThat((questionnaireResponse.item[0].answer[0].value as DateType).localDate) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you compare the two DateType
s directly instead of converting them to local date?
look at the equalsDeep
function in HAPI lib.
then your assert becomes something like this:
assert(this.equalsDeep(that)).isTrue()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to use equalsDeep but it was returning false because of the minor time difference in currentDate
and date returned from FHIRPath Function
.
I added another assertions to make sure that FHIRPath Function
returns currentDate
assertThat(fhirFunctionDateType.isToday).isTrue()
@@ -514,7 +548,7 @@ private fun wrapAnswerInFieldType(answer: Base, fieldType: Field): Base { | |||
return answer | |||
} | |||
|
|||
private const val ITEM_INITIAL_EXPRESSION_URL: String = | |||
const val ITEM_INITIAL_EXPRESSION_URL: String = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be internal?
@@ -21,6 +21,7 @@ import android.os.Build | |||
import androidx.test.core.app.ApplicationProvider | |||
import ca.uhn.fhir.context.FhirContext | |||
import ca.uhn.fhir.parser.IParser | |||
import com.google.android.fhir.datacapture.views.localDate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be removed - see later comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reason mentioned here #1295 (comment)
// extension function for evaluating provided initial expression and using the result as an | ||
// initial value of the QuestionnaireItemComponent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// extension function for evaluating provided initial expression and using the result as an | |
// initial value of the QuestionnaireItemComponent | |
// Extension function for evaluating provided initial expression and using the result as an | |
// initial value of the QuestionnaireItemComponent. |
) | ||
} | ||
} | ||
questionnaireItem.setInitialValueFromInitialExpression(resources = resources.asList()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please rename populateInitialValue
to populateIntialValueWithInitialExpression
.
…3_advance_behaviour
@jingtang10, I have incorporated all the requested changes. Kindly re-review this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created this PR as I don't have write access of https://github.com/google/android-fhir repo. I have resolved the changes that you requested earlier on this PR due to the same reason. |
Thanks @RaaziaTarique |
IMPORTANT: All PRs must be linked to an issue (except for extremely trivial and straightforward changes).
Fixes ##1033
Description
Added functionality to use
FhirPath functions
such astoday()
,now()
and etc.Previously these functions were not supported in SDK because it was only using the extracted resource from the
FhirPath expression
and in case ofFhirPath functions
, theFhirPath Expressions
doesn't have any resource name in it.Alternative(s) considered
Have you considered any alternatives? And if so, why have you chosen the approach in this PR?
Type
Choose one: Feature
Screenshots (if applicable)
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.