Skip to content

Instantly share code, notes, and snippets.

@mtuchi
Last active February 5, 2024 12:56
Show Gist options
  • Save mtuchi/f6502ded29bcd6702e58df82a38b0995 to your computer and use it in GitHub Desktop.
Save mtuchi/f6502ded29bcd6702e58df82a38b0995 to your computer and use it in GitHub Desktop.
Day 1 homework

Challenge

Your organization is collecting patient data in a custom EMR application.

Your government partner wants you to start sending newly registered patient records from your EMR to its national DHIS2 system on a weekly basis.

You’ve been asked to design a workflow to:

  • extract data from your app (which has a REST API that returns data in JSON)
  • map the data elements to the DHIS2 data model, and
  • sync patient records as “Tracked Entity Instance” records to DHIS2

Request

Job 1: Get users from this endpoint https://jsonplaceholder.typicode.com/users

Job 2: For each user, create 1 tracked entity instance in DHIS2.Note that for orgUnit you will have to dynamically fill in the orgUnit. See the Globals: orgUnit sheet for the mapping table for how to re-assign cities and orgUnits.

See mapping spec here and sample output linked below

State

Job 1: Sample Users Data http adaptor

Job 2: Use the following to access via the web UI. Not sure that URL is required for the API. (Note this is DHIS2 dev) https://play.im.dhis2.org/dev/ (UN: admin, PW: district

See the latest DHIS2 Adaptor docs here: https://docs.openfn.org/adaptors/packages/dhis2-docs

Output

I think this is what the final DHIS2 payload needs to look like: DHIS2 Sample Payload

FYI - To create tracked entity instance, using the lates version of language-dhis2

create("trackedEntityInstances", {
  orgUnit: "TSyzvBiovKh",
  trackedEntityType: "nEenWmSyUEp",
  attributes: [
    {
      attribute: "w75KJ2mc4zz",
      value: "Gigiwe",
    },
  ],
});

see here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment