Created
September 25, 2021 01:36
-
-
Save swhume/61800b8f967addba62a18bb50b3e8634 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fhirclient import client | |
import fhirclient.models.observation as ob | |
settings = { | |
'app_id': 'rof_adapter', | |
'api_base': 'https://api-v5-stu3.hspconsortium.org/rofphir/open' | |
} | |
def get_observations(patient_id, loinc_code): | |
smart = client.FHIRClient(settings=settings) | |
search_obs = ob.Observation.where(struct=dict(patient=patient_id, code=loinc_code)) | |
obs = "" | |
if len(search_obs.perform_resources(smart.server)) > 0: | |
obs = search_obs.perform_resources(smart.server).pop().as_json() | |
return obs | |
# get lab WBC | |
pt_id = "SMART-1642068" | |
loinc_code = "26464-8" # WBC Bld | |
wbc = get_observations(pt_id, loinc_code) | |
print("WBC Bld:", wbc) | |
# get vitals sysbp | |
pt_id = "SMART-665677" | |
loinc_code = "8480-6" | |
sysbp = get_observations(pt_id, loinc_code) | |
print("Systolic BP:", sysbp) | |
# get vitals diastolic bp | |
loinc_code = "55284-4" | |
dbp = get_observations(pt_id, loinc_code) | |
print("Diastolic BP:", dbp) | |
# get vitals bmi | |
loinc_code = "39156-5" | |
bmi = get_observations(pt_id, loinc_code) | |
print("BMI:", bmi) | |
# get vitals heart rate | |
loinc_code = "39156-5" | |
hr = get_observations(pt_id, loinc_code) | |
print("HR:", hr) | |
# get vitals temp | |
loinc_code = "8310-5" | |
temp = get_observations(pt_id, loinc_code) | |
print("Temp:", temp) | |
# get vitals height | |
loinc_code = "8302-2" | |
height = get_observations(pt_id, loinc_code) | |
print("Height:", height) | |
# get vitals weight | |
loinc_code = "3141-9" | |
weight = get_observations(pt_id, loinc_code) | |
print("Weight:", weight) | |
# get lab rbc | |
loinc_code = "789-8" | |
rbc = get_observations(pt_id, loinc_code) | |
print("RBC:", rbc) | |
# get lab albumin | |
pt_id = "SMART-765583" | |
loinc_code = "1751-7" | |
alb = get_observations(pt_id, loinc_code) | |
print("Albumin:", alb) | |
# get lab glucose SerPl-mCnc | |
pt_id = "SMART-665677" | |
loinc_code = "2339-0" | |
gluc = get_observations(pt_id, loinc_code) | |
print("Glucose:", gluc) | |
# get lab hemoglobin / Hgb Bld-mCnc | |
pt_id = "SMART-665677" | |
loinc_code = "718-7" #"4548-4" | |
hema = get_observations(pt_id, loinc_code) | |
print("Hemoglobin:", hema) | |
# get lab creatinine | |
pt_id = "SMART-765583" | |
loinc_code = "2160-0" #"14959-1" | |
creat = get_observations(pt_id, loinc_code) | |
print("Creatinine:", creat) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment