-
Notifications
You must be signed in to change notification settings - Fork 302
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
Fix issue with empty context with initial expression #1228
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1228 +/- ##
============================================
+ Coverage 84.50% 84.53% +0.02%
- Complexity 686 687 +1
============================================
Files 148 148
Lines 10697 10701 +4
Branches 832 832
============================================
+ Hits 9040 9046 +6
+ Misses 1244 1240 -4
- Partials 413 415 +2
Continue to review full report at Codecov.
|
…3_advance_behaviour
… evaluate method.
…3_advance_behaviour
- Add test cases in ResourceMapperTest.kt
@@ -957,6 +990,231 @@ class ResourceMapperTest { | |||
.isEqualTo(true) | |||
} | |||
|
|||
@Test | |||
fun `populate() should fill QuestionnaireResponse with values when given a single Resource should use definition based extraction`() = |
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.
- Just a question. What does this test assert that the other population tests do not
- I think that the
should use definition based extraction
should not be part of this tests function and name
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.
As per the discussion, I have removed the definition based initial expression evaluation code and test cases in favour of itemPopulationContext http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemPopulationContext which will be handled in another 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.
Cool
@@ -490,6 +491,38 @@ class ResourceMapperTest { | |||
assertThat(patient.telecom[0].value).isEqualTo("+254711001122") | |||
} | |||
|
|||
@Test | |||
fun `populate() should correctly populate current date in QuestionnaireResponse`() = runBlocking { | |||
val ITEM_EXTRACTION_CONTEXT_EXTENSION_URL = |
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 think we can use this directly instead
@@ -490,6 +491,38 @@ class ResourceMapperTest { | |||
assertThat(patient.telecom[0].value).isEqualTo("+254711001122") | |||
} | |||
|
|||
@Test | |||
fun `populate() should correctly populate current date in QuestionnaireResponse`() = runBlocking { | |||
val ITEM_EXTRACTION_CONTEXT_EXTENSION_URL = |
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.
the name of this is wrong, this is not item extraction context. this is initial expression
@@ -198,17 +197,21 @@ object ResourceMapper { | |||
) { | |||
if (questionnaireItem.type != Questionnaire.QuestionnaireItemType.GROUP) { | |||
questionnaireItem.fetchExpression?.let { exp -> |
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 rename the fetchExpression
property to intialExpression
?
extractedAnswers = | ||
fhirPathEngine.evaluate(resources[0], expression.expression.removePrefix("%")) |
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.
these lines and line 221-222 are doing the same except for the context resource. So what you should do is to have
val contextResource = if( ... ) { ... } else { ... }
and then have
extractedAnswers =
fhirPathEngine.evaluate(contextResource, expression.expression.removePrefix("%"))
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 is this logic not in the function getContextResource
?
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.
LGTM
datacapture/src/main/java/com/google/android/fhir/datacapture/mapping/ResourceMapper.kt
Outdated
Show resolved
Hide resolved
Struggling to make the tests pass on GitHub even though they're passing locally... |
tests should hopefully pass after #1324 |
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.