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.

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|

Using a VMD file, parse the incoming HL7 messages.

Screen Shot 2024-09-30 at 12.32.04 PM.png

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

Screen Shot 2024-09-30 at 12.34.09 PM.png

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

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: