This is a beginner Python project that reads a sample HL7 ORU lab result message and extracts patient and result information.
The purpose of this project is to practice basic HL7 message parsing and understand how healthcare interface messages are structured.
The script reads an HL7 message from a separate .hl7 file, checks for required segments, and extracts values from the PID and OBX segments.
The Python script:
- Reads an HL7 message from
sample_message.hl7 - Splits the message into HL7 segments
- Checks for required segments: MSH, PID, OBR, and OBX
- Extracts patient information from the PID segment
- Extracts lab result information from the OBX segment
- Formats the patient date of birth
- Converts HL7 codes into readable values, such as:
L= LowF= Final
- Displays a warning if the OBX result segment is missing
MRN: 123456
Patient: Smith, John
DOB: 05/12/1980
Test Code: HGB
Test Name: Hemoglobin
Result: 6.8 g/dL
Reference Range: 12.0-16.0
Flag: Low
Status: Final