Skip to main content

Python library parsing HL7 v2.x messages

Project description

Simple library for parsing messages of Health Level 7 (HL7) version 2.x.

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).

python-hl7 currently only parses HL7 version 2.x messages into an easy to access data structure. The current implementation 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
'
>>> 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
'
>>> 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
'
>>> message += 'OBX|1|SN|1554-5^GLUCOSE^POST 12H CFST:MCNC:PT:SER/PLAS:QN||^182|mg/dl|70_105|H|||F
'
We call the hl7.parse() command with string message:
>>> h = parse(message)

We get a n-dimensional list back:

>>> type(h)
<type 'list'>

There were 4 segments (MSH, PID, OBR, OBX):

>>> len(h)
4

We can extract individual elements of the message:

>>> h[3][3][1]
'GLUCOSE'
>>> h[3][5][1]
'182'

We can look up segments by the segment identifer:

>>> pid = segment('PID', h)
>>> pid[3][0]
'555-44-4444'

Project site: http://www.bitbucket.org/johnpaulett/python-hl7/wiki/Home

HL7 References:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hl7-0.0.3.tar.gz (3.6 kB view details)

Uploaded Source

Built Distributions

hl7-0.0.3.win32.exe (68.9 kB view details)

Uploaded Source

hl7-0.0.3-py2.6.egg (6.9 kB view details)

Uploaded Source

hl7-0.0.3-py2.5.egg (6.9 kB view details)

Uploaded Source

File details

Details for the file hl7-0.0.3.tar.gz.

File metadata

  • Download URL: hl7-0.0.3.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for hl7-0.0.3.tar.gz
Algorithm Hash digest
SHA256 0901dcbf5352b62afee3983704b0be7e470a4bfb33f6f1dbf373b97bad0b32ab
MD5 2b403b63de810d891bb556d2b2cf2920
BLAKE2b-256 4a30203f6386e9ab5002fae239a2596b70f410507bf8955a5736284a6250456d

See more details on using hashes here.

File details

Details for the file hl7-0.0.3.win32.exe.

File metadata

  • Download URL: hl7-0.0.3.win32.exe
  • Upload date:
  • Size: 68.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for hl7-0.0.3.win32.exe
Algorithm Hash digest
SHA256 0e1009f0b62c5243263c6d0a4a0afc503bfe2fcda51b69ef75a0aae1d775ff4f
MD5 19fe9243bb162d3bcee9348028f1d1ac
BLAKE2b-256 dd394314455b5706e7c183da964e7160368901b3843dfe1c29fb7325991ba3ae

See more details on using hashes here.

File details

Details for the file hl7-0.0.3-py2.6.egg.

File metadata

  • Download URL: hl7-0.0.3-py2.6.egg
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for hl7-0.0.3-py2.6.egg
Algorithm Hash digest
SHA256 858ba4b808f98c8d2d26bcf1656853abb8fdb53f67a01c7bd11ebd82b72607e6
MD5 b64bc3c2206f34738dae1db32707faee
BLAKE2b-256 d140a4665793c033b704454428eecd1d2a2c07f3903506b2a4d196a79cb4455f

See more details on using hashes here.

File details

Details for the file hl7-0.0.3-py2.5.egg.

File metadata

  • Download URL: hl7-0.0.3-py2.5.egg
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for hl7-0.0.3-py2.5.egg
Algorithm Hash digest
SHA256 dcb1ab08aaeba4dc165d2b33c0ae746357b648911fa61e10c147f1458409d5ab
MD5 5d656d509a5d75db61bfb3c5bec3685f
BLAKE2b-256 9cb51acd64a62d4f07329ddb26259d63fb4c82734430afbfcd07ab6ac392b5b7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page