Migrate Patient and Encounter Data

Purpose and Benefits

Bahmni supports data migration via CSV files. There are two types of data you can create, patient and encounter. With patient you can create patient attributes, address details, patient identity amount with core patient fields. Patient import allows you to specify the patient identity matching logic using a groovy script. Encounter import allows you to create encounters with observations (we don't support orders yet). The import automatically creates the visits for you based on the days supplied.

Sample CSV formats for Data Import

You can see some sample import CSV file formats in github here: https://github.com/Bahmni/banyan-config/tree/master/openmrs/referencedata


Note

From v0.90 Bahmni, We are supporting the CSV import of special characters/non-english characters. This is done as part of this Jira card.

Types of CSV Imports

Bahmni has 4 different types of imports for transactional data. For each type of import we have attached a sample file  with some example rows. 

1. Patient

Patient Data - This is just to create the patients with their identifiers (used by the hospital). patient.csv

Registration Number,Registration Date,First Name,Middle Name,Last Name,Gender,Birth Date,Address.Village,Address.Tehsil,Address.District,Address.State

To import implementation-specific Patient Attributes, the column heading should be "Attribute.nameOfTheAttribute".

From 0.90v Bahmni, we are supporting CSV import of org.openmrs.util.AttributableDate type. It is a implementation-specific person attribute which can be configured from openmrs admin.

From 0.94v, it also supports for validating mandatory fields in patient registration page.

2. Encounters

Encounter import meant for importing all clinical information about the patient. This is meant for observations, diagnosis, lab order/results and drug orders. We do not support the last two yet. The visit and encounters are also imported via this same file. Here is a sample file encounter_import.csv. The encounter fields reference:

 

KeyUseMandatory
Registration Number The identifier for the patient, for example GAN200189 Y
Patient.Name
 N
Patient.AGE
 N
Patient.Gender
N
Patient.Village
N
encounterTypeName of encounter type, for example Consultation.N (Encounter level)
visitTypeName of the visit type, for example Outpatient.N
Visit Start Date

If visit dates are not provided the encounter date would be used to create a visit for just one day.

If there is already a visit in the database for that date then the import would use that visit.

N
Visit End Date
N
EncounterDate
N (Encounter level)
Obs.Obs PathIn obs path you can provide the complete concept-set+concept path. For example: Diabetes Template.Nutritional Values.HeightN (Encounter level, Multiple allowed)
DiagnosisThe name of diagnosis concept. It assumes all diagnosis to be be primary and confirmed.N (Encounter level, Multiple allowed)
  • The date format is yyyy-mm-dd
  • (has multiple) fields can be provided more than once like Diagnosis.1, Diagnosis.2 for a every encounter
  • (encounter level) fields should be prefixed with Repeat.1., Repeat.2. and so on when using multiple fields.
  • You can enter multiple encounters by prefixing the column headers with of diagnosis, observations with Repeat.x. For example your columns could be named as Repeat.1.Obs.History, Repeat.1.Diagnosis.1 and Repeat.2.Obs.History, Repeat.2.Obs.History.
  • You can provide observations by providing the ConceptSet+Concept hierarchy. You can see an example in the attached file.

Bahmni also supports following features for forms 2 (Use )

  • checks for mandatory fields (Validate all mandatory fields and provide error message if field is empty.)
  • check for future dates 
  • loading of multiple entries for multi select observations (suffixing column headings with attribute MultiSelect=true; Default Delimiter is | or configure global property bahmni.admin.csv.upload.obs.multiSelect.splitter)
  • loading of multiple entries for Add more observations (suffixing column headings with attribute AddmoreConcept=true; Default Delimiter is | or configure global propertybahmni.admin.csv.upload.obs.addmore.splitter)
  • loading of multiple entries for observation in Add more section (suffixing column headings with attribute AddmoreSection=true)

Refer this talk thread for more info.

3. Lab Results

Please refer to the sample import file.

 

KeyUseMandatory
Registration Number The identifier for the patient, for example GAN200189 Y
Patient.Name
 N
Patient.AGE
 N
Patient.Gender
N
Patient.Village
N
DateVisit starting dateN
Visit TypeName of the visit type, for example LAB_VISIT.N
TestTest nameN
ResultResult for the lab testN

Test,Result can be repeated multiple times to upload multiple lab results.

4. Relationships

The CSV Relationship Import/Upload provides an ability to import/upload relationship information for patients using a CSV file.

Consider two assumptions:

  1. We have an existing patient (Person A) for whom we would like to add relationships, whose registration number should be entered in the Registration_Number field.
    We should populate the Related_To_Registration_Number field for relationships between 2 persons in the system. We should populate the Provider_Name field for relationships between a person and provider. Relationship_StartDate  and  Relationship_EndDate are optional fields. If the are not specified then Relationship_StartDate will be saved as today's date and Relationship_EndDate will be null.

  2. There will be a global property "bahmni.relationshipTypeMap", which provides all required mapping for all possible relationships. This is used to validate information provided in the CSV file in the Relationship_Type column. 

The following is an example for a global property relationship mapping:

{
 "patient": ["Sibling", "Parent", "Child", "Uncle"],
 "provider": ["Doctor", "Nurse", "Care Taker"]
} 

Data in the CSV file to be uploaded must be as per the following required order and names of columns:

  1. Registration_Number
  2. Relationship_Type
  3. Related_To_Registration_Number
  4. Provider_Name
  5. Relationship_StartDate
  6. Relationship_EndDate

The first four columns are mandatory. The dates should be provided in the following format: yyyy-mm-dd. Here is an example of a relationship CSV file.

The Bahmni documentation is licensed under Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)