Help on Data Exchange JSON Payload to include Category options, and combinations

Hello, Help the structure of the JSON payload in the data exchange that also include data elements with category options, and combination. I am stuck on the element of categories. Thank you

Hi @BernardMasache

I understand you are using a GET request GET /api/aggregateDataExchanges/{id}?

Could you share an API example request that is working and the one that is not working? It would be great if the example is from any of the play.dhis2.org instances so we could work on it together and see how to fix it.

Thanks!

1 Like

Let me share the experience using POSTMAN.

In the

"dx": [
          "MAL_ADMIT_0_4",
          "MAL_ADMIT_5_14",
          "MAL_ADMIT_15",
          "MAL_CASES_0_4"
        ]

These are data elements codes, indicators works too. Only category combinations brings an issue because the same category is used in multiple data elements so the code or id or the category option can not be used as UID for the data source.

I can suggest a remedy only i dont know the implementation of how the request body from the payload sent via the postman is processed. i could recommend the same way how dataValues are sent in the dataset as shown from the block of code taken from dhis2 developer manual.

{
  "dataSet": "dataSetID",
  "completeDate": "date",
  "period": "period",
  "orgUnit": "orgUnitID",
  "attributeOptionCombo": "aocID",
  "dataValues": [
    {
      "dataElement": "dataElementID",
      "categoryOptionComboIdOrCode": "cocID",
      "value": "1",
      "comment": "comment1"
    },
  ]
}

Unless there is a workaround, i can propose the following layout in the "dx" where the data element has category option combination

"dx": [
          "MAL_ADMIT_0_4",
          "MAL_ADMIT_5_14",
          "dataElementIdOrCode":[{
                   categoryOptionCombo: 'MAL_ADMIT_5_14'
                }],
          "MAL_CASES_0_4"
        ]

because it will generate "dataElementIdOrCode.categoryOptionComboIdOrCode" data source reference.

Thank you Addin, for your response.

1 Like

@BernardMasache Try this


where dx includes DEUID.COCUID

1 Like