This nodejs application merges two instances of OpenMRS databases into one. It works by connecting to the two databases and move 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:
- If you still want the original copy of the destination database, then you have to create a copy before running this application on it.
- The assumption is made that the two OpenMRS instances share the same metadata (i.e. concepts, forms e.t.c).
- For the purpose of this implementation, some of the tables are purposely ignored (See below for the list of tables included)
Below is the list of tables whose records are moved.
-
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
- nodejs 7+
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,
"generateNewUuids": true, //Must be provided.
"debug": false
}
- batchSize: This is number of records that will be moved at a time.
- generateNewUuids: Whether to generate UUIDs or not. If you want to move the records with existing UUID which is recommended set this to false note: This option has to be explicitly provided.
- debug: Whether to print debug level statements.
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