Skip to content
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

[ZEIR] - Growth Monitoring : Z-Score Computation #2745

Merged
merged 10 commits into from
Sep 14, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@
try {
val configBinary = fhirEngine.get<Binary>(extractedId)
configsJsonMap[configIdentifier] = configBinary.content.decodeToString()
} catch (resourceNotFoundException: ResourceNotFoundException) {
Timber.e("Missing Binary file with ID :$extractedId")

Check warning on line 311 in android/engine/src/main/java/org/smartregister/fhircore/engine/configuration/ConfigurationRegistry.kt

View check run for this annotation

Codecov / codecov/patch

android/engine/src/main/java/org/smartregister/fhircore/engine/configuration/ConfigurationRegistry.kt#L310-L311

Added lines #L310 - L311 were not covered by tests
withContext(dispatcherProvider.main()) { configsLoadedCallback(false) }
}
}
Expand Down Expand Up @@ -382,6 +382,7 @@
ResourceType.PlanDefinition.name,
ResourceType.Library.name,
ResourceType.Measure.name,
ResourceType.Basic.name,
)
}
.forEach { resourceGroup ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@
import java.util.Date
import java.util.UUID
import javax.inject.Inject
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.hl7.fhir.r4.context.IWorkerContext
import org.hl7.fhir.r4.model.Basic
import org.hl7.fhir.r4.model.Bundle
import org.hl7.fhir.r4.model.Group
import org.hl7.fhir.r4.model.IdType
Expand Down Expand Up @@ -215,7 +218,7 @@
// Important to load subject resource to retrieve ID (as reference) correctly
val subjectIdType: IdType? =
if (currentQuestionnaireResponse.subject.reference.isNullOrEmpty()) {
null

Check warning on line 221 in android/quest/src/main/java/org/smartregister/fhircore/quest/ui/questionnaire/QuestionnaireViewModel.kt

View check run for this annotation

Codecov / codecov/patch

android/quest/src/main/java/org/smartregister/fhircore/quest/ui/questionnaire/QuestionnaireViewModel.kt#L221

Added line #L221 was not covered by tests
} else {
IdType(currentQuestionnaireResponse.subject.reference)
}
Expand All @@ -233,11 +236,14 @@
questionnaireConfig = questionnaireConfig,
)

executeCql(
subject = subject,
bundle = newBundle,
questionnaire = questionnaire,
)
withContext(Dispatchers.IO) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use dispatcherProvider.io() here instead? The provider is already injected as a constructor parameter

executeCql(
subject = subject,
bundle = newBundle,
questionnaire = questionnaire,
)
}

fhirCarePlanGenerator.conditionallyUpdateResourceStatus(
questionnaireConfig = questionnaireConfig,
subject = subject,
Expand Down Expand Up @@ -333,7 +339,7 @@
if (resource != null) {
this.id = resource.logicalId
if (this is RelatedPerson && resource is RelatedPerson) {
this.identifier = resource.identifier

Check warning on line 342 in android/quest/src/main/java/org/smartregister/fhircore/quest/ui/questionnaire/QuestionnaireViewModel.kt

View check run for this annotation

Codecov / codecov/patch

android/quest/src/main/java/org/smartregister/fhircore/quest/ui/questionnaire/QuestionnaireViewModel.kt#L342

Added line #L342 was not covered by tests
}
}
}
Expand Down Expand Up @@ -568,9 +574,19 @@
.all { it is Valid || it is NotValidated }

suspend fun executeCql(subject: Resource, bundle: Bundle, questionnaire: Questionnaire) {
questionnaire.cqfLibraryIds().forEach {
questionnaire.cqfLibraryIds().forEach { libraryId ->
if (
libraryId == "223758"
) { // Resource id for Library that calculates Z-score in ZEIR application
// Adding 4 basic resources which contain the Data needed for Z-score calculation
val basicResourceIds = listOf("223754", "223755", "223756", "223757")
basicResourceIds.forEach { resourceId ->
val basicResource = defaultRepository.loadResource(resourceId) as Basic?
bundle.addEntry(Bundle.BundleEntryComponent().setResource(basicResource))

Check warning on line 585 in android/quest/src/main/java/org/smartregister/fhircore/quest/ui/questionnaire/QuestionnaireViewModel.kt

View check run for this annotation

Codecov / codecov/patch

android/quest/src/main/java/org/smartregister/fhircore/quest/ui/questionnaire/QuestionnaireViewModel.kt#L582-L585

Added lines #L582 - L585 were not covered by tests
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please create a new issue to make this generic with a proposal on how to do this and add a TODO on line 577 that links to that issue

if (subject.resourceType == ResourceType.Patient) {
libraryEvaluator.runCqlLibrary(it, subject as Patient, bundle)
libraryEvaluator.runCqlLibrary(libraryId, subject as Patient, bundle)
}
}
}
Expand Down
Loading