HL7 servers in Python?

Richard Sharp rbsharp at gmx.de
Mon Jun 16 17:29:22 CEST 2003

On Fri, 13 Jun 2003 07:10:26 +1000, Tim Churches wrote:

> Does anyone know of a Python HL7 socket server/daemon - that is, a
> daemon which accepts socket connections on a TCP port from an HL7
> source, receives an HL7 message via the connection, hands off the
> message for processing, and then sends back an ACK or NACK H7 message -
> usually synchronously, via a blocking connection (thus the server needs
> to be multi-threaded)?
> HL7 stands for Health Level 7 (where 7 represents the 7th layer of the
> OSI network stack) and is a widely-used standard for communication of
> medical information. I'm not looking for HL7 message assembly or parsing
> libraries, just the socket server bit. Perhaps the SocketServer module
> in the Python library makes this so trivial that no-one has felt the
> need to write a specific HL7 server in Python? Anyway, I've looked on
> Google but can't spot anything obvious.

It is extremely doubtful, given the specialised nature of the question,
whether most people understand what you want. Given that HL7 is really
only sending and receiving some information in a curious format, and that
you either receive data and then send the other side an ACK or a NAK, or
wait until they do that in reply to your message, it is really not all
that complicated.

The short answer to you question ist Twisted -

What may confuse you is that it does not use blocking sockets and
therefore does not need to be multithreaded, although I think it can be,
but it does work.

My bread and butter Python work is software that interfaces between a
Pathology System running any number of versions of Unix and some
overarching Hospital System that provides me with patient data and to
which I deliver reports and accounting data, mostly, but not always, in

I have one Pathology Unit that does work for two hospitals and
communicates with two hospital systems. With Twisted I basically subclass
protocol.Factory and implement the necessary submethods.

It is a little daunting at first and there was at the time (about 2 years
ago) when no usable documentation worth speaking of was available. I am
also stuck at the moment with Twisted 0.18.0, because it runs with Python
1.5.2, and I had trouble getting Python >= 2.0 running on the all the
Unixes I had to get it running on. In the meantime, I think I've got that
under control.

If you're interested in looking at the programms I will have to ask the
company I developed the software for, but the complete program is only ca.
800 Lines and covers 4 Low Level Protocols.

I hope I have been of some help. Once people realise that what you want is
some sort of select-loop-server, then they will probably gush forth with
helpful suggestions.


Richard Sharp

More information about the Python-list mailing list