Please change the logic to check ALL service items in the services_section array for this criteria.
Note that some cases may have an empty services_section[...] and some cases may only have 1 service that matches this criteria. Only if service_implementing_agency_individual === 'unhcr_cw', should we consider this service a "referral" to send to UNHCR. We can discard all services that do not match this criteria.
See this sample case returned by Primero. It has 2 services... 1 service that matches this criteria, 1 that doesn't (no service_implementing_agency_individual exists)... so I'd expect only 1 referral to be sent to DTP/
Request
Currently we check if the first service has
service_implementing_agency_individual === 'unhcr_cw'
. https://github.com/OpenFn/primero-progres/blob/9803138de5de47809f2904320a474ece8aed2f87/jobs/2.a.getCases.js#L11-L12Please change the logic to check ALL service items in the
services_section
array for this criteria.Note that some cases may have an empty
services_section[...]
and some cases may only have 1 service that matches this criteria. Only ifservice_implementing_agency_individual === 'unhcr_cw'
, should we consider this service a "referral" to send to UNHCR. We can discard all services that do not match this criteria.Remember 1 Primero
service_section
item = 1 DTPreferral
.expression
https://github.com/OpenFn/primero-progres/blob/master/jobs/2.a.getCases.js
state
See LP for Primero Dadaab. This job
2-1
(https://openfn.org/projects/p5am6e/jobs/jv7rnp) will trigger job2-2
to send the referral to DTP: https://openfn.org/projects/p5am6e/jobs/jydbjqTo test
See this sample case returned by Primero. It has 2 services... 1 service that matches this criteria, 1 that doesn't (no
service_implementing_agency_individual
exists)... so I'd expect only 1 referral to be sent to DTP/Please run this on prod to make sure this works: https://openfn.org/projects/p5am6e/jobs/jv7rnp