Skip to content

Instantly share code, notes, and snippets.

Challenge

Your organization is collecting immunization data in a custom health information system (HIS) built on PostgreSQL.

Your government partner wants you to start sending weekly, aggregate reports to Salesforce 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 Salesforce data model, and
  3. upsert vera__Indicator_Result__c records in Salesforce in order to update linked indicator reports

Challenge

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

To enable program monitoring and enhanced reporting, your M&E team wants you to start sending newly registered patient records from your EMR to its global M&E system built on Salesforce 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 Salesforce data model, and
  • sync patient records as vera__Beneficiary__c records in Salesforce
// Log size of initial state
fn(state => {
const { data, year } = state;
console.log(
`Initial state for Job 3 contains ${data.results.length} aggregate records`,
`from SLUHIS for ${year}.`
);
return state;
});
@aleksa-krolls
aleksa-krolls / primeroReferralsToOscar.json
Last active March 30, 2023 07:49
This is the payload OpenFn sends to Oscar API for an existing client `yoaz-2258`. See below for the output in Oscar (with dupe services).
[
{
"organization": {
"external_id": "86f084b7-6cfc-40f7-abf9-2a8b6f35dbf3",
"external_id_display": "f35dbf3",
"global_id": "01GWRMBDA85FY15JR6EE7XG99Y",
"level_of_risk": "no action",
"mosvy_number": "",
"given_name": "Ryan",
"family_name": "Reynolds",
{
"given_name": "មិនា",
"family_name": "សេង",
"local_given_name": "",
"local_family_name": "",
"gender": "male",
"date_of_birth": "2008-11-30",
"global_id": "01GWK7GMM2SD0WD5S9DB0J80FF",
"slug": "lept-2248",
"external_id": "2581f89b-c4b9-42e2-99c3-3e24e16ab4c9",

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
[
{
"id": 1,
"name": "Leanne Graham",
"username": "Bret",
"email": "Sincere@april.biz",
"address": {
"street": "Kulas Light",
"suite": "Apt. 556",
"city": "Gwenborough",
{
"organization": {
"external_id": "6f49e00d-da5d-49a4-8b41-af40451fe53d",
"external_id_display": "51fe53d",
"level_of_risk": "high",
"mosvy_number": "",
"given_name": "Primero",
"family_name": "l2",
"gender": "female",
"date_of_birth": "2013-01-01",
@aleksa-krolls
aleksa-krolls / ref2services_beforeSplitting.json
Created October 17, 2022 21:11
How the referral looks when extracted from Primero. OSCaR team requested to only send 1 Service per referral, so we will later split this into 2 payloads.
{
"organization": {
"external_id": "1a20d411-efda-4ad5-82f5-53b891f96ca8",
"external_id_display": "1f96ca8",
"level_of_risk": "medium",
"mosvy_number": "",
"given_name": "two",
"family_name": "referrals",
"gender": "female",
"date_of_birth": "2013-01-01",
@aleksa-krolls
aleksa-krolls / refToOscar_2nd_withError.json
Created October 17, 2022 21:06
fails with 422 error: data: '{"external_id":"1a20d411-efda-4ad5-82f5-53b891f96ca8","message":"Record was found.","errors":{"global_id":"global_id must exist.","referral_status":"referral_status must be present."}}'
{
"organization": {
"external_id": "1a20d411-efda-4ad5-82f5-53b891f96ca8",
"external_id_display": "1f96ca8",
"level_of_risk": "medium",
"mosvy_number": "",
"given_name": "two",
"family_name": "referrals",
"gender": "female",
"date_of_birth": "2013-01-01",