Bahmni Test Data Generator
Source Code
User Configuration Inputs
Patient Count(PATIENT_COUNT)
- Number of patients for new registration with BahmniCreate Encounters(S_CREATE_ENCOUNTER)
- y/n - Flag to create encounters for the patients registered aboveEncounter Count(ENCOUNTER_COUNT)
- Number of patients that needs an encounterUpload Data(S_UPLOAD_CSV)
- y/n - Flag to upload the created csv files to Bahmni
config.yaml
PATIENT_PROFILE_FILE_NAME: output/registrations.csv
ENCOUNTER_PROFILE_FILE_NAME: output/encounters.csv
REGISTRATION_INDEX_START_POINT: 1011
PATIENT_REGISTRATION_START_DAY: "2014-02-11"
BASEURL : Required Bahmni URL
USERNAME: admin username
PASSWORD: admin password
LOCATION: valid location
//Default Configuration Parameters
REG_INITIAL: PERF
PATIENT_COUNT: 10
S_CREATE_ENCOUNTER: y
ENCOUNTER_COUNT: 10
S_UPLOAD_CSV: y
Glossary
PATIENT_PROFILE_FILE_NAME
- path of theregistrations.csv
file where the new patient details are availableENCOUNTER_PROFILE_FILE_NAME
- path of theencounters.csv
file where the encounters (previous visit related information of the patients) are availableREGISTRATION_INDEX_START_POINT
- last four ending digits of the unique ID created for the patientPATIENT_REGISTRATION_START_DAY
- reference date to create a random registration dateBASEURL
- Bahmni URL to upload the createdcsv
filesUSERNAME
- admin userPASSWORD
- admin passwordLOCATION
- login location of the admin userREG_INITIAL
- first four letters of the patient IDPATIENT_COUNT
- default patients count, value: 10S_CREATE_ENCOUNTER
- defaulted to y(yes) to create encounters for the above patientsENCOUNTER_COUNT
- default encounters count for each patient, value: 10S_UPLOAD_CSV
- defaulted to y(yes) to upload the createdcsv
files to Bahmni database
CSV Generator
CSV Generator takes user configuration inputs to create the patients(registration.csv), encounters(encounters.csv)and upload them to Bahmni, when the user configuration is not provided, default values are sent to CSV generator from config.yaml
To achieve the creation of real time test data about patients, CSV generator uses Faker service to generate name, address etc.
Once the test data gets created internally, they are stored in output folder successfully as registration.csv and encounters.csv(optional)
CSV Files Snapshot
registration.csv
"Registration Number","Registration Date","First Name","Middle Name","Last Name","Gender","Birth Date","Address.Village","Address.Tehsil","Address.District","Address.State"
"GAN1019","2021-07-13","Brahmabrata","Agarwal","Mehra","M","1935-09-04","Hyderabad","Apt. 680","Hyderabad","Manipur"
"GAN1020","2017-04-04","Sarisha","Nehru","Dubashi","F","1950-07-10","Mumbai","Apt. 807","Mumbai","Rajasthan"
encounters.csv
"Registration Number","encounterType","visitType","Patient.Name","Patient.AGE","Patient.Gender","Patient.Village","Visit Start Date","Visit End Date","Repeat.1.EncounterDate","Repeat.1.Obs.Chief Complaint Duration","Repeat.1.Obs.Chief Complaint Notes","Repeat.1.Obs.History Notes","Repeat.1.Obs.Examination Notes","Repeat.1.Obs.Smoking History","Repeat.1.Diagnosis.1","Repeat.1.Condition.1","Repeat.1.Obs.Consultation Note","Repeat.1.Obs.Hospital Course","Repeat.1.Obs.Operative Notes, Condition","Repeat.1.Obs.Operative Notes, Procedure","Repeat.1.Obs.Procedure Notes, Diagnosis"
"GAN1020","Consultation","OPD","Sarisha Nehru Dubashi","72","F","Mumbai","2017-04-04","2017-04-04","2017-04-04","12","Test notes","history notes","exam notes","yes","Fever","Infectious diarrhea","Testing Consultation Note","Testing hospital course comment","Stable","Wound Care","Need dressing"
"GAN1019","Consultation","OPD","Brahmabrata Agarwal Mehra","86","M","Hyderabad","2021-07-13","2021-07-13","2021-07-13","12","Test notes","history notes","exam notes","yes","Fever","Infectious diarrhea","Testing Consultation Note","Testing hospital course comment","Stable","Wound Care","Need dressing"
CSV File Upload
OpenMRS and BahmniCore APIs are used to upload both the registration and encounters csv files
Successful upload of the CSV files to the Bahmni database is possible only when the correct cookies have been created
To achieve the cookies setup before the upload, various different API services are called and the required cookie information is obtained and stored in the cookie store.
Note: cookie store - an object created to store and retrieve cookies in run time.
Order of Execution
Get Location Service
/openmrs/ws/rest/v1/location
Provides location and location uuid to the cookie store.
Get User Service
/openmrs/ws/rest/v1/user
Takes ‘user’ and ‘password’ from config.yaml and provides JSESSION ID
of the user to the cookie store.
Get Session Service
/openmrs/ws/rest/v1/session
Uses the current cookies from CookieStore and provides Reporting Session ID
to the cookies store.
Upload Patient Service
/openmrs/ws/rest/v1/bahmnicore/admin/upload/patient
Uses the current cookies from CookieStore and uploads the registration.csv
file using multipart upload method.
Get Upload Status Service
/openmrs/ws/rest/v1/bahmnicore/admin/upload/status
This service helps us to validate the csv
file upload has been completed successfully. Only when the status is retrieved as “Completed” the upload encounter service will be called further.
Upload Encounter Service
/openmrs/ws/rest/v1/bahmnicore/admin/upload/encounter
Uses the current cookies from CookieStore and uploads the encounters.csv
file using multipart upload method.
Get Upload Status Service
/openmrs/ws/rest/v1/bahmnicore/admin/upload/status
This service helps us to validate the csv
file upload has been completed successfully. Only when the status is retrieved as “Completed”, the build will be assigned successful.
The Bahmni documentation is licensed under Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)