OpenFn / openfn-lime-pilot

MSF LIME Project - OpenFn Workflows for Iraq Pilot
1 stars 0 forks source link

wf2 - New form & more mappings #19

Closed aleksa-krolls closed 2 months ago

aleksa-krolls commented 2 months ago

Background, context, and business value

Ref #2 for the original WF2 specs., and ref #12 for how we implemented logic to handle multiple forms.

The specific request, in as few words as possible

Given the new MHPSS Followup form and extended mappings for mhGAP Baseline form, we need to make to make the following changes... please branch off of staging

3-get-encoutners

We have a new MHPSS Followup form to map, so add the uuid: be8c12f9-e6fd-369a-9bc7-46a191866f15

Remember: There will be other encounters belonging to other form uuids. Discard these encounters --> we only want to hold onto the encounters for the forms in our list.

4-get-options-map

We need to add more mappings for (1) mhGAP Baseline form, and (2) new form MHPSS Followup. See updated mapping spec.

  1. Add mappings for mhGAP Baseline form to the mappings list in state.mhgapMap
  2. Add NEW mappings state.mhpssFollowupMap for the new form MHPSS Followup

Note on custom transformations & refactoring the logic

The PHQ9 Score question has custom transformation logic, for which I drafted a function for - see getRangePhq(). Please

  1. Review/update this function to align with best practices, as you see fit
  2. Consider if we should refactor this if statement code block to better handle custom transformations. https://github.com/OpenFn/openfn-lime-pilot/blob/staging/workflows/wf2/6-create-events.js#L30-L62

6-create-events

Now that we're mapping 3 forms/encoutners, we need to insert 3 different types of events. (And remember, eventually there will be up to 6 types of forms/events.). Each event type will have (1) its own programStage and (2) different mappings for dataValues (bc each event has a different set of questions).

Here is the mapping for the NEW MHPSS Followup event

{
      program: 'w9MSPn5oSqp', //same
      orgUnit: 'OPjuJMZFLop', //same
      programStage: 'eUCtSH80vMe', //mhpss followup*
      trackedEntityInstance: TEIs[data.patient.uuid],
      eventDate: encounterDate,
      dataValues //mapped using state.mhpssFollowMap
 }

API Documentation

Input

Credentials

Data

Run wf2-1 with cursor {"manualCursor": "2024-09-16T10:00:00.00"}

Output

If OMRS returns X patients, then X number of patients should be upserted in DHIS2. For each Patient, we will query for Encounters and then filter by form.uuid. If Z Encounters are returned, then Z Events should be created in DHIS2.

Testing guidance

Run wf2-1 with cursor {"manualCursor": "2024-09-16T10:00:00.00"} to find patients where these new forms have been filled out.

Katrina Dima is an example OMRS patient who should be returned and has all 3 forms (MHPSS Baseline, MHPSS Followup, and mhGAP Baseline) completed. http://msf-ocg-openmrs3-dev.westeurope.cloudapp.azure.com/openmrs/spa/patient/9ef373a2-3267-4171-89ce-5b5dd0da0b3c/chart/Patient%20Summary

Toggl

MSF 2024

mtuchi commented 2 months ago

Good progress on the mapping of mhpssFollowup form, See WIP #23

mtuchi commented 2 months ago

EOD Update I have fix merge conflicts and rebase latest changes from staging. But i have commented out the create() operation. @aleksa-krolls let's sync tomorrow to test this