OpenFn / unicef-cambodia

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

f2-j2: upload to Primero fails because of age range validation error #77

Closed aleksa-krolls closed 3 years ago

aleksa-krolls commented 3 years ago

Issue

In this "f2" flow, we get case data from OSCaR and upload to Primero. This recent run failed on prod because the calculated age was not within the range of 0 and 130: https://www.openfn.org/projects/pdngk6/runs/r89r3g3e

This could have been because we received a bad quality date value for date_of_birth or because the validation was only recently added. https://github.com/OpenFn/unicef-cambodia/blob/07a7a1330709e85e0f37082a70deb66a37a68198/jobs/f2-j2-upsertCasesToPrimero.js#L352-L361

Please modify this age calculation logic to return 0 as a default value if age > 30 || age < 1 || date_of_birth === undefined.

adaptor

UPDATE: Note that this is Primero v1 so use language-primero@v1.2.0

expression

Flow job triggered by f2-j1... https://github.com/OpenFn/unicef-cambodia/blob/master/jobs/f2-j2-upsertCasesToPrimero.js

state

Please be careful to only use these credentials for testing... f2-j1 to get data: Oscar Staging API user f2-j2 to upload to primero: Primero Alpha Cambodia - Staging API user

See here for f2-j1 state ... this is sample output.json from f2-j1 that you can use as state for f2-j2. https://github.com/OpenFn/unicef-cambodia/blob/master/sample_data/sample-f2-j1-output.json NOTE that this state includes 3 cases: 1 with valid date_of_birth, 1 with very old out of range dob, and 1 with null dob.

aleksa-krolls commented 3 years ago

@lakhassane please prioritize this today, and lmk if any questions!

lakhassane commented 3 years ago

@aleksa-krolls I added the conditions to return 0 on dob.

aleksa-krolls commented 3 years ago

@lakhassane looks like it's working now, thanks!