OpenFn / primero-progres

Interoperability solution for UNICEF <> UNHCR interagency referrals between Primero and Progres v4 systems.
https://openfn.github.io/primero-progres/
0 stars 2 forks source link

Flow1 referrals to Primero: updated mapping logic #11

Closed aleksa-krolls closed 3 years ago

aleksa-krolls commented 3 years ago

Background, context, and business value

See issue #3 for the original specs, and see issue #8 where similar mappings were implemented for services, protection concerns, and languages. I tried to borrow this logic from 2.b.uploadReferrals.js and implement these transformations in this job... but not successful.

The specific request, in as few words as possible

Check the job for the TODO comments, which include:

  1. service_type - please use the serviceMap in the job to output the correct service value based on the value data.progres_interventiontype2. Output should be a string value.
  2. protection_concerns - please use the protectionMap in the job to output the correct service value based on the value data.specificneeds.progres_spncategory2.Id. Output should be an array of strings, even if there's only 1 value.
  3. languages - please use the languageMap in the job to output the correct service value based on the value data.languages.progres_languagecodeid.Name.
  4. address_current - please return a concatenated comma-separated string of the values data.individuals.progres_coalocationlevel1.Name, level2, level3, level4, level5 + data.individuals.progres_coalocationlevel6

state.json

Use this and pls run on prod to make sure it works: https://www.openfn.org/projects/p5am6e/messages/mgk5er9q

adaptor

primero

used on production -example: {form: "form-name"}

expression.js

https://github.com/OpenFn/primero-progres/blob/master/jobs/1.upsertExtracts.js

output.json

Successfully upsert this new referral to Primero with all fields mapped.

lakhassane commented 3 years ago

@aleksa-krolls is the sample data correct? e.g for service type I see this in the data "progres_interventiontype2": "a8b00885-b3c3-e611-xxxx-xxxxxxx", but the mapping object you used (serviceMap) looks like this

const serviceMap = {
      alternative_care: 'BIA', //TESTING: DO NOT USE
      security: 'Protection',
      education: 'Education',

    };

So this instruction serviceMap[data.progres_interventiontype2] will never map

lakhassane commented 3 years ago

Or eventually are those the right mapping objects you need?

lakhassane commented 3 years ago

@aleksa-krolls I checked the TODOs with the sample data. Note that I still doubt about the mapping objects but I left a note on how they should be formatted on Line 14.

aleksa-krolls commented 3 years ago

@lakhassane Quick feedback on item 3. If the progres languages.progres_languagecodeid.Name listed in state is not in the languageMap, please return the value other. https://github.com/OpenFn/primero-progres/blob/master/jobs/1.upsertExtracts.js#L98 Here's the sample state again: https://www.openfn.org/projects/p5am6e/messages/mgk5er9q

lakhassane commented 3 years ago

@aleksa-krolls ready for testing