Skip to content

Commit

Permalink
Merge branch 'master' into modify-submit
Browse files Browse the repository at this point in the history
  • Loading branch information
f-odhiambo committed Jan 22, 2024
2 parents 6533875 + 9d41e1b commit 0bf6fe2
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 19 deletions.
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/Releases.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Google LLC
* Copyright 2023-2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -54,7 +54,7 @@ object Releases {

object DataCapture : LibraryArtifact {
override val artifactId = "data-capture"
override val version = "1.0.0"
override val version = "1.1.0"
override val name = "Android FHIR Structured Data Capture Library"
}

Expand Down
60 changes: 60 additions & 0 deletions datacapture/sampledata/layout_paginated.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"resourceType": "Questionnaire",
"item": [
{
"linkId": "1",
"type": "group",
"extension": [
{
"url": "http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl",
"valueCodeableConcept": {
"coding": [
{
"system": "http://hl7.org/fhir/questionnaire-item-control",
"code": "page",
"display": "Page"
}
],
"text": "Page"
}
}
],
"item": [
{
"linkId": "1.1",
"type": "display",
"text": "Personal information",
"prefix": "1."
}
]
},
{
"linkId": "2",
"type": "group",
"extension": [
{
"url": "http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl",
"valueCodeableConcept": {
"coding": [
{
"system": "http://hl7.org/fhir/questionnaire-item-control",
"code": "page",
"display": "Page"
}
],
"text": "Page"
}
}
],
"item": [
{
"linkId": "2.1",
"type": "date",
"text": "Date of birth",
"prefix": "2.",
"required": true
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Google LLC
* Copyright 2023-2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -105,6 +105,30 @@ class QuestionnaireUiEspressoTest {
)
}

@Test
fun shouldHideNextButtonIfDisabled() {
buildFragmentFromQuestionnaire("/layout_paginated.json", true)

clickOnText("Next")

onView(withId(R.id.pagination_next_button))
.check(
ViewAssertions.matches(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.GONE)),
)
}

@Test
fun shouldDisplayNextButtonIfEnabled() {
buildFragmentFromQuestionnaire("/layout_paginated.json", true)

onView(withId(R.id.pagination_next_button))
.check(
ViewAssertions.matches(
ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE),
),
)
}

@Test
fun integerTextEdit_inputOutOfRange_shouldShowError() {
buildFragmentFromQuestionnaire("/text_questionnaire_integer.json")
Expand Down Expand Up @@ -503,6 +527,7 @@ class QuestionnaireUiEspressoTest {
val questionnaireFragment =
QuestionnaireFragment.builder()
.setQuestionnaire(questionnaireJsonString)
.setShowCancelButton(true)
.showReviewPageBeforeSubmit(isReviewMode)
.build()
activityScenarioRule.scenario.onActivity { activity ->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Google LLC
* Copyright 2023-2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -199,8 +199,8 @@ class QuestionnaireFragment : Fragment() {
if (displayMode.pagination.isPaginated) {
paginationPreviousButton.visibility = View.VISIBLE
paginationPreviousButton.isEnabled = displayMode.pagination.hasPreviousPage
paginationNextButton.visibility = View.VISIBLE
paginationNextButton.isEnabled = displayMode.pagination.hasNextPage
paginationNextButton.visibility =
if (displayMode.pagination.hasNextPage) View.VISIBLE else View.GONE
} else {
paginationPreviousButton.visibility = View.GONE
paginationNextButton.visibility = View.GONE
Expand Down
2 changes: 1 addition & 1 deletion datacapture/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@
</style>
<style
name="Questionnaire.CancelButtonStyle"
parent="Widget.Material3.Button.OutlinedButton"
parent="Widget.Material3.Button.TextButton"
>
<item name="android:textAllCaps">false</item>
<item name="android:visibility">visible</item>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022-2023 Google LLC
* Copyright 2022-2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -132,4 +132,27 @@ class FhirOperatorLibraryEvaluateTest {

assertThat(results.getParameterBool("CompletedImmunization")).isTrue()
}

@Test
fun evaluateImmunityCheck_shouldReturn_allEvaluatedVariables() = runBlocking {
val patientImmunizationHistory = load("/immunity-check/ImmunizationHistory.json") as Bundle
for (entry in patientImmunizationHistory.entry) {
fhirEngine.create(entry.resource)
}

// Load Library that checks if Patient has taken a vaccine
knowledgeManager.install(copy("/immunity-check/ImmunityCheck.json"))

// Evaluates a specific Patient
val results =
fhirOperator.evaluateLibrary(
libraryUrl = "http://localhost/Library/ImmunityCheck|1.0.0",
patientId = "d4d35004-24f8-40e4-8084-1ad75924514f",
expressions = null,
) as Parameters

assertThat(results.hasParameter("CompletedImmunization")).isTrue()
assertThat(results.hasParameter("GetFinalDose")).isTrue()
assertThat(results.hasParameter("Patient")).isTrue()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,14 @@ internal constructor(
* from a worker thread or it may throw [BlockingMainThreadException] exception.
*
* @param libraryUrl the url of the Library to evaluate
* @param expressions names of expressions in the Library to evaluate.
* @param expressions names of expressions in the Library to evaluate. If null the result contains
* all evaluations or variables in library.
* @return a Parameters resource that contains an evaluation result for each expression requested.
* Or if expressions param is null then result contains all evaluations or variables in given
* library.
*/
@WorkerThread
fun evaluateLibrary(libraryUrl: String, expressions: Set<String>): IBaseParameters {
fun evaluateLibrary(libraryUrl: String, expressions: Set<String>?): IBaseParameters {
return evaluateLibrary(libraryUrl, null, null, expressions)
}

Expand All @@ -94,14 +97,17 @@ internal constructor(
*
* @param libraryUrl the url of the Library to evaluate
* @param patientId the Id of the patient to be evaluated
* @param expressions names of expressions in the Library to evaluate.
* @return a Parameters resource that contains an evaluation result for each expression requested
* @param expressions names of expressions in the Library to evaluate. If null the result contains
* all evaluations or variables in library.
* @return a Parameters resource that contains an evaluation result for each expression requested.
* Or if expressions param is null then result contains all evaluations or variables in given
* library.
*/
@WorkerThread
fun evaluateLibrary(
libraryUrl: String,
patientId: String,
expressions: Set<String>,
expressions: Set<String>?,
): IBaseParameters {
return evaluateLibrary(libraryUrl, patientId, null, expressions)
}
Expand All @@ -114,14 +120,17 @@ internal constructor(
*
* @param libraryUrl the url of the Library to evaluate
* @param parameters list of parameters to be passed to the CQL library
* @param expressions names of expressions in the Library to evaluate.
* @return a Parameters resource that contains an evaluation result for each expression requested
* @param expressions names of expressions in the Library to evaluate. If null the result contains
* all evaluations or variables in library.
* @return a Parameters resource that contains an evaluation result for each expression requested.
* Or if expressions param is null then result contains all evaluations or variables in given
* library.
*/
@WorkerThread
fun evaluateLibrary(
libraryUrl: String,
parameters: Parameters,
expressions: Set<String>,
expressions: Set<String>?,
): IBaseParameters {
return evaluateLibrary(libraryUrl, null, parameters, expressions)
}
Expand All @@ -135,15 +144,18 @@ internal constructor(
* @param libraryUrl the url of the Library to evaluate
* @param patientId the Id of the patient to be evaluated, if applicable
* @param parameters list of parameters to be passed to the CQL library, if applicable
* @param expressions names of expressions in the Library to evaluate.
* @return a Parameters resource that contains an evaluation result for each expression requested
* @param expressions names of expressions in the Library to evaluate. If null the result contains
* all evaluations or variables in library.
* @return a Parameters resource that contains an evaluation result for each expression requested.
* Or if expressions param is null then result contains all evaluations or variables in given
* library.
*/
@WorkerThread
fun evaluateLibrary(
libraryUrl: String,
patientId: String?,
parameters: Parameters?,
expressions: Set<String>,
expressions: Set<String>?,
): IBaseParameters {
return libraryProcessor.evaluate(
/* url = */ libraryUrl,
Expand Down

0 comments on commit 0bf6fe2

Please sign in to comment.