listLab Instructions 2

Lab Instructions for HealthGorilla ETL with OpenMRS

Prerequisites

  1. Checked out Lab Repo from GitHub CS595 Lab RepoStep

  2. Pull the code to get the latest updates for GitHub Repo

  3. Python version 3.10 or later

  4. A Python virtual environment to link and use for the project (Python version: 3.10 or later)

  5. 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

  1. 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)

  2. Open this folder in VS Code.

  3. Create and activate a Python virtual environment:

    python -m venv venv

>> source venv/bin/activate # Mac/Linux >> venv\Scripts\activate # Windows

  1. Install dependencies:

    pip install -r requirements.txt // windows

python3 -m pip install -r requirements.txt // mac

Setup and Verify LoF Services

  1. Inside the lof folder, open the .env file.

  2. Update it with your LoF credentials:

    client_id= client_secret=

  3. Run the LoF verification script:

    python services.py

  4. You 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

  1. Implement the following functions in Script.py:

    • retrieve_patient_from_hg

    • transform_hg_to_openmrs

  2. Uncomment the following line in the main():

    result = retrieve_patient_from_hg(patient)

  3. Run the script:

    python Script.py

  4. On 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

  1. Implement the following functions in Script.py:

    • upload_conditions

  2. Uncomment the following line

upload_conditions(uuid, conds)

  1. Run the script:

    python Script.py

  2. The 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