OpenFn / unicef-cambodia

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

f1-j2: Change criteria for when `is_referred` is true before upload to Oscar #58

Closed aleksa-krolls closed 3 years ago

aleksa-krolls commented 3 years ago

Background

Currently the job will only mark the case as a referral if the case originates in Primero. However, cases might originate in Oscar and be shared with Primero (Oscar case --> Primero case), and then individual services can be shared back from Primero to Oscar (Primero referral service --> Oscar case).

Change Request

Modify the mapping on L302 in f1-j2-casesToOscar.js to check if the Primero case contains services where "service_response_type": "referral_to_oscar". Only if Primero services contains this value, then should we mark Oscar is_referred as true. https://github.com/OpenFn/unicef-cambodia/blob/1ef487b2cd411b2a0ae68a2d1ac7386ce1187534/jobs/f1-j2-casesToOscar.js#L203

expression.js

f1-j2-casesToOscar.js using language-http

state.json

This state has 3 cases where I expect the following...

  1. case 31de2d0 with services that have referrals --> should send case where is_referred: true to Oscar
  2. case 2e3732f with NO services --> should send case where is_referred: false to Oscar
  3. case cedb069 with services but NO referrals --> should send case where is_referred: false to Oscar
aleksa-krolls commented 3 years ago

Logic flow...

  1. Does service_section exist?
  2. If yes, iterate over services_section. Do any of the services contain "service_response_type": "referral_to_oscar"?
  3. If yes, is_referred: true. Otherwise set to false.