HL7 is based on messages. The HL7 standard defines a number of different types of messages, each serving a different purpose.
LEADTOOLS toolkits provide the MessageFactory and MessageConstructor classes to simplify the process of creating different messages for HL7.
As an example, in order to build an ORU_R01 HL7 message (observation result message), first start by calling MessageFactory.New which will return a message of the specified type. Next, call the MessageConstructor.CreateSegments method which will create all segments, each with empty values. Finally, call MessageConstructor.FillCommonMSH in order to fill the MSH header with typical values.
Typical values for MSH segments include the default encoding characters as specified by the HL7 standard.
HL7 messages come encoded as text messages, and are called pipe-messages because typically the pipe character ( ¦ ) is used to separate the fields.
To load a message from a given string that contains the pipe-message text, begin by creating an instance of the PipeMessageConverter class. Next, call PipeMessageConverter.PipeMessageToMessageStructure to load the message to an intermediate format called MessageStructure. Next, create an instance of MessageStructureConverter and call MessageStructureConverter.MessageStructureToMessage to convert it into an HL7 message.
The MessageStructure class is provided for added flexibility. Use this class to easily manipulate a pipe message.
The MessageStructureConverter.MessageStructureToMessage method has a number of parsing flags that cover most message parsing cases. For example, there is a parsing flag that allows messages with non-standard segments to be parsed.
Save HL7 messages to text messages (mainly pipe messages) or XML messages.
To save a message to a pipe-message from a given message object, simply call SegmentStructureConverter.MessageToPipe. It outputs text pipe messages.
XML can be useful when communicating with a web service. Use the SegmentStructureConverter.MessageToXML method to output XML text.
Note: The XML text output by the SegmentStructureConverter.MessageToXML method is totally different from HL7 V3 XML notation.
To modify the contents of a message, either set text values to IField.Value or use the solid presentation of the message to modify fields.
For example, if you have an ADT_A01message, modify the field separator as follows:
ADT_A01.MSH.Field_Separator.Value = "|";
The same technique applies when reading field values.
Each message item contains a ‘Schema” which can be accessed from INodeItem.Schema. To determine whether an item is required, call ISchemaItem.Mandatory.
One way of validating HL7 messages is to loop through all items and check their schemas (access schemas from INodeItem.Schema). For example, determine whether ISchemaItem.Mandatory is true. If it is then the item should have repetitions; otherwise, it is not valid.
Another way of doing this is to first save the item as a pipe-message, and then try to load it again. This takes advantage of the automatic validation performed when a message is loaded. Refer to the "Loading a Message" and "Saving a Message" sections, above, for more information.
Building an HL7 Network Client
Building an HL7 Network Server
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document