Mapping: MapData() filtering
Contents
MapData()
uses FilterMessage()
to filter our unknown messages. The call to FilterMessage()
detects when unknown messages are sent through the Iguana channel.
Note: You can also filter on other criteria in the HL7 header (MSH segment), i.e., you could filter out messages from certain hospitals.
Before You Start
The demo.vmd file contains a default message definition, Catchall, which matches all messages that are not Lab or ADT messages.
This is a screenshot of the Catchall message in Chameleon. See understanding VMD files for more information.
Note: If we want to process another type of message (ORM for example), then we can add a new message definition to the VMD.
How It Works
We don’t want to process unknown (“Catchall”) messages. When MapData()
finds a Catchall message it filters it out and returns nil to main()
which prevents the message from being processed.
- Call
FilterMessage()
to check for Catchall (unknown) messages - When
FilterMessage()
finds a Catchall message- It calls
ReportFilter()
to log an error message “Unexpected message type.”Note: Two messages are logged for Each Catchall message as
MapData()
also logs an error. FilterMessage()
then returns true toMapData()
Tip: You might wonder why we don’t simply filter on the Name
returned fromhl7.parse{}
, given that that this would make the code simpler (and we are always espousing minimalism and simpler code)UsingName
like this instead ofMsg
would look like this:The reason is simple but subtle: Using theMsg
is more versatile, we can filter on any information in the MSH segment, i.e., you could filter out test messages from “iNTERFACEWARE”.
- It calls
- When
MapData()
identifies a Catchall message (true returned fromFilterMessage()
)- It logs an error “Filtering message.”
Note: Two messages are logged for Each Catchall message as
ReportFilter()
also logs an error. - Then it returns nil to
main()
to indicate there is no valid message to process
- It logs an error “Filtering message.”
- The
main()
function only processes valid messages, so when it receives a nil return fromMapData()
it does nothing. - Finally if a valid message is found then
MapData()
calls a function to map the data- For Lab message the
ProcessLab()
function is called - For ADT messages the
ProcessADT()
function is called
- For Lab message the
Next Step?
Now you understand how the MapData()
filters unknown messages. Since the sample data for this tutorial is matched by ADT, the script next calls ProcessADT()
, therefore the the next thing we look at will be the ProcessADT()
function.