Skip to content

Instantly share code, notes, and snippets.

@aleksa-krolls
Last active March 30, 2023 07:49
Show Gist options
  • Save aleksa-krolls/9ef6835ec096c8b2b083d2384cf37530 to your computer and use it in GitHub Desktop.
Save aleksa-krolls/9ef6835ec096c8b2b083d2384cf37530 to your computer and use it in GitHub Desktop.
This is the payload OpenFn sends to Oscar API for an existing client `yoaz-2258`. See below for the output in Oscar (with dupe services).
[
{
"organization": {
"external_id": "86f084b7-6cfc-40f7-abf9-2a8b6f35dbf3",
"external_id_display": "f35dbf3",
"global_id": "01GWRMBDA85FY15JR6EE7XG99Y",
"level_of_risk": "no action",
"mosvy_number": "",
"given_name": "Ryan",
"family_name": "Reynolds",
"gender": "male",
"date_of_birth": "2018-01-01",
"location_current_village_code": "02070103",
"address_current_village_code": "02070103",
"reason_for_referral": "ref 4-1",
"external_case_worker_name": "openfn",
"external_case_worker_id": "",
"external_case_worker_mobile": "000000000",
"resource": "Primero",
"is_referred": true,
"organization_name": "cif",
"organization_id": "cif",
"services": [
{
"uuid": "7e04a877-29d5-4154-8226-bb54b382efd9",
"name": "Kinship care"
}
],
"date_of_referral": "2023-03-30"
}
},
{
"organization": {
"external_id": "86f084b7-6cfc-40f7-abf9-2a8b6f35dbf3",
"external_id_display": "f35dbf3",
"global_id": "01GWRMBDA85FY15JR6EE7XG99Y",
"level_of_risk": "no action",
"mosvy_number": "",
"given_name": "Ryan",
"family_name": "Reynolds",
"gender": "male",
"date_of_birth": "2018-01-01",
"location_current_village_code": "02070103",
"address_current_village_code": "02070103",
"reason_for_referral": "ref 4-1",
"external_case_worker_name": "openfn",
"external_case_worker_id": "",
"external_case_worker_mobile": "000000000",
"resource": "Primero",
"is_referred": true,
"organization_name": "cif",
"organization_id": "cif",
"services": [
{
"uuid": "5925f7ff-a082-4633-b138-83faaccd061a",
"name": "Family reunification"
}
],
"date_of_referral": "2023-03-30"
}
}
]
@aleksa-krolls
Copy link
Author

aleksa-krolls commented Mar 30, 2023

If the above^ payload is sent via POST request to OSCaR API '/api/v1/organizations/clients/upsert/' multiple times, then:

  • it looks like the Oscar client is being upserted ✅
  • but the services are NOT upserted (even though the service uuid is provided) ❌

Rather, the services (with the same uuids) are being duplicated - see below payload.

Output in Oscar

{
        "given_name": "Ryan",
        "family_name": "Reynolds",
        "local_given_name": "",
        "local_family_name": "",
        "gender": "male",
        "date_of_birth": "2018-01-01",
        "global_id": "01GWRMBDA85FY15JR6EE7XG99Y",
        "slug": "yoaz-2258",
        "external_id": "86f084b7-6cfc-40f7-abf9-2a8b6f35dbf3",
        "external_id_display": "f35dbf3",
        "status": "Accepted",
        "mosvy_number": "",
        "location_current_village_code": "02070103",
        "case_worker_name": "ជិន ស្រឡឹង",
        "case_worker_mobile": "0969331660",
        "is_referred": true,
        "organization_name": "cif",
        "organization_address_code": "120611",
        "resource": "primero",
        "services": [
          {
            "program_name": null,
            "enrollment_date": null,
            "uuid": "1804d3de-d1d8-4647-8968-68d4985e2a1e",
            "name": "Kinship care",
            "referral_id": 5109,
            "referral_status": "Referred"
          },
          {
            "program_name": null,
            "enrollment_date": null,
            "uuid": "3777bc02-dd93-4e6e-a206-8ca200d60131",
            "name": "Family reunification",
            "referral_id": 5110,
            "referral_status": "Referred"
          },
          {
            "program_name": null,
            "enrollment_date": null,
            "uuid": "1804d3de-d1d8-4647-8968-68d4985e2a1e",
            "name": "Kinship care",
            "referral_id": 5108,
            "referral_status": "Accepted"
          },
          {
            "program_name": null,
            "enrollment_date": null,
            "uuid": "1804d3de-d1d8-4647-8968-68d4985e2a1e",
            "name": "Kinship care",
            "referral_id": 5113,
            "referral_status": "Referred"
          },
          {
            "program_name": null,
            "enrollment_date": null,
            "uuid": "3777bc02-dd93-4e6e-a206-8ca200d60131",
            "name": "Family reunification",
            "referral_id": 5114,
            "referral_status": "Referred"
          }
        ]
      }
    

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment