– 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.
...
Expand |
---|
title | 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.
Code Block |
---|
| local filter = require 'filters'
function main(Data)
-- Parse the HL7 message
local msg, name = hl7.parse{vmd = 'example/demohl7.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 |
|
Expand |
---|
title | 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. 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)
Code Block |
---|
| -- This local module contains functions customized for this component only
sample filtering rules.
-- Use your own filter conditions and error messages.
local filter ={}
function filter.checkMsgType(MsgfilterMessage(msgIn, name)
if Msg:nodeName()name ~== 'CatchallADTA01' then
iguana.logError('Unexpected message type.')
return true
-- use your own filter conditions and error messages
elseif Msgelseif msgIn.MSH[3][1]:nodeValue():lower() == 'interfaceware' then
iguana.logError('Rejecting test message from iNTERFACEWARE.')
return true
elseif MsgmsgIn.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 |
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 (boolean) if a message should be filtered (false if it is ok to transmit) |