Closed aleksa-krolls closed 4 years ago
Output from Primero f1-j1 ...
{
"references": [
{}
],
"data": [
{
"owned_by": "primero",
"owned_by_agency": "agency-unicef",
"module_id": "primeromodule-cp",
"created_at": "2020/03/30 00:00:00 +0000",
"case_id_display": "d275a05",
"name_first": "ange",
"name_last": "nahir",
"sex": "male",
"date_of_birth": "2015/06/03",
"oscar_number": "89507076",
"mosvy_number": "305889865",
"location_current": "12110417",
"protection_status": "migrant_child_13820",
"services_section": [
{
"unique_id": "12345ee2-f45e-1510-9b8f-3ad23590fd7c",
"service_response_type": "referral_to_oscar",
"service_type": "counselling",
"service_type_text": "Counselling",
"service_type_details_text": "deFamily counselling / mediation",
"oscar_case_worker_name": "deN5555ame OSCaR case worker",
"oscar_case_worker_telephone": "012553456789",
"service_implemented": "not_implemented"
}
],
"transitions": [
{
"unique_id": "b92ccbac8-aecc-1510-0c2a-ed0f656abc58",
"type": "referral",
"notes": "this is a new referal for ange",
"transitioned_by": "primero",
"service": "counselling",
"service_section_unique_id": "12345ee2-f45e-1510-9b8f-3ad23590fd7c",
"created_at": "2020/03/30",
"id": "5330478e-dffc-4f68-89ff-682504c37e41"
}
],
"_id": "778d3e7d8512f37ed5751ecb949da56b",
"case_id": "67f2adb5-dcdb-1804-1510-c4e28d275a05"
}
],
"configuration": {
"url": "https://cpims-kh-alpha.primero.org",
"user": "xxx",
"password": "xxx",
"inboxUuid": "xxx"
}
}
reference second reference.
@taylordowns2000 This is still not resolved. With this current job version, we are posting the below output to Oscar. See f1-j2 run failure here (line 25). Returns 422 error - I think because of our request body.
I think we need to remove "data":{}
from the request body. See here for Oscar API docs.
When I test locally, the below is my output.json
when running f1-j2-casesToOscar.js
. See the state.json
I used when copying from f1-j1 output.
{
"configuration": {
"baseUrl": "http://start.oscarhq-staging.com",
"username": "api.user@example.com",
"password": "pwd"
},
"data": {
"references": [
{}
],
"data": [
{
"owned_by": "primero",
"owned_by_agency": "agency-unicef",
"module_id": "primeromodule-cp",
"created_at": "2020/03/30 00:00:00 +0000",
"case_id_display": "d275a05",
"name_first": "ange",
"name_last": "nahir",
"sex": "male",
"date_of_birth": "2015/06/03",
"oscar_number": "89507076",
"mosvy_number": "305889865",
"location_current": "12110417",
"protection_status": "migrant_child_13820",
"services_section": [
{
"unique_id": "12345ee2-f45e-1510-9b8f-3ad23590fd7c",
"service_response_type": "referral_to_oscar",
"service_type": "counselling",
"service_type_text": "Counselling",
"service_type_details_text": "deFamily counselling / mediation",
"oscar_case_worker_name": "deN5555ame OSCaR case worker",
"oscar_case_worker_telephone": "012553456789",
"service_implemented": "not_implemented"
}
],
"transitions": [
{
"unique_id": "b92ccbac8-aecc-1510-0c2a-ed0f656abc58",
"type": "referral",
"notes": "this is a new referal for ange",
"transitioned_by": "primero",
"service": "counselling",
"service_section_unique_id": "12345ee2-f45e-1510-9b8f-3ad23590fd7c",
"created_at": "2020/03/30",
"id": "5330478e-dffc-4f68-89ff-682504c37e41"
}
],
"_id": "778d3e7d8512f37ed5751ecb949da56b",
"case_id": "67f2adb5-dcdb-1804-1510-c4e28d275a05"
}
]
}
}
https://github.com/OpenFn/unicef-cambodia/blob/38c481aa36bacb62d428619a3d6c03405b362ccd/jobs/f1-j2-casesToOscar.js#L40
See run failure here.
Looks like it's failing because
references[]
is returning null even though we apparently received 1 case from Primero... did something change with the data structure here?And what is the flow if we receive 0 cases from Primero? Do we need to work in validation at the start of this job to abort if no new data? I'd like any logs to be user-friendly if in our control.