HL7 is a communication protocol and message format for health care data. It is the de facto standard for transmitting data between clinical information systems and between clinical devices. The version 2.x series, which is often is a pipe delimited format is currently the most widely accepted version of HL7 (version 3.0 is an XML-based format).
The current implementation of python-hl7 does not completely follow the HL7 specification, but is good enough to parse the most commonly seen HL7 messages. The library could potentially evolve into being fully complainant with the spec. The library could eventually also contain the ability to create HL7 v2.x messages.
As an example, let's create a HL7 message:
>>> message = 'MSH|^~\&|GHH LAB|ELAB-3|GHH OE|BLDG4|200202150930||ORU^R01|CNTRL-3456|P|2.4\r'
>>> message += 'PID|||555-44-4444||EVERYWOMAN^EVE^E^^^^L|JONES|196203520|F|||153 FERNWOOD DR.^^STATESVILLE^OH^35292||(206)3345232|(206)752-121||||AC555444444||67-A4335^OH^20030520\r'
>>> message += 'OBR|1|845439^GHH OE|1045813^GHH LAB|1554-5^GLUCOSE|||200202150730||||||||555-55-5555^PRIMARY^PATRICIA P^^^^MD^^LEVEL SEVEN HEALTHCARE, INC.|||||||||F||||||444-44-4444^HIPPOCRATES^HOWARD H^^^^MD\r'
>>> message += 'OBX|1|SN|1554-5^GLUCOSE^POST 12H CFST:MCNC:PT:SER/PLAS:QN||^182|mg/dl|70_105|H|||F\r'
We call the hl7.parse() command with string message:
>>> import hl7
>>> h = hl7.parse(message)
We get a n-dimensional list back:
There were 4 segments (MSH, PID, OBR, OBX):
We can extract individual elements of the message:
We can look up segments by the segment identifer:
>>> pid = hl7.segment('PID', h)
python-hl7 will work with Python 2.5, 2.6, and 3.0. It is under a BSD license.
The easiest way to obtain the package is with easy_install
An egg and tar.gz file can be downloaded from PyPi
You can always clone or fork the source:
hg clone http://bitbucket.org/johnpaulett/python-hl7/
Thsi looks great. What about v3 support? Do you know of a python lib for that?
Ben, thanks. I've played around with converting python-hl7 to Python 3 and the task is pretty trivial using 2to3. At some point I plan to create an official 3 branch, I was just wanting for an impetus to do so. Let me know if you are interested
@John I think Ben meant HL7 v3 not Python 3. HL7 v3 is xml-based and cannot be parsed with the current version of python-hl7.
Sorry I am late to the party. HL7 v3v3 will be XML-like. A python XML parser should work.
Professor of Analytics Michael Magazine has crunched the numbers, and agreed that blackjack is finest way|one of the only ways|the best way} to go home with money in your pockets. He mentioned if you somewhat time|take a while|take some time} to study the sport, 토토사이트 you have have} the best odds of successful. The Craps desk normally a|could be a} bit intimidating for the beginner with all the packing containers on the desk, Bean admitted.
Post a Comment