-
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
populate initial with initialExpression result collection #2751
base: master
Are you sure you want to change the base?
Conversation
To support multiple initially selected options from the dropdown, not quite sure populating the
I would suggest maybe using |
@LZRS Thank you so much for your feedback! Invariant:
cc: @jingtang10 , @icrc-jofrancisco |
datacapture/src/main/java/com/google/android/fhir/datacapture/mapping/ResourceMapper.kt
Show resolved
Hide resolved
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
… initialExpression
datacapture/src/main/java/com/google/android/fhir/datacapture/mapping/ResourceMapper.kt
Outdated
Show resolved
Hide resolved
datacapture/src/main/java/com/google/android/fhir/datacapture/mapping/ResourceMapper.kt
Outdated
Show resolved
Hide resolved
datacapture/src/main/java/com/google/android/fhir/datacapture/mapping/ResourceMapper.kt
Show resolved
Hide resolved
Handles repeats logic for answerOption
…o fix-populate-initial-values
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.
Very good test cases! Thanks @parthfloyd!
A few comments below
@@ -2973,6 +2979,414 @@ class ResourceMapperTest { | |||
) | |||
} | |||
|
|||
@Test | |||
fun `populate() should fail with IllegalStateException when QuestionnaireItem of group or display item has a initial value`(): |
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 split this into 2 smaller test cases one for group one for display item?
In each questionnaire just include a single questionnaire item.
In general, for tests, it's much better to keep tests small and focused. So when a test fails from the test name you'll immediately figure out what's the problem, instead of having to debug.
val questionnaireResponse = | ||
ResourceMapper.populate(questionnaire, mapOf("observations" to observationBundle)) | ||
|
||
assertThat((questionnaireResponse.item[0].answer[0].value as Coding).code) |
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.
extract questionnaireResponse.item[0].answer[0].value as a variable. or use kotlin's with
:
with(questionnaireResponse.item[0].answer[0].value) {
assert(this.code...)
assert(this.system...)
}
val observation1 = | ||
Observation().apply { | ||
status = Observation.ObservationStatus.FINAL | ||
value = | ||
CodeableConcept().apply { | ||
coding = | ||
mutableListOf( | ||
Coding().apply { | ||
code = "correct-code-val" | ||
display = "correct-display-val" | ||
}, | ||
) | ||
} | ||
} | ||
val observation2 = | ||
Observation().apply { | ||
status = Observation.ObservationStatus.FINAL | ||
value = | ||
CodeableConcept().apply { | ||
coding = | ||
mutableListOf( | ||
Coding().apply { | ||
code = "correct-code-val" | ||
display = "correct-display-val" | ||
}, | ||
) | ||
} | ||
} |
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.
what's the significance of having 2 observations in this test case? it seems that's not really being tested?
is the point you would collapse the 2 choices? would it be better to give the second observation a different coding and show that the first one is chosen?
assertThat((questionnaireResponse.item[0].answer[0].value as Coding).code) | ||
.isEqualTo("correct-code-val") | ||
assertThat((questionnaireResponse.item[0].answer[0].value as Coding).display) | ||
.isEqualTo("correct-display-val") | ||
assertThat((questionnaireResponse.item[0].answer[1].value as Coding).code) | ||
.isEqualTo("correct2-code-val") | ||
assertThat((questionnaireResponse.item[0].answer[1].value as Coding).display) | ||
.isEqualTo("correct2-display-val") |
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.
similarly extract local variables instead of repeating
} | ||
|
||
@Test | ||
fun `populate() should select a single initial answer for non repeating question without answerOption`() = |
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 a missing test case here is that if there's no answer option but the expression evaluates to multiple values?
you should test in that case only the first value is used. right?
IMPORTANT: All PRs must be linked to an issue (except for extremely trivial and straightforward changes).
Fixes #2750
Description
Updated
populateInitialValue()
function inResourceMapper.kt
of the SDC module to populatequestionnaireItem.initial
with values of collection instead of just the first value of the collection.Alternative(s) considered
None | Looking forward to feedback
Type
Bug fix
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.