Archive for the ‘Python’ Category

Open source HL7 parser

March 19, 2010

I’ve spent the last few days creating the data ingest engine for our application so we can automatically retrieve data from our in-house lab machines. In doing so, I decided to start my own HL7 parser. I did this because I wanted access to fields by field name and not just by list index.  I also wanted to learn the HL7 spec a bit more.

And learn I did! I learned that there all all sorts of flavors of HL7, each home-grown from lab or EMR vendors to suit their own needs.  We have also decided to make this an open-source aspect of our project. I wanted to wait a while to do this, but this video about the pitfalls of trying to make code ‘perfect’ before releasing it helped push this open source move.

The code can be found here:

link

This code is far from complete and we will be adding features as we find a need for them. This system currently is sufficient to ingest blood work data from our LabCorp machines.

 

Edit:

As according to this recent post

http://ankhos.com/2012/10/31/python-hl7-parser-released/

 

Our newly released python HL7 parser can be found here:

https://github.com/norlowski/HL7py

HL7 fields, interoperability

March 9, 2010

I thought I’d quickly share a few of the lessons I’ve learned about parsing HL7 data.  I’m using the python hl7 parser by john paulett.

The first problem I had was with the line endings on my sample file. They must be in \r (carriage return only) for this parser to work.  This is in the hl7 standard, by the way.

hl7 may be a bit confounding at first glance, but it’s actually pretty straighforward once you know the data type labels. Here is a link that explains some of the fields and their names.

Hl7 is basically just a list of information vectors. Each of these vectors has a specific role. For example:  A PID vector  denotes patient identity information, while AL1 denotes a vector containing information about a patient allergy.

I have heard stories of vendors charging upwards fo $6,000 to implement different interfaces in their EMR… something that would take half a day. Atrocious.

Django polymorphism: Mixins vs Inheritance Models

January 15, 2010

Relational databases are not the greatest storage destination for polymorphic data structures (stack overflow). Polymorphism allows you to have heirarchies of objects that perform similar actions. By defining this action once, you can re-use it for its subclasses. It makes code cleaner and easier to maintain. I experimented with a few different ways of doing some of my subclassing and came away with an approach involving mixins that I really like so far.

(more…)

Connectivity implementations

January 11, 2010

We can talk about connectivity and interoperability until the cows come home, but if we don’t have a technical solution for how to actually perform the information transfer, we won’t go very far.

The kinds of technical solutions I am talking about are things like automatic HTTPS POST/GET  transfers, FTP drop-boxes, (gasp) email or any other number of proprietary solutions. Protocol standards like HL7 and others are a level above this discussion.

I don’t have intimate knowledge of the inner-workings of other EMR/EHR  products, so I can only speak for our product. The focus of Ankhos is on office workflow and chemotherapy documentation, not file storage and retrieval. As such, Carolina Oncology Specialists are also implementing an EMR product  for larger-scale file storage. If Ankhos were to generate a patient visit report, it would be necessary to push that report to this archive.  Another source of medical data in the office is the lab equipment. These lab machines currently dump their values via ftp to a pre-defined server on the office intranet. Storing these lab values in this archive and accessing them from Ankhos is a necessity.  Let’s talk about specifics:

(more…)

Why ask Why?

January 4, 2010

Asking questions of yourself and your development process is a very effective and integral part of making good software. I just spent the early morning eating my ritual breakfast of Panera coffee and pastries and I usually bring my (paper)notebook with me to brainstorm and plan my development for the day. I should buy stock in panera.    These mornings are to my project what sleep is to Humans. It helps us index the events of the previous day and helps us prepare for the day to come.

Today, I had a plan to implement many of my doctests into unittests with the Python unittest framework, but got sidetracked… to my delight.  Re-reading some of my notes, I got the urge to ask ‘Why?’   The new year’s weekend had given me sufficient pause to make my notes unfamiliar so I took advantage.  At the end my inquisition I was able to get rid of at least 3 features that were either redundant or not relevant to the project.

(more…)

Design Decision: Python and Django

December 25, 2009

Python is one of the leading professional programming languages in use today. It was the official programming language of my previous employer and, boy, am I glad I had the chance to learn it! C++ is not much of a web language these days. Many people use Java, PHP and Perl for their web programming. These are all fine languages but it is my personal opinion that they are all inferior to Python for this project.

(more…)