Using a Fresh Database
Purpose and Benefits
Bahmni comes with an out-of-the-box demo database. However, after installing Bahmni, one might test the system by doing some data entry. This would create some transactional data about Patients, Visits, Encounters, Observations, Orders, etc. Creating a fresh database helps in removing such transactional data so that the database (with proper Metadata setup) can be used in other deployments. This Documentation will help you setting up the basic vanilla database with minimum data to access all the modules in Bahmni.
Steps
- Drop existing openmrs database.
mysql -uroot -ppassword -e "drop database openmrs"For more information please refer to this Bahmni talk thread: https://talk.openmrs.org/t/install-bahmni-0-89-to-have-fresh-database/11451/16
1. Install Bahmni for Vanilla OpenMRS DB
- To get a fresh Bahmni database, you need to install Bahmni, by setting the implementation name (implementation_name in setup.yml) as anything BESIDES "default". For instance, you may call it: "myhospital".
- Copy the required config folder from here to /etc/bahmni-installer/deployment-artifacts.
- As per Bahmni's installation process, if a database is unavailable during the deployment, it would restore a base vanilla database based on latest Bahmni version if the implementation_name is NOT chosen as default.
- Run the bahmni install command.
2. Setup appropriate Metadata for Bahmni
Bahmni requires some minimal metadata to be setup, before it can be used. The metadata needed is:
- Location (Mandatory - at least one location should be present)
- Visit Types (Mandatory - at least one visit type should be present)
- "superman" user (Mandatory - a user who has all the privileges and would act as a super user.
Import the SQL Script
- Download the sql file from here. This is just a sample file. This sql file will add a single location, visit type, superman provider for your reference. One can change the sql file with their sample data and import.
- Run the below command from the command prompt to import sql file.
Please choose the fresh-db-v082.sql file for Bahmni v0.82, fresh-db-v083.sql for Bahmni v0.83 and up and fresh-db-v086.sql for Bahmni v0.86 and up
mysql -uopenmrs-user -ppassword openmrs < fresh-db-v086.sql
Deleting patient data from database
In order to delete patient data from the database and clean up all the corresponding transactional data, one has to follow these steps.
Steps to Delete all the patient data from the database
- Set Environment Variables
Set the following environment variables based on the requirement.
| Variable | Explanation |
|---|---|
| OPENMRS_DB_USER | User name of Openmrs Database |
| OPENELIS_DB_USER | User name of Openelis Database |
| OPENERP_DB_USER | User name of Openerp Database |
| INVENTORY_FILE | Name of the Inventory File |
Follow the below example commands to set the environment variables
export OPENMRS_DB_USER=openmrs-user
export OPENELIS_DB_USER=clinlims
export OPENERP_DB_USER=openerp
export INVENTORY_FILE=local- Download the script
Download the delete patient data script from the github. Use the below command to download
wget https://raw.githubusercontent.com/Bahmni/bahmni-scripts/master/deletePatientData/0.91/deletePatientData.shwget https://raw.githubusercontent.com/Bahmni/bahmni-scripts/master/deletePatientData/0.92/deletePatientData.shwget https://raw.githubusercontent.com/Bahmni/bahmni-scripts/master/deletePatientData/deletePatientData.sh- Run the script
Execute the script from the folder it is downloaded. Use the below command to run the script.
sh deletePatientData.shBahmni Wiki · CC BY-SA 4.0