Filtering Messages

This article shows you how to filter out messages that you do not wish to transmit. Message filtering is always based on a specified condition or conditions, you can use any condition(s) that match your requirements. In this example we will filter out all unrecognized messages. These are messages that are not recognized by our VMD file and are therefore identified as “Catchall” messages (messages that do not match any other message definition).

The example used in this tutorial copies an incoming HL7 message to an outgoing HL7 message, but the same technique will work with all types of incoming and outgoing messages.

In this tutorial we do the filtering in the Filter component, but the same filtering code can be used in any component where filtering is needed.

Create the Channel [top]

  1. Create a Channel with the the following settings:
    • Source = LLP Listener
    • Destination = LLP Client
    • Channel name = Message Filtering
  2. Activate the Filter Component: Click the Filter tab and check Use Filter.
  3. Click the Add Channel button to create the channel.
    Ignore the red warning messages, see resolving the milestone configuration error.
  4. Open the Translator by clicking the Edit Script link at the bottom of the Filter tab.
  5. Download and import the project file.
    This file contains a skeleton project and six sample HL7 messages.
  6. Iguana will load the project and data into the Translator, your screen should look like this:

Tutorial Instructions [top]

  1. Pass the message data to the script.
    • Iguana automatically passes the message data to the main() function
    • The message can be accessed using the Data parameter
    • No action is needed
  2. Create the outgoing message.
    Add the following lines of code to your script:
  3. Filter out unwanted messages.
    Add the following lines of code to your script:

    You can change the if statement to use whatever condition(s) match your business requirement.
  4. Navigate through the sample messages to see the filtering code in action.
    Here you can see that an order message (ORM^O01) is not recognized, so it is filtered out:
  5. You will also need to complete the mapping and transformation of the message and write it to the queue, see the mapping and transformation tutorials in this section.

Tip: You can apply the same filtering logic no matter what you are doing with the message.

For example if you are writing to a database, two changes are needed, and the code would usually be in a To Translator component:

Complete Sample Code [top]

Here is the completed filtering code that you can cut and paste into your script.

function main(Data)
   -- (1) Parse the HL7 message
   local Msg, Name = hl7.parse{vmd = 'example/demo.vmd', data = Data}
   local Out       = hl7.message{vmd = 'example/demo.vmd', name=Name}

   -- (2) Filter out unwanted messages
   if Msg:nodeName() == "Catchall" then
      iguana.logError('Filtering Message')
   -- Map the complete message      
   -- Transform the message      
   -- Push the outgoing message into the Iguana queue

More Information [top]

Leave A Comment?

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