OpenFn / unicef-cambodia

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

Update `referal_status` mapping in f1-j2-casesToOscar #94

Closed daissatou2 closed 2 years ago

daissatou2 commented 2 years ago

Feature Request

Background, context, and business value

As discussed, update the f1-j2-casesToOscar job to send Primero decisions to the /api/v1/organizations/clients/upsert/ instead of the /api/v1/organizations/clients/update_links/ endpoint. Follow the steps below:

  1. Add both 'referral_to_oscar' and 'referral_from_oscar' cases to the referrals array here.
  2. In the mapping section for the /api/v1/organizations/clients/upsert/ operation, add one more mapping for the referral_status Oscar field as follows:

if we get services_section[*].referral_status_5fe9c1a = 'accepted_270501' from Primero, send referral_status = 'Accepted' to Oscar if we get services_section[*].referral_status_5fe9c1a = 'rejected_412652' from Primero, send referral_status = 'Exited' to Oscar

NOTE: The mapping for referral_status should only happen if it is a "referral_from_oscar". If it is a "referral_to_oscar", do not map the referral_status field.

state.json

Primero (to generate state):

{ "configuration": "Primero V2 Cambodia Demo API user", "data": "Data will be generated from this job, Sample getCases response" }

Oscar:

{ "configuration": "Oscar Staging (api only user)", "data": "Run F1-J1 to generate state" }

expression.js

f1-j2-casesToOscar

daissatou2 commented 2 years ago

@lakhassane please push these changes but hold off on testing until our Primero access if restored.

daissatou2 commented 2 years ago

@grayey as discussed, the referral_status mapping is incorrectly being added to the services section of the data we are sending to Oscar. It should instead be on the case-level...so outside of services. Like this:

image

This is the run in question: https://openfn.org/projects/primero-oscar-cambodia-io-staging/runs/062288eb-7766-7229-94d8-92926162d3cd. Please use the case with "global_id": "01FXQ6GQGA36FMX3YAA620RCRK" when testing.

daissatou2 commented 2 years ago

@grayey here's new data you can work with: https://openfn.org/projects/primero-oscar-cambodia-io-staging/runs/0622a23e-7c91-7969-8ed9-f4fe94f9f174 "case_id" = "53e0897c-cb06-49f4-b50f-ec8b3cf6600e"

daissatou2 commented 2 years ago

As discussed, in this run: https://openfn.org/projects/primero-oscar-cambodia-io-staging/runs/0622b354-b46b-7bf7-9284-a88ec7a5655d line 79 we see "referral_status_5fe9c1a": "rejected_412652", for what we received from Primero but in line 154 we are sending "referral_status": "Accepted", to Oscar

we should be sending "referral_status": "Exited"

daissatou2 commented 2 years ago

Hello @grayey how is this coming along? Any updates?