Filtering Messages

In many integration workflows, not all messages need to be processed. Filtering out unwanted messages is a common practice to improve efficiency and ensure only relevant data moves through the system.

This involves checking key data elements in the message and deciding whether to process or discard it based criteria like message content or type.

Take the following interface workflow:

local filter = require 'filters' function main(Data) -- Parse the HL7 message local msg, name = hl7.parse{vmd='hl7.vmd', data=Data} -- Filter out unwanted messages if not filter.filterMessage(msg, name) then -- Map or Transform the message -- Write the data to a destination end end

For HL7, you can easily filter messages using:

  • Message Name: hl7.parse{} returns the name of the identified message which you can use to determine if it should be filtered or processed.

  • Catchall VMD Matching Rule: Create a catchall message definition and matching rules in your VMD to match multiple message types as a “Catchall“ message to be filtered out.

The following sample filtering rules are intended to be a base for you to adapt to your own requirements.

The filter.filterMessage() function does the following:

  • It filters out messages that match specified conditions

  • It logs a meaningful error in each case. Detailed logging is invaluable!

  • It returns true if a message should be filtered (false if it is ok to continue processing)

-- This module contains sample filtering rules. -- Use your own filter conditions and error messages. local filter ={} function filter.filterMessage(msgIn, name) if name ~= 'ADTA01' then iguana.logError('Unexpected message type.') return true elseif msgIn.MSH[3][1]:nodeValue():lower() == 'interfaceware' then iguana.logError('Rejecting test message from iNTERFACEWARE.') return true elseif msgIn.PID[5][1][1]:nodeValue():lower() == 'addams' then iguana.logError('No thing shall lurch or fester here!') return true end return false end return filter