A comprehensive tool for migrating data between OpenMRS instances while handling differences in metadata, concepts, and programs.
- Horizontal migration (patient by patient)
- Complete data migration including:
- Users and roles
- Patients and related data
- Visits and encounters
- Observations
- Programs and workflows
- Configurable mappings for different metadata elements
- Transaction support for data integrity
- Detailed logging
- Error handling and rollback support
- Node.js 16 or higher
- Access to source and target OpenMRS databases
- MySQL/MariaDB
- Clone the repository
- Install dependencies:
npm install
- Copy
.env.example
to.env
and configure your database connections
- Update
config/mappings.yml
with your specific mappings for:- Concepts
- Encounter types
- Forms
- Visit types
- Programs
- Identifier types
- Configure your database connections in
.env
- Update mappings in
config/mappings.yml
- Run the migration:
npm start
Logs are written to:
- Console (for immediate feedback)
migration.log
file (for detailed debugging)
- Each patient's data is migrated in a transaction
- If an error occurs, the transaction is rolled back
- Detailed error logs are available in
migration.log
- Always backup both databases before migration
- Test with a small subset of patients first
- Verify mappings before full migration
- Monitor the logs during migration
- Validate data after migration
-
Different concept dictionaries:
- Update concept mappings in
config/mappings.yml
- Example:
concepts: 5096: 5097 # Weight concept has different ID
- Update concept mappings in
-
Different form versions:
- Update form mappings
- Verify form schemas match
-
Missing programs:
- Add program mappings
- Skip if program doesn't exist in target
MIT