Use the HL7 Inbound Device's "MessageReceived" Event Hook

When you need to modify the raw data that is being received by the HL7 Inbound Device, before the message is processed. For example, in one case the segment terminator that was being received was 0x0A instead of 0x0D and this needed to be corrected before the message was processed.

Step-by-step guide

  1. If you do not have a Custom Code device, or HL7 Transform Device V2 in your channel, you need to add one.
  2. In the Code editor of either the HL7 Transform Device V2, or Custom Code Device, go to the "Event Publications" folder and expand its contents (see below)

  3. Drag the MessageReceived event from the tree, into the code editor.
  4. Add your custom code to modify the property e.Message


The way this works is as follows.

When a message is received via the HL7 Inbound Device, before any processing to the message has been done, the device publishes an MessageReceived event. Passed into the event is the MessageReceivedEventArgs which contains, among other things, the message that was received. 

You can use this event to modify the message as needed before the message is pushed down the channel.

There are a number of other Event Hooks in the HL7 Inbound device, as well as other devices, that you can hook in to the framework to do some pretty interesting things. For example there is a similar event available on the Outbound HL7 Device that will allow you to manipulate the message just before it is sent out over the network

 

Attached Sample

The attached channel demonstrates fixing invalid segment termination characters: 0x0A by replacing them with the standard segment terminator: 0x0D.