Skip to content

Instantly share code, notes, and snippets.

@aleksa-krolls
Last active March 14, 2023 12:26
Show Gist options
  • Save aleksa-krolls/b7f240213d733c05d83e7bf13eb8e7e3 to your computer and use it in GitHub Desktop.
Save aleksa-krolls/b7f240213d733c05d83e7bf13eb8e7e3 to your computer and use it in GitHub Desktop.

Challenge

Your organization is collecting immunization data in a custom HIS built on PostgreSQL.

Your government partner wants you to start sending weekly, aggregate reports to DHIS2 on immunization key indicator results. To do this, you need to automatically calculate indicator values based on the individual data collected in the HIS.

You’ve been asked to design a workflow to:

  1. extract data from your HIS (you've been given direct DB access)
  2. automatically calculate indicator results & map the data elements to the DHIS2 data model, and
  3. create dataValue records in DHIS2 in order to update related indicator reports

Request

  • Job 1: Get rows from the DB table patient
  • Job 2: Calculate the # of OPV doses given across all patients. Reported on the calculated sum value to DHIS2 as a new dataValueSet.

See Day 2 mapping spec here and sample output linked below.

homework-2-diagram

State

Job 1: postgresql DB

  • Configuration: See slide 52 from training

Job 2: DHIS app

  • Configuration: See slide 52 from training

See the latest Adaptor docs here: https://docs.openfn.org/adaptors/

Output

See example JSON output from DHIS2 API documentation

FYI - To create dataValueSets, using the latest version of language-dhis2 See job example:

create('dataValueSets', {
  dataSet: 'pBOMPrpg1QX',
  completeDate: '2014-02-03',
  period: '201401',
  orgUnit: 'DiszpKrYNg8',
  dataValues: [
    {
      dataElement: 'f7n9E0hX8qk', //dataElement you are reporting on
      value: '1', //value to dynamically return based on calculations
    }
  ],
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment