How to start with a fresh / clean database for Bahmni?

Hello guys, Trying to get a fresh db but i am unable to connect to openERP db…

username and password not validated

@puneet1984 Please refer to this document on connecting to databases:

Hi Vsingh, I’m trying to clean all patient data of my Bahmni installation, and this is what I have now:

I couldn’t run the deletePatientData.rb because I couldn’t install pg gem. It was an ruby version isue, I tryed to upgrade ruby but now it can’t find the path to ruby (I’m not too good about ruby :blush:)

Then I went for executing the sql scripts and the deletePatientDataForOpenMRS.sql worked like a charm! All my patients are gone.

But when executing the deletePatientDataForOpenElis.sql it didn’t work. It finished with the following errors messages:

Output from uploaded SQL commands …

psql:/tmp/.webmin/664285_425_1_exec_file.cgi:31: ERROR: relation “result_signature” does not exist psql:/tmp/.webmin/664285_425_1_exec_file.cgi:33: ERROR: relation “person” does not exist LINE 1: delete from person where not exists (select p.person_id from… ^ psql:/tmp/.webmin/664285_425_1_exec_file.cgi:35: ERROR: relation “event_records_offset_marker” does not exist

Can you help me with some instructions on how to solve this?



Hi German Acevedo,

According to the output you pasted, looks like you don’t have proper OpenElis database. How did you install Bahmni ? Is OpenElis up and running in your system ? Can you check if table “result_signature” and “person” exists in your database.

Thanks, Sravanthi

Here is a link explaining how to connect to OpenELIS database. Maybe the script is connecting with a user that doesn’t have rights to see the tables. Please check.

Hi Sravanthi, I installed Bahmni following the instructions on The install ended without any errors, and OpenElis, Bahmni, OpenMRS and OpenERP are all working fine. In my server I have webmin as control panel, and I log into it as root. This are screenshots of what I see about the requested tables:

As Gurpreet already mentioned, Can you please try using “clinlims” user.

german2209, just to clarify you are passing the .sql script to postgres, correct? openElis uses postgres, not mysql.

btw, which ruby version does the “deletePatientData.rb” script require? I tried with ruby 1.8.7 on CentOS 6 but it doesn’t work (sintax error).

Hi Sravanthi, I tryed again with user clinlims, this time through phpPgAdmin, but again it didn’t worked, this is the result after running the deletePatientDataForOpenElis.sql:

Error de SQL:

ERROR: syntax error at or near “table” LINE 1: SELECT COUNT(*) AS total FROM (truncate table result_signatu… ^

En la declaración:

SELECT COUNT(*) AS total FROM (truncate table result_signature, referral_result, referral, result_inventory, result, worksheet_analyte, note, report_external_export, report_external_import, analysis_qaevent, analysis_storages, analysis_users, analysis, sample_qaevent, sample_requester, sample_human, sample_newborn, sample_animal, sample_environmental, sample_item, sample_organization, sample_projects, sample, observation_history, patient, patient_identity, patient_occupation, person_address, patient_patient_type, patient_relations, organization_contact;

delete from person where not exists (select p.person_id from provider p where p.person_id =;

truncate table event_records_offset_marker) AS sub

Hi Nostalgicamigo, yes I’m using phpPgAdmin to run the script.

Hi German Acevedo,

Can you try the below command from command prompt to delete the data from OpenElis. It worked for me.

psql -Uclinlims clinlims < deletePatientDataForOpenElis.sql

Make sure you have the deletePatientDataForOpenElis.sql file in the folder where you are executing the command.

Hello I am able to clear openMRS and openERP data … but i am unable to reset the registration counter… Please suggest what to do…need to fix it urgently

To reset the Patient ID counter, please refer to this document:

Guys, there’s a BIG issue that starts to happen when the script to remove the demo data is used: the results of an Order (input through OpenELIS) are not view-able anymore on the patient dashboard in Bahmni. The orders are there, but not the results values, even though they’re validated in OpenELIS.

Does it happen to you guys too? Try to make an Order for any patient, go to OpenELIS, collect, give results & validate it, and then see if those results show in the patient dashboard.

(I opened a discussion here: )

Reiterating on this topic… We have improved the fresh installation of bahmni. Also we are now providing a script to delete all the patient or transactional data that is packaged with the default instance of bahmni.

Need Metadata from Demo Instance but not Patient Data During installation if the implementation_name is not overridden, it will be set to “default”. Which means default_config of bahmni and default demo database will be installed. this database will be a replica of demo database. So to delete the patient data and other related data like observations, orders etc… One can use the script mentioned in the documentation following the instructions pointed in the same page. This will keep the meta data and delete all the transactional data. Please refer the instructions mentioned in our documentation

To start fresh with clean database (without patients and metadata aswell),

  1. During installation, override the value of implementation_name with value other than default. Lets say xyz (in /etc/bahmni_installer/setup.yml)

  2. Put the xyz_config in /etc/bahmni_installer/deployment_artifacts/ (xyz_config is the config folder (name should match the implementation_name in step 1) with the structure similar to )

  3. Run the installation command. (bahmni -i {inventory_file} install) Refer documentation for installation

This will install bahmni with fresh databases without any patient or meta data. You have to manually choose to import or add the data from scratch.

We are in the process of making this better and easier. We will update the documentation soon… :slight_smile:

Does the openmrs_clean_dump.sql still need to be executed manually or is it part of the installation process? Thanks.

Installation will take care unless you have dump file that has to be used during the installation.

How to specify my database in installation configuration?

Any clue how to do this for a Vagrant box install?

If you are using v0.93 vagrant, you can drop the DB in the vagrant, and restore a Fresh DB of OpenMRS from here: bahmni-package/bahmni-emr/resources at master · Bahmni/bahmni-package · GitHub (file: openmrs_clean_dump.sql)

For OpenELIS clean DB is here: bahmni-package/ at master · Bahmni/bahmni-package · GitHub

For Odoo clean DB is here: bahmni-package/bahmni-erp/resources at master · Bahmni/bahmni-package · GitHub

Since all 3 DBs are interconnected, you would need to refresh them all together. If things go in some wonky state, you can always destroy your vagrant box, and bring it up again, and it should be back up with the orginal vagrant pre-loaded db.