Handling duplicate Category Option Combos
Sometimes it is necessary to manually update Category Option Combos. A cause, steps to reproduce, or a Jira bug with details is still needed to pinpoint an actual “error” why this happens.
We have identified three options:
COC generation via DHIS2 Data Admin Maintenance has been troubling implementations in the past, especially with regards to COC duplicates. As you know there is no management interface for this generation. In order to prevent duplicates in the past we have a few options here.
A). Try to selectively update the COCs per a specific CatCombo (e.g. with Postman other REST client):
curl -X POST 'https://server.com/api/maintenance/categoryOptionComboUpdate/categoryCombo/CC_uid' -u user:password
B). Do not rely on the Maintenance API, and Insert the COCs manually as metadata. In fact, this is what larger implementations do as it allows greater control in what COCs are available. An example structure of 1 COC is here: https://server.com/api/categoryOptionCombos/HYoye8kacPf?fields=:owner. This probably requires some tool development.
C). Invest in finding the root cause to submit a DHIS2 bug report. For that we would require 5-10 hours to investigate closely: first we would need the exact metadata, or steps, that lead to the duplication. Then we would load a backup locally pre-duplicate (downloaded from BAO Manager). We would then enable query logging to inspect the database-level queries made when the "Update category option combinations" task is triggered, as a first step in the investigations on why these duplicates appear. The goal would be to submit a bug report for a future version.
Some general tips :
- Identify which of the duplicate COCs are actually linked to the category combo on the data sets (warning different data sets may have different COC duplicates on each!)
- Select one of the COCs from 1 as the 'true' COC
- Move data via SQL from all the duplicate COCs to the 'true' COC
- Delete the other COCs
You can see what duplicate COCs exist with an SQL View:
SELECT name, COUNT(name) from categoryoptioncombo GROUP BY name ORDER BY COUNT(name) DESC;
But not all duplicates are problems so be wary of this! For example if you have two cat combos,
- Age & Sex
- Age & Sex (unknown age)
These will have a lot of overlapping COCs, in fact all the COCs in 1. will exist in 2. So be very careful when moving or deleting data from duplicate COCs that they are not valid for a different category combo!