Luke Leighton's refactoring of hl7.py

John Paulett's excellent work has been enhanced, among other things, with a python-style interface of properties. This makes it possible – in place of hl7.PID[3][0] – to do this:

p = hl7.PID
print "patient", p.patient_id_internal_id, \
p.patients_name.family_name,
p.patients_name.given_name

Different versions of hl7 have different, sometimes incompatible, names for fields. The currently-enhanced code makes use of mirthcorp.com-published HL7 specifications (in XML file format) to create revision-dependent segment and field parsers. The names of the properties are auto-generated directly from mirthcorp's XML specifications:

  • ORCs are matched with ORBs via the filler order number, so it is possible to do "hl7.ORC[0].ORB"
  • ORCs and ORBs are both given a property of OBX, so it is possible to do "hl7.ORC[0].ORB.OBX[3]"
  • NTEs are also supported, if they exist

HL7v3 revisions 2.1, 2.2, 2.3, 2.31, 2.4 and 2.5 are supported.

Mirth, while highly capable, does force a dependency on java and javascript for scripting, which may not suit everyone's needs, hence creation of this smaller library, in python. Even one person can keep the hl7 python module relevant and up-to-date with the latest HL7 specifications, so long as mirthcorp continues to publish the XML files.

There is still work to be carried out: MSH, PID, NTE, ORC, ORB and OBX are the presently supported segments with a hard-coded assumption about the data hierarchy (sufficient for lab data import) instead of using the same MessageFormat specifications that mirthcorp.com have written. Support for other MessageFormats could be a next step.

Announcements:

Code and reference to the auto-generation:

Topic revision: 08 Jul 2011, JamesBusser
 
Download.png
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback
Powered by Olark