Event Hooks
Many Connexion devices include explicit points where the existing logic can be altered - these are called Event Hooks (and are analogous to events in most programming languages). If a device provides the vast majority of logic your workflow requires, but you require a small tweak, update, or additional logic, event hooks should be your first choice.
Custom devices (plugins) can also expose event hooks.
For this example, we’re using the following channel:
Event Hooks for each device within a channel are exposed by Custom Code Devices. While you can work with event hooks in any custom code device within your channel, we recommend adding a dedicated custom code device to the end of your channel. In our example, we’ve placed it after a Channel Separator device.
Available event hooks are displayed in the tree on the right side of the Custom Code device. Expand the tree to view the available hooks.
Custom Code devices come with boilerplate code for processing messages. Since this device will not process any messages (it’s purely for injecting our own logic), we can remove all the boilerplate code.
After dragging and dropping the MessageReceived tree item, we get the following code:
Let’s assume that we need to replace invalid segment termination characters 0x0A with the standard segment terminator: 0x0D. We can accomplish this by adding the following code:
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 a 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.