Skip to content

Commit

Permalink
Follow up PR of 2025 (google#2265)
Browse files Browse the repository at this point in the history
* Use launchContext for initialExpression

* Test ResourceMapper

* Fix test

* Fix launchContexts for demo app when editing patient

* spotlessApply

* WIP

* Revert "WIP"

This reverts commit d2d53a2.

* spotlessApply

* Fix test

* Refactor validateLaunchContextExtension

* Remove QuestionnaireLaunchContextSet enum class

* Rename vars and functions

* Add code comment for MoreResourceTypes.kt

* Unit testing

* Fix post-merge-conflict

* spotlessApply

* Address review

* spotlessApply

* Revert un-intended changes

* Fix failing checks

* Remove check of must contain 2 sub-extensions

* Update Kdoc

* Revert

* validate launch context when using populate public API

* Address Jing's Review

- google#2025 (comment)
- google#2025 (comment)
  • Loading branch information
FikriMilano authored and Santosh Pingle committed Oct 18, 2023
1 parent 706f7e0 commit b5f5eb1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,15 @@ object ResourceMapper {

questionnaireItem.initialExpression
?.let {
fhirPathEngine.evaluate(launchContexts, null, null, null, it.expression).firstOrNull()
fhirPathEngine
.evaluate(
/* appContext= */ launchContexts,
/* focusResource= */ null,
/* rootResource= */ null,
/* base= */ null,
/* path= */ it.expression,
)
.firstOrNull()
}
?.let {
// Set initial value for the questionnaire item. Questionnaire items should not have both
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -812,16 +812,6 @@ class ResourceMapperTest {
runBlocking {
val questionnaire =
Questionnaire()
.apply {
addExtension().apply {
url = EXTENSION_SDC_QUESTIONNAIRE_LAUNCH_CONTEXT
extension =
listOf(
Extension("name", Coding(EXTENSION_LAUNCH_CONTEXT, "mother", "Mother")),
Extension("type", CodeType("Patient")),
)
}
}
.addItem(
Questionnaire.QuestionnaireItemComponent().apply {
linkId = "patient-dob"
Expand All @@ -839,9 +829,7 @@ class ResourceMapperTest {
},
)

val patientId = UUID.randomUUID().toString()
val patient = Patient().apply { id = "Patient/$patientId/_history/2" }
val questionnaireResponse = ResourceMapper.populate(questionnaire, mapOf("mother" to patient))
val questionnaireResponse = ResourceMapper.populate(questionnaire, emptyMap())

assertThat((questionnaireResponse.item[0].answer[0].value as DateType).localDate)
.isEqualTo((DateType(Date())).localDate)
Expand Down

0 comments on commit b5f5eb1

Please sign in to comment.