Skip to content

Commit

Permalink
Merge branch 'master' into 2356-save-help-card-state
Browse files Browse the repository at this point in the history
  • Loading branch information
FikriMilano authored Jan 28, 2024
2 parents 70aac0b + 99c5b9c commit fe549db
Show file tree
Hide file tree
Showing 4 changed files with 197 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ class QuestionnaireFragment : Fragment() {
reviewModeEditButton.visibility = View.GONE

if (displayMode.pagination.isPaginated) {
paginationPreviousButton.visibility = View.VISIBLE
paginationPreviousButton.isEnabled = displayMode.pagination.hasPreviousPage
paginationPreviousButton.visibility =
if (displayMode.pagination.hasPreviousPage) View.VISIBLE else View.GONE
paginationNextButton.visibility =
if (displayMode.pagination.hasNextPage) View.VISIBLE else View.GONE
} else {
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 @@ -139,6 +139,153 @@ class QuestionnaireFragmentTest {
.isEqualTo(View.VISIBLE)
}

@Test
fun `should hide next button on last page`() {
val questionnaireJson =
"""{
"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": "Item 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": "display",
"text": "Item 2"
}
]
}
]
}
"""
val scenario =
launchFragmentInContainer<QuestionnaireFragment>(
bundleOf(
EXTRA_QUESTIONNAIRE_JSON_STRING to questionnaireJson,
),
)
scenario.moveToState(Lifecycle.State.RESUMED)
val view = scenario.withFragment { requireView() }
view.findViewById<Button>(R.id.pagination_next_button).performClick()
assertThat(view.findViewById<Button>(R.id.pagination_next_button).visibility)
.isEqualTo(View.GONE)
}

@Test
fun `should hide previous button on first page`() {
val questionnaireJson =
"""{
"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": "Item 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": "display",
"text": "Item 2"
}
]
}
]
}
"""
val scenario =
launchFragmentInContainer<QuestionnaireFragment>(
bundleOf(
EXTRA_QUESTIONNAIRE_JSON_STRING to questionnaireJson,
),
)
scenario.moveToState(Lifecycle.State.RESUMED)
val view = scenario.withFragment { requireView() }
assertThat(view.findViewById<Button>(R.id.pagination_previous_button).visibility)
.isEqualTo(View.GONE)
}

@Test
fun `questionnaireItemViewHolderFactoryMatchersProvider should have custom QuestionnaireItemViewHolderFactoryMatchers `() {
ApplicationProvider.getApplicationContext<DataCaptureTestApplication>()
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 fe549db

Please sign in to comment.