OpenFn / unicef-cambodia

UNICEF Cambodia - Primero Interoperability
https://openfn.github.io/unicef-cambodia/
1 stars 2 forks source link

New Oscar changes: job updates needed to successfully upload to Primero #53

Closed aleksa-krolls closed 3 years ago

aleksa-krolls commented 4 years ago

Mapping updates

Background, context, and business value

This issue is related to Flow 2 of the integration (Oscar cases --> Primero). When OpenFn sends GET requests to the Oscar /clients endpoint, Oscar API previously always with the exact same payload - no matter the case type. Now Kiry implemented a change so that Oscar API will now send fewer fields in its response to any GET request for cases without referrals. The mapping rules shouldn't change, we just now have fewer data points to map to Primero.

The flow should be unaffected for where cases do have referrals/ services.

The specific request, in as few words as possible

Please update the job f2-j2-upsertCasesToPrimero.js to handle the full-length response from Oscar when cases do have referrals, as well as the smaller smaller payload it will now send for cases without referrals.

Here are the mappings. Only change is the owned_by mapping.

state.json

See sample_data/getOscarNew.json for the new response when f2-j1 is run. See L125 for a case with referral & services. See L201 for a case without referrals.

Creds see LP for "Oscar Staging API User" and "UNICEF Primero Alpha API User Login".

adaptor

f2-j1 uses language-http to communicate with Oscar f2-j2 uses language-primero to communicate with Primero

output.json

Successful upsert of cases to Primero. See here for the project documentation and links to mapping specifications.

aleksa-krolls commented 3 years ago

@taylordowns2000 Two feedback items from testing...

  1. It does not look like all Oscar cases are being upserted in Primero. See this run and search for Id 01EK26WFB9JEY92TAWC4JMRDHJ. I can see in the logs that we received this case from Oscar, but I don't see in the logs where we try to upsert in Primero, and I can't find the case Primero-side.
  2. Also why does the WARNING appear in the logs when there is a location_current_village_code present?
    
    Data provided by Oscar (ON: 01EK26WFB9JEY92TAWC4JMRDHJ / extId: ) : {
    "oscar_short_id": "xcqr-1792",
    "external_id": "",
    "external_id_display": "",
    "global_id": "01EK26WFB9JEY92TAWC4JMRDHJ",
    "is_referred": false,
    "location_current_village_code": "02120202",
    "mosvy_number": "",
    "organization_name": "cif",
    "services": []
    }
    WARNING: Invalid Oscar location_current_village_code or address_current_village_code
    ``