Using a Fresh Database

This document will help you setup a fresh / vanilla Bahmni database. This document is still a work in progress, and more updates will happen to it. Please post your questions on this to OpenMRS Talk.

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


Note

This Vanilla OpenMRS DB installation works on fresh CentOS Box. If you already have Bahmni installed on one of CentOS Machine or Virtual Box/Vagrant and planning to have Vanilla OpenMRS DB please follow below steps before starting "Install Bahmni for Vanilla OpenMRS DB"

  • Remove openmrs, bahmni-emr, bahmni-web modules.
yum remove bahmni-openmrs bahmni-emr bahmni-web
  • 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.

One way to setup relevant metadata is via importing sql script once the Bahmni installation is done

Import the SQL Script

  • Download the sql file from hereThis 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.

    mysql -uopenmrs-user -ppassword openmrs < fresh-db-v086.sql

    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

OpenERP doesn't come with Bahmni modules installed. Please refer to OpenERP Basic Configuration wiki page to install relevant Bahmni Modules in ERP. With the above Vanilla Database setup, One can use the Bahmni from scratch without any transactional data like Patients, Visits, Encounters, Observations, Orders, etc. You can choose to snapshot this database, and restore it again whenever you need, instead of doing these steps again.

Odoo database (0.92)

Bahmni 0.92, does not come with a preconfigured base database for Odoo 10. The bare minimum database that is initialized, has only a default company (My Company), an admin user and basic configuration (like INR for currency with default implementation, EURO for non-default implementation)


Please refer EMR Security and Access Control (OpenMRS) to understand more about Roles and Privileges for Bahmni Use

Adding privileges can also be performed through OpenMRS UI EMR Security and Access Control (OpenMRS)


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.

This script will delete all the patient data from EMR, ERP and ELIS!


Please take backup of all the databases openerp, clinlims and openmrs.


Steps to Delete all the patient data from the database

  • Set Environment Variables

Set the following environment variables based on the requirement. 
 

VariableExplanation

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_FILEName of the Inventory File

Follow the below example commands to set the environment variables

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

If one has their own inventory file configured other than default file local then one can set environment variable with their file name

Example: INVENTORY_FILE = inventory_file_name (name of the file)

If any of the environment variable is not set, then the corresponding database patient data will not be deleted. For instance, if one chooses not to delete openerp patient data then one should not set the variable OPENERP_DB_USER

  • Download the script

Download the delete patient data script from the github. Use the below command to download

Script for deleting patient data (v0.91)
wget https://raw.githubusercontent.com/Bahmni/bahmni-scripts/master/deletePatientData/0.91/deletePatientData.sh
Script for deleting patient data (v0.92)
wget https://raw.githubusercontent.com/Bahmni/bahmni-scripts/master/deletePatientData/0.92/deletePatientData.sh


  • Run the script

Execute the script from the folder it is downloaded. Use the below command to run the script.

Run the script
sh deletePatientData.sh

How the script works

Running the script will download deletedPatientDataForOpenMRS.sql, deletePatientDataForOpenERP.sql and deletePatientDataForOpenElis.sql files.
Depending on the  environment variables set the corresponding sql files will be executed. For instance, only OPENMRS_DB_USER is the only variable set then only openmrs patient data will be deleted.