Multiple "default" Category Option Combos
Sometimes there are users that import metadata from older DHIS2 versions prior to the standardization of “default” metadata’s UIDs. Things can get pretty tricky in that scenario. For this Guide, we’re looking at multiple default COCs. See below:
What is a “default”?
From the docs:
In early versions of DHIS2, the UID of the default data dimension was auto-generated. Thus while all DHIS2 instances have a default category option, data element category, category combination and category option combination, the UIDs of these defaults can be different. Later versions of DHIS2 have hardcoded UIDs for the default dimension, and these UIDs are used in the configuration packages.
In the category structure of DHIS2 - category options, categories, category combos, category option combos - everything has a “default” metadata object. When data is entered to using the “default” that is representative as “none”.
So What?
It is important to understand that this is bad. It can end up that data values from across different data sets can end up being associated to different “default” COCs which ends up as having false dimensions for data that should have “none” or no dimension!
What to do
Since DHIS2 doesn’t handle deduplication of default COCs, it’s basic assumption is that it will never have more than one.
In order to figure out how bad the problem is, the first step is a grouping of data value count per default COC to get a sense on the severity.
Using SQL we can use this query to get a count of data values associated with each COC.
--Count of Data Values Per Category Option Combo
SELECT COUNT(*) AS dv_count, coc.uid AS coc_uid
FROM categoryoptioncombo coc
INNER JOIN datavalue dv ON coc.categoryoptioncomboid = dv.categoryoptioncomboid
WHERE coc.name = 'default'
GROUP BY coc.uid
ORDER BY dv_count DESC;
With this knowledge, you can then begin to sort out how severe the problem has become. With a perfect outcome, all data values should be associated to a single default category option combo.