Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import hl7
|
3 |
+
from hl7tools.segment_def_enums import *
|
4 |
+
|
5 |
+
def parse_hl7(message):
|
6 |
+
# Parse the HL7 message using the hl7 library
|
7 |
+
parsed_message = hl7.parse(message)
|
8 |
+
|
9 |
+
# Loop through the segments in the message
|
10 |
+
for segment in parsed_message:
|
11 |
+
# Get the segment type
|
12 |
+
segment_type = segment[0]
|
13 |
+
|
14 |
+
# Get the field names for the segment type
|
15 |
+
field_names = get_segment_fields(segment_type)
|
16 |
+
|
17 |
+
# Loop through the fields in the segment
|
18 |
+
for i, field in enumerate(segment):
|
19 |
+
# Label the field with its corresponding field name
|
20 |
+
if i < len(field_names):
|
21 |
+
st.write(f"{field_names[i]}: {field}")
|
22 |
+
else:
|
23 |
+
st.write(f"Unknown field: {field}")
|
24 |
+
|
25 |
+
# Define the Streamlit app
|
26 |
+
def app():
|
27 |
+
# Add a text input field for the HL7 message
|
28 |
+
hl7_message = st.text_area("Enter HL7 message here", value="MSH|^~\&|ANYSHARE^2.16.840.1.113883.1.2966.500.1.1.17.1.312.1|ABCCHHH|AnyCompanyHIE|CDX|20190408235621||ADT^A03|183000519^248647541|P|2.5.1\r")
|
29 |
+
|
30 |
+
# Parse the HL7 message and display the labeled fields
|
31 |
+
if hl7_message:
|
32 |
+
parse_hl7(hl7_message)
|
33 |
+
|
34 |
+
if __name__ == "__main__":
|
35 |
+
app()
|