Python library for parsing, creating, and manipulating HL7 v2.x messages. Supports HL7 versions 2.1 through 2.7, provides both high-level and low-level APIs for message construction, validation against HL7 schemas, and MLLP (Minimal Lower Layer Protocol) transport support.
pip install hl7apyVerified import paths — ran on the pinned version, not inferred.
Create and parse HL7 v2.5 messages using hl7apy.
Use \r between segments: 'MSH|...|2.5\rPID|...' and ensure raw strings or proper escaping.
Pass validation_level=VALIDATION_LEVEL.TOLERANT when constructing or parsing: Message('ADT_A01', validation_level=VALIDATION_LEVEL.TOLERANT)Use parse_segment() from hl7apy.parser for individual segments, or always pass complete messages to parse_message().
Refer to HL7 spec field numbers. Access sending application as m.msh.msh_3, not m.msh.msh_2.
Use Python 3.6+ and verify examples against current API. Check GitHub issues for compatibility notes.
Always join segments with \r when building composite output manually.
Install the library using pip: `pip install hl7apy`
Ensure the input string is a valid HL7 v2 message with correct segment delimiters (often `\r` or `\n` needs to be replaced with `\r`), field separators, and an MSH segment. You might need to preprocess the message string, e.g., `message.replace('\n', '\r')` or explicitly set `find_groups=False` if dealing with non-standard messages.Verify the HL7 message structure and element names against the official HL7 specification for your message type and version. If you intend to add a non-standard or 'Z' element, consider using `validation_level=VALIDATION_LEVEL.TOLERANT` during message creation or element assignment.
Ensure that date/time values adhere to HL7's specified formats (e.g., YYYYMMDD, YYYYMMDDHHMMSS, YYYYMMDDHHMMSS.sss[+/-ZZZZ]). If the format is intentionally non-standard, set the validation level to `VALIDATION_LEVEL.TOLERANT` for the message or element.
No dependency data recorded yet.