opensrp / fhircore

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.
https://smartregister.org
Apache License 2.0
53 stars 41 forks source link

Check CqlEvaluatorSampleApp & Integrate CQL Library as demo app into FHIR core #177

Closed f-odhiambo closed 2 years ago

f-odhiambo commented 3 years ago

This is a simple app that creates a cql-evaluator and runs the WHO ANC Recommendation A2 content. It was created using Android Studio. Link to repo

Checks

Sample Screenshots

.

Integration

After this we proceed to

f-odhiambo commented 3 years ago

Bug in the demo app : Seems like there are some libraries that are not syncing anymore and closing the app to terminate before launch

  1. Could not find org.opencds.cqf.cql:evaluator:1.2.0-SNAPSHOT.
  2. Could not find org.opencds.cqf.cql:evaluator.builder:1.2.0-SNAPSHOT.
  3. Could not find org.opencds.cqf.cql:evaluator.dagger:1.2.0-SNAPSHOT.

Bug reported here https://github.com/DBCG/CqlEvaluatorSampleApp/issues/1#issue-909546106

f-odhiambo commented 3 years ago

Updated the libs and now working fine

rkodev commented 3 years ago

Summary of the Sample CQL Application

The app is able to evaluate CQL expressions written in text/cql. The sample app demonstrates the ability to load a FHIR Library and Value Sets thats are later used to evaluate the Libraries parameter output against a Patient Resource as an input parameter.

As of the time of this post, neither $measure_evaluate nor $apply operations are capable with the version of this app.

It should be possible to integrate the library as it is to the fhir-core application but for some major concerns with the duration. It takes a long time to run a single evaluation operation on Actual Devices.

Side Note

CQL-Ruler Library is capable of evaluating PlanDefinition $apply and MesureReport $evaluate-measure. Evaluation on Android Platform was not possible but was possible on the server side

pld commented 3 years ago
  1. How we will evaluate Measure(s) to get MeasureReport(s)
    • should any of the work we do towards this issue go upstream into the CQL libs?
  2. How and what parts of this will go into the “engine” section and what into the “chw anc” app section?
    • and are there other custom pieces not in either of those?
pld commented 3 years ago

Ie the first task under integration needs more definition, before we begin on it, but the others are unblocked

MuhammadSalman-7214 commented 3 years ago
  1. How we will evaluate Measure(s) to get MeasureReport(s)

    • should any of the work we do towards this issue go upstream into the CQL libs?
  2. How and what parts of this will go into the “engine” section and what into the “chw anc” app section?

    • and are there other custom pieces not in either of those?

@f-odhiambo can you please answer this one?

MuhammadSalman-7214 commented 3 years ago
  1. How we will evaluate Measure(s) to get MeasureReport(s)

    • should any of the work we do towards this issue go upstream into the CQL libs?
  2. How and what parts of this will go into the “engine” section and what into the “chw anc” app section?

    • and are there other custom pieces not in either of those?

@f-odhiambo can you please answer this one?

as far as I can answer, currently it will be independent of both covax and chw application

MuhammadSalman-7214 commented 3 years ago

Ie the first task under integration needs more definition, before we begin on it, but the others are unblocked

yes have a call with @f-odhiambo regarding this, and currently we decided to proceed with cql as a separate application than fhir core

MuhammadSalman-7214 commented 3 years ago

There can be two approaches to integrate CQL evaluator application into Fhir Core:

  1. Either we integrate it as a separate application from fhir core, which means we would not be able to access code from fhir core in cql application.
  2. We can integrate cql application as a module into fhir core, and then include this cql module into fhir core, but for this approach as well, the code for cql stuff would be written in cql module, but here we will be able to access code from fhir core.
pld commented 3 years ago

Sounds like we need to go w/(2) since the value of integration is being able to call this functionality within FHIR Core

I also do not think we should include any of the UI components. My understanding is that the goal of the integration is so we can implement #404 and #405, not have a CQL demo

pld commented 3 years ago

Ie the first task under integration needs more definition, before we begin on it, but the others are unblocked

yes have a call with @f-odhiambo regarding this, and currently we decided to proceed with cql as a separate application than fhir core

Sounds good, @ekigamba can you join this as well? After the meeting please post the plan here so I can take a look, I'm happy to join as well, but definitely proceed w/out me and I can catch up, I don't want to slow you down!

MuhammadSalman-7214 commented 3 years ago

Ie the first task under integration needs more definition, before we begin on it, but the others are unblocked

yes have a call with @f-odhiambo regarding this, and currently we decided to proceed with cql as a separate application than fhir core

@pld if we are going with second approach, then this is now no longer valid as cql would be a module instead of an application

pld commented 3 years ago

True, we can rewrite the title and description of the issue to match this.

My assumption is that there's code in this app that's useful for #404 and #405, maybe it'd be more useful to work on one of those issues directly and treat this as a sub-issue of those to pull in common CQL functionality.

@f-odhiambo am I missing something here?

ekigamba commented 3 years ago

Ie the first task under integration needs more definition, before we begin on it, but the others are unblocked

yes have a call with @f-odhiambo regarding this, and currently we decided to proceed with cql as a separate application than fhir core

Sounds good, @ekigamba can you join this as well? After the meeting please post the plan here so I can take a look, I'm happy to join as well, but definitely proceed w/out me and I can catch up, I don't want to slow you down!

Sure @pld

f-odhiambo commented 3 years ago

True, we can rewrite the title and description of the issue to match this.

My assumption is that there's code in this app that's useful for #404 and #405, maybe it'd be more useful to work on one of those issues directly and treat this as a sub-issue of those to pull in common CQL functionality.

@f-odhiambo am I missing something here?

@pld We will need to extend the work Ronald was working on for the search use cases to achieve this. Search will need to be extended to work for either name (First name, Last Name, Family name), IDs (UUID, Logical ID, Identifiers) and resources (Encounters, Observations, Practitioners etc) for issues #404 & #405

For this piece of work, I think we are looking at the base code, resources to achieve measure reporting by using the Parameter bundle resource it generates, and later to be consumed by HAPI for $measure_evalute and generate a measure report

f-odhiambo commented 3 years ago

Sounds like we need to go w/(2) since the value of integration is being able to call this functionality within FHIR Core

I also do not think we should include any of the UI components. My understanding is that the goal of the integration is so we can implement #404 and #405, not have a CQL demo

@pld for the mADX work we need to achieve the following

  1. Log in to the app
  2. View a list of patient
  3. Search (Patient /Encounter / Observations)
  4. Define the measure for the indicator (for POC we shall go with Indicator i.e. Percentage of pregnant women with first ANC contact in the first trimester (before 1 week of gestation) ) we need to report
  5. Run $measure_evalute
  6. Show measure report

Thus UI component for this is required

f-odhiambo commented 3 years ago

So we skip moving from Evaluation page directly to map the floe above

pld commented 3 years ago

To clarify, I meant the UI of this specific demo app is not required.

To achieve that we can use the ANC app NOT a separate CQL specific demo app.

f-odhiambo commented 3 years ago

Copy that. All Clear

MuhammadSalman-7214 commented 3 years ago

So based on @pld comments that we don't need the UI of the demo application, the approach finalized with @f-odhiambo and @ekigamba is as follows:

We will not import the cql demo application as a module into fhir core, instead we will copy some of the code and dependencies directly from reference application to fhir core and then use it to achieve our use cases within fhir core directly

MuhammadSalman-7214 commented 3 years ago

Update:

  1. Cql Evaluator reference application has been integrated into fhir core
  2. We have uploaded all Library Resources and Plan Definition Resource to server, and they are being used from server instead of assets folder, but we still need to upload valueset and test bundle files to server. Currently both valueset and test bundle files are being used from asset folder
  3. Though we have uploaded Plan Definition resource file to server, but currently there isn't any usage of the plan definition in the codebase(code of reference application that has been integrated to fhir core)

Branch Name Pushed: feature/integrate-cql-evaluation-application

@f-odhiambo

pld commented 3 years ago

awesome work! is it ready for a PR yet?

MuhammadSalman-7214 commented 3 years ago

awesome work! is it ready for a PR yet?

yes almost

f-odhiambo commented 3 years ago

Update

  1. Shifting this codebase to a module has been done and is ready for review https://github.com/opensrp/fhircore/pull/490
  2. Canonical Types are not being handled yet in FHIR SDK tracked under issues https://github.com/google/android-fhir/issues/694. Until this is resolved we will not be able to sync value sets and test JSON from the server into the local SQLite DB
f-odhiambo commented 3 years ago

@kimigxfoxy Kindly take note that #414 is now complete and that this codebase will need to go under report but accessed via the ANC module

New structure /anc - anything ANC specific will build CHW app for LMH and mADX /eir - anything EIR specific will build Covax app /engine |--- /register |--- /report |--- /task |--- /search

Explanation This implementation is part of the mADX project that aims at generating measure reports for set predefined indicators. The set of patients are primarily ANC clients, the set of observations and details taken are collected in the course of different ANC encounters. The measures for reporting are tracked against a set of several observations collected over time and tracked for various ANC Indicators.

Thus, patients will be accessed via the ANC app and then those being tracked for measure reporting can be selected and evaluate operation run against the patient resource together with with the referenced resources i.e. Library resource with CQL expressions and the value set bundles etc.

Acceptance Criteria

f-odhiambo commented 3 years ago

@kimigxfoxy The sample app has since been updated with some new changes and the ability to generate measure reports check it out https://github.com/DBCG/CqlEvaluatorSampleApp We may need to upgrade part of the previous work done Also there us a new very loaded bundle here

f-odhiambo commented 3 years ago

Some additional notes

Understanding the Library logic vs the measure logic

The Library has the actual CQL embedded, while the Measure is a higher-level construct that gives the elements of the CQL meaning within the context of a quality measure. Figure 3-1 at the link here illustrates the relationship: https://build.fhir.org/ig/HL7/cqf-measures/measure-conformance.html#population-criteria

The Parameters resources is the return type defined for the $evaluate operation for Libraries. It roughly corresponds to key-value pairs for the CQL expressions that are embedded: http://build.fhir.org/ig/HL7/cqf-recommendations/OperationDefinition-cpg-library-evaluate.html What you do with the Parameters resources is context-dependent. In the case of a Measure, the values in the Parameters would map to population criteria. In the context of clinical decision support, it might map to a CDS-hooks card. If you were building a questionnaire app you might show the results to a user. In other words, it's a relatively low-level operation that can be reused under the covers in many different ways. It might be something that's not exposed at all within the Android SDK, depending on the specific requirements. In the demo app, we merely needed it as a first step towards Measure evaluation.

f-odhiambo commented 3 years ago

Some updates

  1. @RaaziaTarique to share with @kimigxfoxy the Patient profile XML
  2. @kimigxfoxy TODO
  • [x] On select, Patient mom on the ANC Client list, go to the patient profile
  • [x] Populate details on Patient Moms profile i.e Name, Age, Patient ID from Patient FHIR resource
  • [x] You can add a label and button just under the CarePlan section
  • [ ] On click evaluate, go to evaluation screen you could use a white background similar to app theme and not dark background
RaaziaTarique commented 3 years ago

@kimigxfoxy shared ANC details xml with you. Please check slack.

kimigxfoxy commented 3 years ago

@f-odhiambo I am waiting for this PR to be approved https://github.com/opensrp/fhircore/pull/515 so that I can pull develop and merge to my branch and the button from there. @RaaziaTarique Thanks

kimigxfoxy commented 3 years ago

@f-odhiambo Test patient with anemia https://fhir.labs.smartregister.org/fhir/Patient/1744/$everything. (We will substitute the ID with the patient loaded) Value set for patient with anemia: https://fhir.labs.smartregister.org/fhir/ValueSet?_id=1750,1751 Library ANCRecommendationA2,FHIRHelpers: https://fhir.labs.smartregister.org/fhir/Library?_id=1752,1753

f-odhiambo commented 2 years ago

Part of the integration to ANC for this POC missing @kimigxfoxy to integrate into a new PR - Access the evaluation from an ANC patient profile page

cc @kimigxfoxy

kimigxfoxy commented 2 years ago
  1. Library evaluator class merged using PR https://github.com/opensrp/fhircore/pull/557
  2. The next step is adding information to ANC details fragment