Lab Instructions 2
Lab Instructions for HealthGorilla ETL with OpenMRS
Prerequisites
Checked out Lab Repo from GitHub CS595 Lab RepoStep
Pull the code to get the latest updates for GitHub Repo
Python version 3.10 or later
A Python virtual environment to link and use for the project (Python version: 3.10 or later)
Do Git Pull on lab repo to make sure you have the latest updates
Setup and Verify Lab env & LOF Services
Setup the Lab Environment
Create a new folder for this lab and place the following files inside it:
Script.py services.py patient.csv requirements.txt .env (make sure it saved as .env and not as txt)Open this folder in VS Code.
Create and activate a Python virtual environment:
python -m venv venv
>> source venv/bin/activate # Mac/Linux >> venv\Scripts\activate # Windows
Install dependencies:
pip install -r requirements.txt // windows
python3 -m pip install -r requirements.txt // mac
Setup and Verify LoF Services
Inside the lof folder, open the
.envfile.Update it with your LoF credentials:
client_id= client_secret=Run the LoF verification script:
python services.pyYou should see the message: “LoF Services verified successfully”.
If you see an authentication error, refer to the “Possible Error Messages and Resolution” section at the end of this document.
Main Lab Steps
Step 1 – Populate Patients
Implement the following functions in
Script.py:retrieve_patient_from_hgtransform_hg_to_openmrs
Uncomment the following line in the main():
result = retrieve_patient_from_hg(patient)Run the script:
python Script.pyOn a successful run, you should see logs similar to:
1 match found in Health Gorilla for patient Rantdt Hotestead with HG ID: 1b7aca64e07d9a4b8ea0ff22 Patient registration status code: 201 1 match found in Health Gorilla for patient Angi Roftec with HG ID: 3e7aca64fa952e7abc670566 Patient registration status code: 201
Check the OpenMRS UI to confirm that new patients have appeared. If not visible immediately, refresh or log in again. Record the Patient IDs (MRN) for reference.
Step 2 – Populate Conditions
Implement the following functions in
Script.py:upload_conditions
Uncomment the following line
upload_conditions(uuid, conds)
Run the script:
python Script.pyThe script will insert patient conditions from Health Gorilla into OpenMRS. # Note : Minor errors caused by missing or mismatched data can be ignored.
Validating Patient Conditions
Confirm that conditions were successfully imported by viewing the data directly in the OpenMRS Facesheet UI.
Possible Error Messages and Resolution
Missing or Incorrect client_id
Failed to get LoF auth token: 400 : {"error":"Invalid client ID"}
Resolution: Update the correct client_id in .env.
Missing or Incorrect client_secret
Failed to get LoF auth token: 401 : {"error":"Unauthorized: Client authentication failed","status":401}
Resolution: Update the correct client_secret in .env.
Submission
Submit the following:
The patient JSON or CSV file (from Step 1)
Screenshots of both patients’ data displayed in OpenMRS
A report with learnings, concepts, issues faced and resolutions.
Last updated