Flush test data from Bahmni/opeMRS

Is there an easy way to flush patient, provider and location and related records testfrom the Vagrant Box version?

Please BACKUP your database before you perform these steps, so that if you are unhappy with the results, you can restore it back and re-try.

See this documentation: https://bahmni.atlassian.net/wiki/display/BAH/Using+a+Fresh+Database#UsingaFreshDatabase-Deletingpatientdatafromdatabase

Once again thanks for you very prompt reply.

Things were going fine until the delete script asked for a password in med-stream - see an extract from the script output below. I guess this might be the database root password - I tried blank and the super user password from openMRS unfortunately both failed. Can you advise?

–2017-04-02 16:55:11-- https://raw.githubusercontent.com/Bahmni/bahmni-scripts/master/deletePatientData/deletePatientDataForOpenMRS.sql Resolving raw.githubusercontent.com… 151.101.0.133, 151.101.192.133, 151.101.64.133, … Connecting to raw.githubusercontent.com|151.101.0.133|:443… connected. HTTP request sent, awaiting response… 200 OK Length: 1933 (1.9K) [text/plain] Saving to: “deletePatientDataForOpenMRS.sql”

100%[==============================================================================================================================>] 1,933 --.-K/s in 0s

2017-04-02 16:55:14 (24.1 MB/s) - “deletePatientDataForOpenMRS.sql” saved [1933/1933]

deleting openmrs patient data Enter password: ERROR 1045 (28000): Access denied for user ‘openmrs-user’@‘localhost’ (using password: NO) Failed to delete the openmrs patient data deleting the existing file downloading openelis delete patient data sql file –2017-04-02 16:57:19-- https://raw.githubusercontent.com/Bahmni/bahmni-scripts/master/deletePatientData/deletePatientDataForOpenElis.sql Resolving raw.githubusercontent.com… 151.101.0.133, 151.101.192.133, 151.101.64.133, … Connecting to raw.githubusercontent.com|151.101.0.133|:443… connected. HTTP request sent, awaiting response… 200 OK Length: 879 [text/plain] Saving to: “deletePatientDataForOpenElis.sql”

100%[==============================================================================================================================>] 879 --.-K/s in 0s

Hi @mafrica,

Yes, We should enter the database credentials here. The username/password combination for openmrs database is openmrs-user/password. Try running the deletePatientData.sh with the above credentials once. Please check this wiki page for more info on connecting to various databases in Bahmni.

I am afraid the credentials from the wiki page do not seem to work and I have not knowingly (in fact I don’t think I know how) changed them. Is it possible that the credentials in the distribution have changed?

You can maybe check if you changed the credentials in setup.yml https://bahmni.atlassian.net/wiki/display/BAH/List+Of+Configurable+Installation+Variables

Use the commands mentioned in this page to check if the credentials are correct https://bahmni.atlassian.net/wiki/display/BAH/Connecting+to+various+databases

Once you have verified the creds, then only run the script.

Thanks I tracked the password down at

https://bahmni.atlassian.net/wiki/display/BAH/Connecting+to+various+databases

However it seems that although the patient data is removed much of the other data remains including location and the associated geographical references (addresses?).

If we endeavour to add our hospital location and its various departments we are told that village is mandatory and the drop downs of state/province etc are all drawn from your demo data.

Worryingly is we choose one of these villages to create a location then we are still told a village is required even having supplied an erroneous one.

I some other posts I note that a full installation has the option to start with an empty or demo db. Are we breaking new ground in starting with the virtual box that is prepopulated with the demo data with no empty db option?

Virtual box is not for productional use case. This is just a handy way of getting Bahmni up and running. For example, if some one wants to try installing Bahmni and play around with it without worrying about the installation, then this pre-populated virtual box is useful and this is the main aim of this pre populated box. For all the other use cases where the demo data is not required, it is always recommended to start fresh which comes with fresh and clean database without any demo (patient + meta) data. In this case, one need not worry about deleting the existing data because this way of installation doesn’t have any transactional and meta data… one has to setup every thing from scratch.

Here it means when we are working on the virtual box and shutdown its virtual machine. All the databases completely vanished off. Then what is the cause for it. Can you tell me please.

Thanks for that. However, as I pointed out in another thread Using the Bahmni Vagrant Box for a Low (IT) Resource Health Centre we are (for better or worse) using a windows server 2016 while your base configuration assumes Centos and so virtual box gives us the possibility of treating the app as an appliance and hence reducing the amount IT resources we need to dedicate both now and in the long term. In the other thread I was told that we are not alone in this and there is another instance of virtual box running in production where I guess this issue was solved.

I would be interested to know how?

Perhaps a better solution to this is to offer those that wish to have a virtual box implementation the choice of downloading either a demo db virtual box or or one with an empty db as with the Centos world?

You should be able to replace the current DB in the Virtual Box with a fresh database. I will request someone to make the fresh DB available to you.

You can also just trigger Bahmni installation in the Virtual Box – and get an updated Bahmni, or fresh database via that process. https://bahmni.atlassian.net/wiki/display/BAH/Using+a+Fresh+Database

But for now, will try and get you a fresh DB via a direct download. Give us some time.

I am very grateful, Thank you.

To help my work planning, could you give me a rough idea of when this might be available. No commitments just your best guess…

In two days likely.

Hi @mafrica, You can download the openmrs clean db dump from here. Please run the below commands to restore the database once you download.

gzip -d openmrs_backup.sql.gz mysql -uroot -ppassword -e "drop database openmrs" mysql -uroot -ppassword -e "create database openmrs" mysql -uroot -ppassword openmrs < openmrs_backup.sql

This is clean database and it doesn’t any concepts, locations , address heirarchy and many more so that you can start from scratch. As @gsluthra mentioned I will share the OpenELIS and OpenERP clean databases in couple of days. Meanwhile you can start configuring openmrs database.

As ever many thanks. Not yet sure of all the consequences of not having concepts or address hierarchy but I am sure I will know soon.

Sorry for my ignorance but having a little trouble here.

I have a windows host:

In the bahmni-vagrant directory at the command line I gzip the .gz successfully. I then vagrant ssh and: mysql -uroot -ppassword -c drop database openmrs create database openmrs

All apparently successfully. However when I come to load the backup it sits in windows file space and cannot be found by mysql in the guest. I read that vagrant should sync the folder containing vagrantfile (and now also the unzipped backup) with the guest /vagrant folder. However /vagrant is empty.

Can you advise?

Hi @mafrica, You can directly download the file using wget in guest machine ( Bahmni server ) and run the above mentioned restore commands.

wget https://github.com/Bahmni/bahmni-scripts/raw/master/FreshDb/v0.86/openmrs_backup.sql.gz

All done, thanks. The wget nicely got over my problem of shifting the file into the guest.