OpenFn / primero-progres

Interoperability solution for UNICEF <> UNHCR interagency referrals between Primero and Progres v4 systems.
https://openfn.github.io/primero-progres/
0 stars 2 forks source link

Check if each location exists, concatenate address #13

Closed aleksa-krolls closed 2 years ago

aleksa-krolls commented 3 years ago

Request

Progres will sometimes send us up to 6 locationlevel fields that when combined, complete a full address_current. However, sometimes all 6 location fields are not available... we therefore need to check if each locationlevel (address1, address2, etc) exist... and if yes, concatenate them with a space.

I implemented this change so far... but it returns too many extra spaces when one of these addresses is not defined. https://github.com/OpenFn/primero-progres/blob/ddbba293135151a1c130036aaa598fe68f963a0e/jobs/1.upsertExtracts.js#L410

See this run for example L30 has lots of extra spaces.

Ideally it will output as: address_current: 'Garissa Block A LOCATION LEVEL 6', where there is only 1 space between each available address.

state

See LP for Dadaab open_function user. Feel free to re-run this on prod: https://www.openfn.org/projects/p5am6e/messages/mqp9zdeg

expression

https://github.com/OpenFn/primero-progres/blob/master/jobs/1.upsertExtracts.js