OpenFn / unicef-cambodia

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

transitions.service always outputs "Other" & service uuid missing #26

Closed aleksa-krolls closed 4 years ago

aleksa-krolls commented 4 years ago

https://github.com/OpenFn/unicef-cambodia/blob/2f3323820985fd29a7b4838e3af2b2689fe04570/jobs/f2-j2-upsertCasesToPrimero.js#L342

For every service, we create 1 transition in Primero ( 1:1 relationship). There are 2 issues with how we're uploading transitions in the Oscar --> Primero data flow. See this run log as an example.

1.transitions.service always outputs "Other", when it should match the service_type.

"services_section": [
    {
      "service_subtype": [
        "mental_health_support_therapeutic_interventions"
      ],
      "service_type": "mental_health_support",
      "service_type_text": "mental_health_support",
      "service_type_details_text": "n/a"
    }
 ],
   "transitions": [
    {
      "service": "Other", //should output "mental_health_support"
      "type": "referral"
    },

2. L341: service_section_unique_id is missing from the payload when we upload transitions. It looks like this is maybe because Oscar is not sending us the service uuid in its response to our GET request, but can you please confirm? (see L51-63 in example run)


"transitions": [
    {
      "service_section_unique_id": t.unique_id,  // this output is missing in run logs
      "service": "Other",
      "type": "referral"

    },
taylordowns2000 commented 4 years ago

Confirmed. I've added a console.log so you can see what Oscar provides: https://www.openfn.org/projects/1671/runs/8995516

{
  "address_current_village_code": "20030901",
  "case_worker_mobile": "comma sep phone numbers",
  "case_worker_name": "str, str, str, str",
  "date_of_birth": "2018-10-16",
  "external_case_worker_id": null,
  "external_case_worker_name": null,
  "external_id": null,
  "external_id_display": null,
  "family_name": "shhhhhhhhhhhhhh",
  "gender": "male",
  "given_name": "shhhhhhhhhhhhhh",
  "global_id": "shhhhhhhhhhhhhh",
  "is_referred": true,
  "location_current_village_code": "20030901",
  "mosvy_number": null,
  "organization_id": 46,
  "organization_name": "cif",
  "protection_status": "",
  "reason_for_referral": "",
  "referral_consent_form": [
    "https://cif-web-assets-staging.s3.amazonaws.com/uploads/referral/consent_form/35/screencapture-coderthemes-hyper-creative-dashboard-crm-html-2020-05-26-23_58_54.png"
  ],
  "services": [
    {
      "id": 27,
      "name": "Therapeutic interventions"
    },
    {
      "id": 30,
      "name": "Disability-aid provision"
    },
    {
      "id": 5,
      "name": "Emergency foster care"
    }
  ],
  "status": "Active"
}