Skip to main content

Mapping HL7 to Database

Here's an example of mapping HL7 messages to a database table using best practices. IguanaX also provides a pre-built HL7 to Database component to help get you started.

STEP 1: Add in Sample Data

See Sample Data for more information on adding and how to use it in the Translator.

Here's a sample ADT message to test with:

MSH|^~\&|AcmeMed|E\T\R|Main HIS|St. Micheals|20110213145956||ADT^A07|9B38584DCB03B0577D55CF66983BA79B39022ABD61F9E0188DD9BD03B2C99446|P|2.6|   
EVN||20110213144818||||20110213144552|
PID|||2495499^^^ADT1||Meade^Sabrina||20001005|F||Martian|207 Miller Lane^^Toronto^ON^16200|||||||7-264-942|365-5-488|
NK1|1|Garland^Sabrina|Second Cousin|
NK1|2|Smith^Fred|Grandchild|
NK1|3|WHITE^Tracy|Grandchild|
NK1|4|Fitzgerald^John|Grandchild|
NK1|5|Adams^Mary|Parent|
PV1||E||||||5101^WHITE^Tracy^F^^DR|||||||||||602131^^^ADT1|||||||||||||||||||||||||20110213150128|
OBX|||WT^WEIGHT||82|pounds|
OBX|||HT^HEIGHT||103|cm|

STEP 2: Parse the HL7 message

Using a VMD file, parse the incoming HL7 messages.

STEP 3: Create a VDB file

A VDB file is used to create a staging table mirroring the database.

STEP 4: Create a mapping module

Add in a separate mapping.lua file to map the HL7 data into the schema. See Structuring Component Translators for more info.

Create functions to map out patient and kin tables

STEP 5: Map the HL7 data into the schema

In the main.lua, call your mapping functions and pass through the parsed HL7 message (P) and the database schema (T):

Map the HL7 data to your VDB generated tables. Take a look at the following sample mapping:

STEP 6: Connect to the database

Iguana connects to the database and the staging table is merged with the database table to insert a new row of HL7 data.