Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -15,5 +15,35 @@ IBM FHIR Sandbox: IBM offers a free FHIR sandbox environment that you can use fo
|
|
15 |
""")
|
16 |
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
|
|
|
15 |
""")
|
16 |
|
17 |
|
18 |
+
import hl7apy
|
19 |
+
from fhir.resources import Bundle, Patient, Observation
|
20 |
+
from fhirclient.models.fhirreference import FHIRReference
|
21 |
+
import streamlit as st
|
22 |
+
|
23 |
+
# Create a sample HL7 v2.x message
|
24 |
+
msg = hl7apy.Message("ORU^R01")
|
25 |
+
msg.msh.msh_3 = "LAB"
|
26 |
+
msg.msh.msh_4 = "LAB"
|
27 |
+
msg.msh.msh_5 = "TEST"
|
28 |
+
msg.pid.pid_3 = "1234"
|
29 |
+
msg.pid.pid_5 = "Doe^John"
|
30 |
+
msg.pid.pid_7 = "19800101"
|
31 |
+
msg.obx = []
|
32 |
+
obx = hl7apy.Segment("OBX")
|
33 |
+
obx.obx_2 = "ST"
|
34 |
+
obx.obx_3 = "GLU"
|
35 |
+
obx.obx_5 = "100"
|
36 |
+
msg.obx.append(obx)
|
37 |
+
|
38 |
+
# Convert HL7 v2.x message to FHIR resources
|
39 |
+
patient = Patient(name=[{"given": ["John"], "family": "Doe"}], birthDate="1980-01-01")
|
40 |
+
observation = Observation(code={"coding": [{"system": "http://loinc.org", "code": "2339-0", "display": "GLUCOSE"}]}, valueQuantity={"value": 100, "unit": "mg/dL"}, subject=FHIRReference({"reference": f"Patient/{patient.id}"}))
|
41 |
+
bundle = Bundle(type="collection", entry=[{"resource": patient}, {"resource": observation}])
|
42 |
+
|
43 |
+
# Display the HL7 v2.x message and FHIR resources in the Streamlit app
|
44 |
+
st.write("HL7 v2.x message:")
|
45 |
+
st.code(str(msg))
|
46 |
+
st.write("FHIR resources:")
|
47 |
+
st.code(bundle.json())
|
48 |
|
49 |
|