-
Notifications
You must be signed in to change notification settings - Fork 0
Home
OVERVIEW
The OpenMRS Groovy Data Importer is a set of scripts I wrote to import legacy patient demographics and encounters into my OpenMRS implementation. Some pieces can be reused on other projects, and I post them here in the hope it may help other developers with their projects. The rest I include as examples.
THE REUSABLE BITS
There are two parts that can be reused.
First, I wrote an OpenMRS domain specific language. A DSL is like a mini programming language that's tailored to a particular kind of problem or expertise. It allows you to represent things in a way that's somewhat more natural to people working in an area. In other words, this will help programmers code with OpenMRS more easily and productively by hiding some of the API's complexity. The DSL could be used for any tool. See org.openmrs.dsl.* for source code, and the test cases for examples.
Second, there are classes for the tasks that are common to all imports. These include:
- Iterate over a data source. For any field in a record, hand back the value, with any cleanup or lookups needed to make it meaningful outside of the legacy system.
- Translate each legacy record into OpenMRS objects
- Save the resulting OpenMRS objects
- Log errors and bad records for reimport
- Handle administrative OpenMRS tasks: start a session, authenticate, cache Concept or other objects, and fetch existing records if this is a reimport.
THE EXAMPLE BITS
These are libraries, rather than an application. Each OpenMRS installation and legacy data set is unique. You must understand OpenMRS well enough to design your custom concepts, forms, and patient attributes, and understand your legacy data well enough to know where it's going and what cleanup must be done. Subclass these classes with the specifics for your implementation.
I've included my code for four imports: patient demographics, OPD and ER encounters, and a lab encounter for blood typing. These are in the org.angkorhospital.* classes. They're here as examples, and will not work on your system as-is. All ID numbers ( concept, form, location, attribute, and provider IDs) are specific to my implementation. The structures reflect how I decided to represent the records in OpenMRS.
THE OPEN SOURCE BITS
I'm happy to accept improvements to the org.openmrs.groovyimporter.* packages. The DSL includes only the classes I've needed so far. The importer class may do well importing against the new REST API rather than opening an OpenMRS session. The data source class imports from CSV text files, and there may be a use for database-driven sources.