In this post I will go over how to create a simple HL7 interface that just accepts a HL7 message on a TCP port and then writes the message to a file. This will be a very simple interface, but it will get you familar with working with channels, sources, and destinations.
To begin, launch the Mirth Connect Administrator program, and go to the ‘Channels’ area.
A channel in Mirth is what I normally call a interface. It contains the sources, destinations, and all of the transformations and filters that make up a interface. So in order to create a new interface, we want to create a new Channel. To create a new Channel, click on ‘New Channel’ under the ‘Channel Tasks’ section. This will take you to the ‘Edit Channel’ window, and you will be on the summary tab.
If you click on ‘Help on this topic’ under the ‘Other’ section you will be taken to the Mirth help page, which gives a good explanation of all the options on the summary tab. I am going to name my channel ‘Simple Interface’, I am going to have it enabled, the incoming data is going to be HL7 2.x, I am going to synchronize the channel, and I am going to store the message data indefinitely.
Next click on the ‘Source’ tab to define the source for this interface. The source is how the data goes into the interface.
Again, you can click on ‘Help on this topic’ under the ‘Other’ section to get a good description of all the options on this screen. At the top of this window you select what type of connector you want to use. You will see that Mirth offers a large number of options for contecting to data. For this example we want to get HL7 information on a TCP socket. Almost all HL7 interfaces that go over TCP use LLP as their protocal, so I will select the LLP Listener.
Since I am receiving the data, I want to configure the LLP Mode to Server, and I can just enter 127.0.0.1 to let it know that I want to listen on the local address. You can pick whatever port you would like to listen to, for my example I will be listening on port 6661. I am going to accept the default for the rest of the settings. You can also specify filters and transformers on the source in order to filter out messages and make changes to the message, but I am not going to cover that in this post.
Next we need to create our destination. The destination species where the data is sent to. In Mirth you can have multiple destinations. You can either always send the data to all destinations, or apply filters to determine what destination the data is sent to. To create destinations you go to the ‘Destinations’ tab in the Edit Channel window.
There will already be one destination created for you. Just like the source, you select a Connector Type. We want to write the HL7 message to a file, so select the ‘File Writer’ message type. For the method select file, enter the directory that you want to write the file to. For the file name, drag ‘Message ID’ over from the Destination Mappings area to the file name field to have it use the message id as the file name. The template section determines what is written to the file, drag ‘Encoded Data’ from the Destination Mappings section to the Template filed to have it write the contents of the HL7 message to the file.
We now have the channel completed, click on ‘Save Changes’ under the Channel Tasks section in order to save the channel. We now need to deploy the channel in order to make it active so we can use it. Under the ‘Mirth Connect’ section click on ‘Channels’ to get back to the Channels window. You will now see you channel listed.
To deploy your channel click on ‘Deploy All’ under the ‘Channel Tasks’ section. Mirth will deploy your channel and switch to the Dashboard window. We are now ready to test the interface.
There are multiple tools that are available that you can use to test the interface by sending a HL7 message to the interface. I used HL7 Browser. Open a HL7 message in HL7 Browser and send it to your local computer to port 6661. You will see the dashboard in Mirth update to show that it sent the message, and you will see the HL7 message written out to a file.