How to build an HL7 message
Learn how the basic structure of an HL7 message works.
Building an HL7 message involves creating a specific format that includes a header and content segments. Segments are separated by a carriage return (), and each segment contains fields that are separated by a pipe character (|
). Additionally, if fields contain subfields, they are separated by a caret (^
).
Step-by-step guide to building the message
Creating the MSH segment (Message Header)
The first segment in any HL7 message is the MSH, which defines basic information about the message. The structure of the MSH generally includes the following fields:
MSH-1: Field Separator (usually “
|
”)MSH-2: Encoding Characters (usually “
^~&
”)MSH-3: Sending Application
MSH-4: Sending Facility
MSH-5: Receiving Application
MSH-6: Receiving Facility
MSH-7: Date/Time of Message
MSH-8: Security
MSH-9: Message Type (example:
ADT^A01
)MSH-10: Message Control ID
MSH-11: Processing ID
MSH-12: Version ID
An example of how this can be formatted:
Final considerations
When building HL7 messages, it’s important to ensure that all required fields are present and that they follow the expected format and order to avoid communication issues between the integrated healthcare systems.
Last updated
Was this helpful?