Skip to main content

HL7MAP Library

The HL7MAP Library is an importable library containing functions that help you dynamically call mapping and filtering functions for complex HL7 mapping and filtering. This library is used in the HL7 to HL7 Map component.

How to use it:

STEP 1: Import the HL7MAP library into your component Translator

Import the HL7MAP library into the Translator using the button.

Typically only the HL7MAPinit module needs to be required in order to initialize the library and access the methods.

require "HL7MAP.HL7MAPinit"   

STEP 2: Initialize the HL7MAP library with your mapping and/or filtering directories

Call HL7MAPinit in your script to initialize the library object and configure the mapping and/or filtering directories that the object will use to call mapping and/or filtering modules. For example:

local H = HL7MAPinit{filter_dir=’filters’,mapping_dir=’mappings’}   

STEP 3: Add filtering modules

Add message-specific filter modules in the specified filters directory. The modules should be named [HL7_Type].lua. There should also be a default.lua to handle default filter conditions.

Messages with an inbound HL7 message type (ex. ADTA01) that matches the name of a filtering module (ex. ADTA01.lua) will be filtered by that module. All other messages will be filtered by the default filter conditions default.lua, which can also be further customized .

STEP 4: Add mapping modules

Add mapping modules in the specified mapping directory. The modules should be named [HL7_Type].lua.

By default, only messages with an outbound HL7 message type (ex. ADTA01) that matches the name of a mapping module (ex. ADTA01.lua) will be mapped. All other messages will be pushed downstream in their original form.

Any codemap-related modules can also be stored in this directory.

How it works:

HL7MAPinit - sets up the library framework and loads the specified filter and/or mapping directories

Sets up the HL7MAP library framework, adding the method modules to a metatable and storing the provided mapping and filter directories. The library can be used for filtering alone, mapping alone, or both filtering and mapping.

The directory paths are also used in require statements for the appropriate modules, so they should be based on the syntax used to call those modules directly. For example, let's say we want to use the mappings folder inside the configurations folder:

We would now initialize our library object like so:

local H = HL7MAPinit{mapping_dir=’configurations.mappings’}   

The methods dynamically call the correct mapping or filtering module based on the provided arguments:

HL7MAPbuild - calls the appropriate mapping module

HL7MAPbuild takes the provided out_message_type (ex. ADTA01) and calls the matching mapping module in the specified mapping directory (ex. mappings/ADTA01.lua). It passes the provided outbound VMD file ( out_vmd) and inbound message ( in_message) to the mapping module, which will build and map the outbound message.

HL7MAPfilter - calls the appropriate filtering module

HL7MAPfilter takes the provided in_message_type (ex. ADTA01) and calls the matching filtering module in the specified filter directory (ex. filters/ADTA01.lua). If a matching filtering module is not found and a default filter (ex. filters/default.lua) is available, it calls the default filtering module instead. By default, only Catchall messages are filtered.