HL7 to Database

Mapping: MapData() filtering

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.

  1. Call FilterMessage() to check for Catchall (unknown) messages
  2. 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 to MapData()

      Tip: You might wonder why we don’t simply filter on the Name returned from hl7.parse{}, given that that this would make the code simpler (and we are always espousing minimalism and simpler code)Using Name like this instead of Msg would look like this:The reason is simple but subtle: Using the Msg is more versatile, we can filter on any information in the MSH segment, i.e., you could filter out test messages from “iNTERFACEWARE”.
  3. When MapData() identifies a Catchall message (true returned from FilterMessage())
    • 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
  4. The main() function only processes valid messages, so when it receives a nil return from MapData() it does nothing.
  5. 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

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.