How can I delete all demo patients?

I need to delete some locations used in many encounters with demo patients. Is there a way to delete all the demo patients so I can delete those locations?

Thank you

What about SQL Delete based on their IDs. Something as follows may be help. But please makesure that you are executing them against the correct table.

Ex : To delete patients delete from patient where patient_id > [sample_patient_start] and patient_id <= [sample_patient_end]

Hope it helps!

I won’t recommending firing delete statements for patients… since patient data may also be referenced by other entities in DB. Maybe there is a delete patient API in OpenMRS, or some “supported” script for deleting patients?

1 Like

Yes. That is true. You have to be careful with the relationships between the database relations. But the best way is to findout whether there are any API s or scripts provided as @gsluthra has suggested. Will try to find some.

I was able to delete all demo patents. Here are the queries I used: NB: make sure you first stop openmrs or tomcat before proceeding. Also ensure you make a copy of your database first before proceeding.

1 Like

its to delete demo patients delete from patient where patient_id>[sample_patient_start] and patient_id <=[sample_patient_end] i hope it will help you .