diff --git a/workflow/src/androidTest/java/com/google/android/fhir/workflow/FhirOperatorLibraryEvaluateTest.kt b/workflow/src/androidTest/java/com/google/android/fhir/workflow/FhirOperatorLibraryEvaluateTest.kt index eb857c49a3..91de7a807e 100644 --- a/workflow/src/androidTest/java/com/google/android/fhir/workflow/FhirOperatorLibraryEvaluateTest.kt +++ b/workflow/src/androidTest/java/com/google/android/fhir/workflow/FhirOperatorLibraryEvaluateTest.kt @@ -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. @@ -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() + } } diff --git a/workflow/src/main/java/com/google/android/fhir/workflow/FhirOperator.kt b/workflow/src/main/java/com/google/android/fhir/workflow/FhirOperator.kt index fb3e0a6c75..81ca998e40 100644 --- a/workflow/src/main/java/com/google/android/fhir/workflow/FhirOperator.kt +++ b/workflow/src/main/java/com/google/android/fhir/workflow/FhirOperator.kt @@ -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): IBaseParameters { + fun evaluateLibrary(libraryUrl: String, expressions: Set?): IBaseParameters { return evaluateLibrary(libraryUrl, null, null, expressions) } @@ -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, + expressions: Set?, ): IBaseParameters { return evaluateLibrary(libraryUrl, patientId, null, expressions) } @@ -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, + expressions: Set?, ): IBaseParameters { return evaluateLibrary(libraryUrl, null, parameters, expressions) } @@ -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, + expressions: Set?, ): IBaseParameters { return libraryProcessor.evaluate( /* url = */ libraryUrl,