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

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

  • 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

You can also use a Catchall Matching Rule in your VMD to identify multiple messages you to catch and filter out. See .