OpenFn/unicef-cambodia

Add service_response_type mapping

aleksa-krolls opened this issue · 2 comments

Request

In Primero, update the service_response_type to 'service_being_provided_by_oscar_partner_47618' if Oscar provides a service enrollment date. Otherwise return 'referral_from_oscar' for any services where enrollment_date is not specified.

service_response_type: s.enrollment_date ? 'service_being_provided_by_oscar_partner_47618 ' : 'referral_from_oscar'

state

See LP for UNICEF Primero Alpha API.
See sample_data/oscarNewReferral.json.

"services": [
{
"enrollment_date": "2020-11-20",
"uuid": "042ffb1c-51de-404b-b69b-fdb9e15c9d36",
"name": "Generalist social work / case work"
},
{
"enrollment_date": "2020-11-20",
"uuid": "155c6b46-ac10-4226-b9fd-6e117111b08c",
"name": "Emergency foster care"
},
{
"enrollment_date": "2020-11-20",
"uuid": "7b97ef20-4c25-4d83-b2cb-60efc1ba300f",
"name": "Support to access care"
},
{
"enrollment_date": null,
"uuid": "37cd9808-c417-4a19-9563-36ac7865e2f8",
"name": "Trauma counselling"
}

expression

This should be mapped to the service-level in Primero... every service has 1 service_response_type

services_section:
convert(c.services).map(s => ({
...s,
//service_referral_notes: c.reason_for_referral, //mapping notes to case-level
})),

output

The last service in this sample state has no enrollment_date (see L45 --> therefore this service should return service_response_type: 'referral_from_oscar'.

The other 3 services should return service_response_type: 'service_being_provided_by_oscar_partner_47618'.

Tested with empty services array, and with no services key at all.

@taylordowns2000 so far working great, thank you! keep you posted with final round of testing next week.