Best practice for modifying a DHIS 2 component

Hi All,

If we find that an option in an option set is wrong/incorrect, but data has already been entered, and we need to modify it, what are the best practices (necessary steps)? Would there be any problem with the database? . We have also seen that even if we can modify the name of the option, the code is disabled.

Thanks

1 Like

Hi @hernandezmachava

Good question! Up to this point, I believe the best practice is not to modify it since it already have data connected to it. Instead, I think it’s better to create a new option set and use it instead. For the older data, you’ll need to export, clean the data by fixing the incorrect option then import back into the new option set.

I hope this helps because I think it’s taking the safe side. :slight_smile:

Thanks!

The reason that the code is disabled via the user interface is because the actual data values are saved with the option’s code. Let’s say that you have been recording data with an option called “RED” and you decide to change the option value to “Red”. DHIS2 will consider these to be different options, and this will cause problems with analysis. Thus, via the user interface at least, the option code cannot be changed.

If you really need to change the option value, then you are going to have to find all of the data which has used this option value (i.e. the code) and update that data. There is no API to do this, so you will need to write your own SQL script to manipulate the data in the database. As always, you should do this in a testing environment and be sure that it works before modifying your production system.

Good luck and best regards,
Jason

1 Like

Once faced the same issue, what I did was to export the the options in an optionSet, change the code in Json file and push the file back in dhis2. After that I downloaded all the events referencing the option and change it to the new code and push all the events back. However important considerations before doing the procedure:

  1. All users to sync their data on their device
  2. Stop data entry or prevent people from capturing data (stop the instance etc)
  3. Do the changes
  4. Start the instance and ask every TO SYNC NEW CONFIGURATIONS BEFORE CAPTURING ANY DATA (IF USERS DON’T SYNC NEW SETTINGS THEY FACE SYNC ERRORS REFERENCING AN OPTION CODE NOLONGER EXISTING)

Though I don’t recommend the process due to many processes involved and in many cases its not possible to stop data entry

1 Like