The parser is divided into two parts:
- Low-level functions that implement a tokenizer, lexer, parser, callback (SAX-like) parser for the HL7 protocol.
- Custom segment accessors (code-generated by
hl7segdef.py
).
This HL7 parser was designed for a memory-constrained hardware environment and thus avoids allocating memory as much as possible. This makes its interface weird at times, and care must be taken to avoid overwriting memory that is in use by a message (e.g. modifying a parsed buffer while the resulting message is still in use).
The HL7 parser has no runtime dependency other than the standard C library, but it requires qmake from the Qt project to generate its makefiles.
To install qmake in Ubuntu/Debian you can run:
apt-get install libt4-dev qt4-qmake
Then run:
cd hl7parser
./configure
make
sudo make install
sudo ldconfig
This will install the dynamic libraries and headers for the project in
/usr/local
. You can test the behavior of the library by using the
following programs:
bin/test_lexer
bin/test_cbparser
bin/test_parser
bin/test_segment
The segment accessors are defined in an XML file (hl7segdef.xml
) and are
auto-generated by a Python script (hl7segdef.py
). The code used to access
the segments is already included in the project (see the src/seg_*.c
and
the include/hl7parser/seg_*.h
files). If you need to modify the segment
definitions, just remove these files, modify the XML file and run the script
like this:
python ./hl7segdef.py <file name>