OpenFn / unicef-cambodia

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

f2-j2-upsertCasesToPrimero job failing to sync Oscar decisions to Primero #113

Closed daissatou2 closed 2 years ago

daissatou2 commented 2 years ago

Bug Report

Describe the bug

We are seeing a green check for a run with an error message for the f2-j2-upsertCasesToPrimero job. Error message: (node:2256147) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'uuid' of undefined

In the run above, we were testing syncing the Oscar decision for case where "external_id": "39051cfc-a2fe-4f97-8323-e7c52a07441a" to Primero. According to line 358 of the log, it looks like the job successfully finds the matching referral that should be updated with the decision but does not actually update the case.

Note: this test scenario passed when we last tested 3 weeks ago.

To Reproduce

Run f2-j1 after clearing the state (I have updated the manual cursor). In the response received from Oscar, use the case where "external_id": "39051cfc-a2fe-4f97-8323-e7c52a07441a", as initial state for f2-j2.

state.json

Primero: Oscar (to generate state):

{ "configuration": "Oscar Staging (api only user)", }

{ "configuration": "Primero V2 Cambodia Demo (openfn_cp_user)", "data": "Run F2-J1 to generate state" }

expression

Please only modify jobs in the V2 folder! https://github.com/OpenFn/unicef-cambodia/blob/master/jobs/V2/f2-j2-upsertCasesToPrimero.js

This is a staging environment, so feel free to run repeated tests locally.

adaptor

language-primero@2.7.0

aleksa-krolls commented 2 years ago

@taylordowns2000 this is priority this week. Pls check out the full run log error... at a glance, I wonder if this is actually adaptor related. Do you have time today or tomorrow to take a look?

@daissatou2 is available for pairing, as needed, so keep her posted.

taylordowns2000 commented 2 years ago

@daissatou2 , adding a comment here for posterity! this is ready for your and @aleksa-krolls 's review/discussion.

aleksa-krolls commented 2 years ago

In sum, the change implemented here was to make sure that cases had a referral service where enrollment_date === null, before classifying this service as a "decision". This is because all services sent from Primero to Oscar do not have enrollment_date. Only Oscar program services (not referrals) do have enrollment_date.

Related slack thread: https://openfn.slack.com/archives/C017ELVRSM8/p1653927956063479?thread_ts=1653911584.650449&cid=C017ELVRSM8