You are viewing an old version of this page. View the current version.
Compare with Current
View Page History
Version 1
Next »
– in progress
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:
Use conditional logic to check messages against your filters
The Inbound HL7 message is parsed and passed to a filtering function along with the name of the message type.
if statements are used to call the filter.checkMsgType()
function to test for messages to be filtered out.
The filtering rules are placed in a local filters.lua file so that we can separate concerns and create multiple rules to check.
local filter = require 'filters'
function main(Data)
-- Parse the HL7 message
local msg, name = hl7.parse{vmd = 'example/demo.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
How to structure filtering rules in filters.lua
The following sample filtering rules are intended to be a base for you to adapt to your own requirements.
-- This local module contains functions customized for this component only
local filter ={}
function filter.checkMsgType(Msg)
if Msg:nodeName() == 'Catchall' then
iguana.logError('Unexpected message type.')
return true
-- use your own filter conditions and error messages
elseif Msg.MSH[3][1]:nodeValue():lower() == 'interfaceware' then
iguana.logError('Rejecting test message from iNTERFACEWARE.')
return true
elseif Msg.PID[5][1][1][1]:nodeValue():lower() == 'addams' then
iguana.logError('No thing shall lurch or fester here!')
return true
end
return false
end
return filter