Restoring deleted program registrations

Hi all, we’ve accidentally had someone delete a program registration using the Delete button for the active program in Bahmni.


I looked through Bahmni and through the OpenMRS settings to see if there was a way to restore the deleted program. I was not able to find anything. Am I just not looking in the right place, or is there no option in the Bahmni or OpenMRS UI to restore a deleted program registration?

If there is no option in the UI, would the following sql be sufficient to restore the program registration? Or are there other tables and columns that would also need to be updated?

update patient_program set voided = 0 WHERE patient_program_id = 1234;
update patient_program set voided_by = NULL WHERE patient_program_id  = 1234;
update patient_program set date_voided = NULL WHERE patient_program_id = 1234;

I also noticed that when the program registration is deleted the obs in the obs table that are associated with that program registration are not voided. I wonder if this is desirable or whether it would be better to void the data associated with the program registration when the registration is deleted. Or perhaps to check whether there is data in the program when a user opts to delete and either give a warning or give the option to void or keep the associated data.

Keeping the data is helpful in that if restoring a program registration you don’t also need to unvoid all of the obs (and risk unvoiding some that are actually meant to be voided). But the downside I can see is that the obs won’t be ignored in sql queries (eg reports, patient queues) unless these are joined to the patient_program_id table and a WHERE clause is used to check that patient_program_id.voided = 0