OpenFn / unicef-cambodia

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

Update f2-j2 logs to show case payload received & transformed #38

Closed aleksa-krolls closed 4 years ago

aleksa-krolls commented 4 years ago

Re: f2-j2-upsertCasesToPrimero.js https://github.com/OpenFn/unicef-cambodia/blob/b84d3f883a54a21b03d29a04a3612b13749f827b/jobs/f2-j2-upsertCasesToPrimero.js#L308-L314

(1) Log Oscar response: Please update the logs to show the following where NO identifying child information or service details (beyond uuids) are included. See pseudo code below...

Data provided by Oscar (ON: c.global_id / extId: c.external_id ) : {
  "address_current_village_code": c.address_current_village_code",
  "external_case_worker_id": c.external_case_worker_id,
  "external_case_worker_name": c.external_case_worker_name,
  "external_id": c.external_id,
  "external_id_display": c.external_id_display,
  "global_id": c.global_id,
  "is_referred": c.is_referred,
  "location_current_village_code": c.location_current_village_code,
  "mosvy_number": c.mosvy_number,
  "organization_id": c.organization_id,
  "organization_name": c.organization_name,
  "services": [
    {
      "uuid": service.uuid
    },
    {
      "uuid": service.uuid
    }
  ],
  "status": c.status
}

Example log output:

Data provided by Oscar (ON: 01EC0XW85GEFC7SJNVDP3SWW0N / extId: 17bce806-1118-4ebb-b01e-f4923a2ab922) : {
  "address_current_village_code": "",
  "external_case_worker_id": "",
  "external_case_worker_name": "agency-cif-user",
  "external_id": "17bce806-1118-4ebb-b01e-f4923a2ab922",
  "external_id_display": "a2ab922",
  "global_id": "01EC0XW85GEFC7SJNVDP3SWW0N",
  "is_referred": true,
  "location_current_village_code": "",
  "mosvy_number": "4444",
  "organization_id": 46,
  "organization_name": "cif",
  "services": [
    {
      "uuid": "827ba321-5ed9-49ce-8494-b70993934733"
    },
    {
      "uuid": "8982daae-2349-4a3b-a0ad-5b0a9560e227"
    }
  ],
  "status": "Active"
}

(2) Log transformed data posted to Primero: Follow the same rules to not show any identifying child information or service details sent to Primero. See below for pseudo code.

Data provided to Primero `upsertCase`:  {
  "remote": true,
  "oscar_number": c.oscar_number,
  "case_id": c.case_id,
  "child": {
    "case_id": c.case_id,
    "oscar_number": c.oscar_number,
    "mosvy_number": c.mosvy_number,
    "location_current": c.location_current,
    "address_current": c.address_current,
    "oscar_status": c.oscar_status,
    "owned_by": c.owned_by,
    "has_referral": c.has_referral,
    "consent_for_services": c.consent_for_services,
    "disclosure_other_orgs": c.consent_for_services,
    "module_id": c.module_id,
    "registration_date": c.registration_date,
    "services_section": [
      {
        "unique_id": s.unique_id,
        "oscar_case_worker_name": c.oscar_case_worker_name,
        "oscar_referring_organization": c.oscar_referring_organization,
        "oscar_case_worker_telephone": c.oscar_case_worker_telephone
      }
    ],
    "transitions": [
      {
        "service_section_unique_id": s.unique_id,
        "created_at": c.created_at,
        "type": c.type
      }
    ]
  }
}

Example log output for upsert to Primero:

Data provided to Primero `upsertCase`:  {
  "remote": true,
  "oscar_number": "01E7JGRAZ9ZT8108SM662PXJT7",
  "case_id": null,
  "child": {
    "case_id": "",
    "oscar_number": "01E7JGRAZ9ZT8108SM662PXJT7",
    "mosvy_number": "",
    "location_current": "4060607",
    "address_current": "04060607",
    "oscar_status": "Active",
    "owned_by": "agency-cif-user",
    "has_referral": true,
    "consent_for_services": true,
    "disclosure_other_orgs": true,
    "module_id": "primeromodule-cp",
    "registration_date": "2020/07/13",
    "services_section": [
      {
        "unique_id": "11226c6d-d7b8-4272-b45e-85cf635b9fba",
        "oscar_case_worker_name": "Janani Panchalingam",
        "oscar_referring_organization": "agency-cif",
        "oscar_case_worker_telephone": "8765432"
      }
    ],
    "transitions": [
      {
        "service_section_unique_id": "11226c6d-d7b8-4272-b45e-85cf635b9fba",
        "created_at": "2020/07/13",
        "type": "referral"
      }
    ]
  }
}
taylordowns2000 commented 4 years ago

To discuss: where do we need to build from scratch (safer, harder to maintain) and where can we use existing objects or object.delete to strip sensitive keys?