Send HL7 sample data using LLP Client


Our HL7 Simulator is a Windows only tool so it is not convenient to use it on the other operating systems like Mac or Linux. A simple solution to this problem is to create a channel that reads HL7 messages from a file and forwards them using an LLP Client destination (this works on all operating systems).

Task [top]

Create a channel to read HL7 messages from a file and forward them using an LLP Client destination.  In the example code shown here we use the HL7 sample messages that are included with the Iguana install — <iguana install dir>/Demo/sample_data.txt.

Implementation [top]

  1. Create a channel named HL7 LLP simulator (or similar).
    • Source: From Translator
    • Destination: LLP Client
  2. Paste this code into the From Translator:
    -- NOTE: using the "/" forward slash in the path works Windows as well 
    SAMPLE_DATA = iguana.workingDir()..'Demo/sample_data.txt'
    function main()
       -- open the sample data file
       local f =
       -- read & queue each message
       while true do
          -- uncomment to pause between messages
          --util.sleep(1000) -- 1000 = 1 second
          local r = f:read()
          if r == nil then 
  3. Save a commit.
  4. identify the Port, in the LLP Client destination properties (default = 5145):
    llp client port
  5. Create another channel with an LLP Listener source and use the port from the previous step:
    LLP Listener properties
  6. Start your Listener channel.
  7. Start your LLP Simulator channel and then stop it immediately.

    Stopping the HL7 Simulator channel immediately after starting ensures that you will only send the file of (282) sample messages a single time. You can leave the channel running if you wish but every time the channel polls it will send all the messages in the file again — this is ok if you wish to send the messages repeatedly.

How it works [top]

  1. The channel uses the sample_data.txt included in the Iguana install.

    The code automatically finds the HL7 sample message file (<iguana install dir>/Demo/sample_data.txt) that is included with the Iguana install.

  2. Each message is then read in from the file using f:read().

    This works because each HL7 message is stored as a line in the sample data file (sample_data.txt). If you want to use the code with your own file you will need to ensure that each message is on one line (i.e., using a LF or /n to separate the messages).

    Iguana sample message editor

  3. Each message is queued.
  4. When the end of file is reached (r=nil) the loop exits and processing stops.
  5. Queued messages are sent out as LLP messages by the LLP Client destination.

Note: Every time the channel polls it will send the file again. You will probably only want to send the file once — in this case just stop the channel immediately, and it will only process the file a single time. It will take some time for the channel to stop as it needs to finish processing the file (so you do not want to force stop the channel).

However you can also leave the channel running if you wish to send the file several times — but be careful as you can send a lot of messages. You can slow the message sending by using sleep (time between each message) or adjusting the polling time (time delay between repeating the file).

The polling time is set in the channel source setting (default = 10 seconds):

polling time

More information [top]



Leave A Comment?

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.