-
Notifications
You must be signed in to change notification settings - Fork 59
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
Changes from 5 commits
ef35578
b1cd931
8ab75ef
7cb2360
3f5bffa
5044a87
e2b96f4
0e55ab3
66eba1c
b719134
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 Codecov / codecov/patchandroid/quest/src/main/java/org/smartregister/fhircore/quest/ui/questionnaire/QuestionnaireViewModel.kt#L221
|
||
} else { | ||
IdType(currentQuestionnaireResponse.subject.reference) | ||
} | ||
|
@@ -233,11 +236,14 @@ | |
questionnaireConfig = questionnaireConfig, | ||
) | ||
|
||
executeCql( | ||
subject = subject, | ||
bundle = newBundle, | ||
questionnaire = questionnaire, | ||
) | ||
withContext(Dispatchers.IO) { | ||
executeCql( | ||
subject = subject, | ||
bundle = newBundle, | ||
questionnaire = questionnaire, | ||
) | ||
} | ||
|
||
fhirCarePlanGenerator.conditionallyUpdateResourceStatus( | ||
questionnaireConfig = questionnaireConfig, | ||
subject = subject, | ||
|
@@ -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 Codecov / codecov/patchandroid/quest/src/main/java/org/smartregister/fhircore/quest/ui/questionnaire/QuestionnaireViewModel.kt#L342
|
||
} | ||
} | ||
} | ||
|
@@ -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 Codecov / codecov/patchandroid/quest/src/main/java/org/smartregister/fhircore/quest/ui/questionnaire/QuestionnaireViewModel.kt#L582-L585
|
||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
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