Spaces:
Runtime error
Runtime error
import streamlit as st | |
import hl7 | |
from hl7tools.segment_def_enums import * | |
def parse_hl7(message): | |
# Parse the HL7 message using the hl7 library | |
parsed_message = hl7.parse(message) | |
# Loop through the segments in the message | |
for segment in parsed_message: | |
# Get the segment type | |
segment_type = segment[0] | |
# Get the field names for the segment type | |
field_names = get_segment_fields(segment_type) | |
# Loop through the fields in the segment | |
for i, field in enumerate(segment): | |
# Label the field with its corresponding field name | |
if i < len(field_names): | |
st.write(f"{field_names[i]}: {field}") | |
else: | |
st.write(f"Unknown field: {field}") | |
# Define the Streamlit app | |
def app(): | |
# Add a text input field for the HL7 message | |
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") | |
# Parse the HL7 message and display the labeled fields | |
if hl7_message: | |
parse_hl7(hl7_message) | |
if __name__ == "__main__": | |
app() | |