FHIR Core / OpenSRP 2 is a Kotlin application for delivering offline-capable, mobile-first healthcare project implementations from local community to national and international scale using FHIR and WHO Smart Guidelines on Android.
Describe the feature request.
As a content creator and project implementer I want to be able to run $apply on a PlanDefinition and any referenced CQL to create output resources, e.g. CarePlans.
I want to be able to optionally enable this instead of, or in addition to, the current method of executing PlanDefinitions.
Additional context
Our current approach to executing PlanDefinitions is to run a StructureMap on the PlanDefinition that uses FHIRPath within it to create additional resources.
[ ] Google's example PlanDefinition is loaded into an app config that also includes a config to execute it through the app UI
[ ] Executing the PlanDefinition through the app UI produces the expected output
Area path
Login to the WHO EIR
Open Navigation bar
Click on Patient register
Click on Add a patient
Click on Run plan def configured in the add patient questionnaire
Implementation plan (For Engineers)
[ ] Introduce a new boolean config property called QuestionnaireConfig.generateCarePlanWithWorkflowApi. When set to true, use $apply from the Workflow library to generate CarePlan otherwise default to using the current approach in FhirCarePlanGenerator#generateOrUpdateCarePlan().
[ ] Update the signature for the function FhirCarePlanGenerator#generateOrUpdateCarePlan() to include a new parameter generateCarePlanWithWorkflowApi. The value for this param should be obtained from the QuestionnaireConfig, which is available in the QuestionnaireViewModel (where the generate CarePlan function is called).
[ ] NOTE: The FhirCarePlanGenerator#generateOrUpdateCarePlan() is an overloaded function. The one to be updated has planDefinitionId: String in its parameters and is invoked directly in the QuestionnaireViewModel.
[ ] Implement functionality to execute $apply to generate CarePlan. Ideally, this should be done in a separate class (WorkflowCarePlanGenerator). The class will be injected into the FhirCarePlanGenerator constructor.
[ ] Update the implementation inside FhirCarePlanGenerator#generateOrUpdateCarePlan() to either use the new WorkflowCarePlanGenerator.generateCarePlan() or the current depending on the value passed through the QuestionnaireConfig.generateCarePlanWithWorkflowApi property.
[ ] The implementation for WorkflowCarePlanGenerator.generateCarePlan() can be adapted from this function applyPlanDefinitionOnPatient in the sample application. Copy and modify all the necessary functions from the sample code to WorkflowCarePlanGenerator as required.
[ ] Remember to document the functions and use the HILT injected instances of the KnowledgeManager and FhirOperator. The two can be injected as constructor properties of the WorkflowCarePlanGenerator class.
[ ] Update the tests for FhirCarePlanGenerator#generateOrUpdateCarePlan() and write new tests for WorkflowCarePlanGenerator.generateCarePlan(). Avoid using mocks unless really necessary, test the actual implementation instead, using injected dependencies.
Describe the feature request. As a content creator and project implementer I want to be able to run $apply on a PlanDefinition and any referenced CQL to create output resources, e.g. CarePlans.
I want to be able to optionally enable this instead of, or in addition to, the current method of executing PlanDefinitions.
Additional context Our current approach to executing PlanDefinitions is to run a StructureMap on the PlanDefinition that uses FHIRPath within it to create additional resources.
The android-fhir repo has an example app that executes a PlanDefinition using $apply through their Workflow API.
Acceptance criteria
Area path
Implementation plan (For Engineers)
[ ] Introduce a new boolean config property called
QuestionnaireConfig.generateCarePlanWithWorkflowApi
. When set totrue
, use $apply from the Workflow library to generate CarePlan otherwise default to using the current approach inFhirCarePlanGenerator#generateOrUpdateCarePlan()
.[ ] Update the signature for the function
FhirCarePlanGenerator#generateOrUpdateCarePlan()
to include a new parametergenerateCarePlanWithWorkflowApi
. The value for this param should be obtained from theQuestionnaireConfig
, which is available in theQuestionnaireViewModel
(where the generate CarePlan function is called).[ ] NOTE: The
FhirCarePlanGenerator#generateOrUpdateCarePlan()
is an overloaded function. The one to be updated hasplanDefinitionId: String
in its parameters and is invoked directly in theQuestionnaireViewModel
.[ ] Implement functionality to execute $apply to generate CarePlan. Ideally, this should be done in a separate class (
WorkflowCarePlanGenerator
). The class will be injected into theFhirCarePlanGenerator
constructor.[ ] Update the implementation inside
FhirCarePlanGenerator#generateOrUpdateCarePlan()
to either use the newWorkflowCarePlanGenerator.generateCarePlan()
or the current depending on the value passed through theQuestionnaireConfig.generateCarePlanWithWorkflowApi
property.[ ] The implementation for
WorkflowCarePlanGenerator.generateCarePlan()
can be adapted from this function applyPlanDefinitionOnPatient in the sample application. Copy and modify all the necessary functions from the sample code toWorkflowCarePlanGenerator
as required.[ ] Remember to document the functions and use the HILT injected instances of the KnowledgeManager and FhirOperator. The two can be injected as constructor properties of the
WorkflowCarePlanGenerator
class.[ ] Update the tests for
FhirCarePlanGenerator#generateOrUpdateCarePlan()
and write new tests forWorkflowCarePlanGenerator.generateCarePlan()
. Avoid using mocks unless really necessary, test the actual implementation instead, using injected dependencies.