From d1bdb4390d94006d94a09f0d2e4c977c15ff6c80 Mon Sep 17 00:00:00 2001 From: ur23 <ur23@ic.ac.uk> Date: Wed, 7 Feb 2024 20:45:19 +0000 Subject: [PATCH] parsing_mesage_types1.0 --- constants.py | 2 +- main.py | 2 +- utils.py | 8 ++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/constants.py b/constants.py index 2716bef..a1db2a1 100644 --- a/constants.py +++ b/constants.py @@ -3,7 +3,7 @@ MLLP_START_CHAR = b"\x0b" MLLP_END_CHAR = b"\x1c\x0d" # Path to load and store the trained Decision Tree model -DT_MODEL_PATH = "model/dt_model.joblib" +DT_MODEL_PATH = "dt_model.joblib" ON_DISK_DB_PATH = "database.db" # Map for AKI Label diff --git a/main.py b/main.py index d0adabf..6c167fe 100644 --- a/main.py +++ b/main.py @@ -34,7 +34,7 @@ def start_server(host="0.0.0.0", port=8440): print(category,mrn,data,'\n') # Create and send ACK message - ack_message = create_acknowledgement(message) + ack_message = create_acknowledgement() sock.sendall(ack_message) else: print("No valid MLLP message received.") diff --git a/utils.py b/utils.py index 06ad06c..22f473c 100644 --- a/utils.py +++ b/utils.py @@ -20,7 +20,8 @@ def parse_hl7_message(hl7_data): """ Parses the HL7 message and returns the parsed message object. """ - message = hl7.parse(hl7_data.decode("utf-8")) + hl7_string = hl7_data.decode("utf-8").replace('\r', '\n') + message = hl7.parse(hl7_string) return message @@ -88,7 +89,10 @@ def populate_test_results_table(db, path): def parse_system_message(message): """ - Parses the HL7 message and returns the parsed message object. + Parses the HL7 message and returns components of respective message type: PAS, LIMS + Args: + - HL7 message object + Returns the category of message, MRN, [AGE, SEX] if PAS category or [DATE_BLOOD_TEST, CREATININE_VALUE] if LIMS """ mrn = 0 category = '' -- GitLab