This nodejs application merges two instances of OpenMRS 2.x databases into one. It works by connecting to the two databases and copy data from designated source database into designated destination database. Once run successfully, the designated destination database will be a merger of the two initial instances.
Note:
Below is the list of tables whose records are copied.
person
person_attribute_type
person_attribute
person_name
person_address
relationship_type
relationship
patient
patient_identifier_type
patient_identifier
users
role
role_role
privilege
role_privilege
user_role
location
provider
provider_attribute_type
provider_attribute
visit
visit_type
encounter
encounter_role
encounter_provider
obs
program
program_workflow
program_workflow_state
patient_state
GAAC module tables
Clone the code from github.
$ git clone https://github.com/mhawila/beehive.git
Change into the project directory, and create a JSON configuration file called config.json putting the following content.
{
"source": {
"host": "mysql source host or IP",
"username": "username",
"password": "secret",
"openmrsDb": "openmrs1",
"location": "unique string to identify location" //Must be provided.
},
"destination": {
"host": "mysql destination host or IP",
"username": "username",
"password": "secret",
"openmrsDb": "openmrs2"
},
"batchSize": 16000,
"debug": false
}
Note: Substitute the given values with appropriate values.
Once the configuration file is in place, Install the required dependencies:
$ npm install
Run the application
$ node --harmony orchestrator.js
Running without committing changes to the database (Dry running)
$ node --harmony orchestrator.js --dry-run
The application includes a verification process that is run separately once the merging has been completed. Currently the tables being verified are person, person_attribute, person_name, person_address, relationship, patient_identifier, visit, encounter, provider, program_workflow, patient_state, obs, gaac, gaac_member. Also currently this feature is supported on database running on the same instance of MySQL. In order to run this process, run the following command on terminal.
$ node verify-merge.js