Analizador / escritor HL7 para PHP

He estado leyendo HL7 files with a home grown script, but am looking for something a little more robust. I've checked out the Net_HL7 Pear module, but there is no documentation and it looks like no updates since 2009.

Is there anything new on the market (commercial or open source) available for working with HL7 via PHP?

preguntado el 01 de febrero de 12 a las 22:02

any new tools for this. I have the same problem -

@user56 - I haven't found anything new since the OP. Still using a custom script to read the messages. If you locate something useful, please post back. -

4 Respuestas

I know this is an old thread, but I've been working on a PHP class for working with HL7.

I'm wondering what sort of functionality people would want.

My class allows you to break an HL7v2.x message into a multidimensional array.

I'm working on some common things like getting the patient's full name, and finding the location of a string.

This is the basic function that breaks down the message. It uses the encoding characters in MSH.2, however I haven't gone beyond the carat.

I also need to write the handler for repeating sub segments.

function parsemsg($string) {

    $segs = explode("\n",$string);

    $out = array();       

            //get delimiting characters

            if (substr($segs[0],0,3) != 'MSH') {

                $out['ERROR'][0] = 'Invalid HL7 Message.';
                $out['ERROR'][1] = 'Must start with MSH';

                return $out;



            $delbarpos = strpos($segs[0],'|',4);  //looks for the closing bar of the delimiting characters

            $delchar = substr($segs[0],4,($delbarpos - 4));

            define('FLD_SEP', substr($delchar,0,1));
            define('SFLD_SEP', substr($delchar,1,1));
            define('REP_SEP', substr($delchar,2,1));
            define('ESC_CHAR', substr($delchar,3,1));

            foreach($segs as $fseg) {

                $segments = explode('|',$fseg);

                $segname = $segments[0];
                $i = 0;
               foreach ($segments as $seg) {

                   if (strpos($seg,FLD_SEP) == false) {

                       $out[$segname][$i] = $seg;

                   } else {

                       $sf = explode(FLD_SEP,$seg);

                       foreach($sf as $f) {

                           $out[$segname][$i][$j] = $f;






                    return $out;

                } //end parsemsg

respondido 10 nov., 14:18

One of my interfaces uses customized HL7 2.7.. would be interested to see how this handles it. - un codificador

I do a lot of custom work too, only in the Mirth Integration Engine that we use at the hospital where I work. The PHP stuff is for a side project. Be interested to hear your requirements - DavidRothbauer

Did you finish your HL7 library? Seems like there is still no comprehensive HL7 library for PHP, just the basic implementations such as the one by PEAR - mickadoo

The project fell off my radar after couple of tumultuous years. Moving into the consulting world has exposed me to a variety of engines, some of which are simply terrible. Your post popped up in my notifications was timely as I was wondering what platform to base a suite of HL7 tools on. Eventually these tools would allow users to build a custom HL7 engine. I'll start by providing a PHP class and a JQuery plugin and go from there. - DavidRothbauer

Echa un vistazo al Net_HL7 repository on github. This looks like there has been some recent activity.

If you want to do more than just some simple parsing, your best bet may be to use an interface engine, such as Mirth Connect, and then interface the messages between your application using web services or a database.

Respondido 02 Feb 12, 19:02

I know this is an old thread, but if someone is still looking for a HL7 package for PHP, here is one I've developed recently -

respondido 16 nov., 17:16

Thanks, are there plans to do more than take pre-assembled segments and write out a file? Just wondering why I wouldn't do that with native PHP vs using this class. - un codificador

There is already quite a lot you can do - 1) Parse pre-assembled HL7, and read values using methods like getSegmentsByName('PID'), getSegmentsByIndex(4), getField(3) etc. 2) Construct new HL7 using addSegment(), setSegment($obr, 3), setField(1, 'AB Rad') etc. 3) Send HL7 to a specific port/IP using socket I'm yet to document all available methods, but I'll do that soon, along with examples. I'll continue to add more functionality, e.g., getter methods to read specific data - getOutsidePID(), getProcedureCode() etc. and more validation. Suggestion are most welcome :) - Aranya Sen

Maybe a search feature to return segments/field/index values of matches. - un codificador

That's an excellent idea! I'll add it in my to-do list. Thank you - Aranya Sen

This is excellent Aranya! Thank you for this PHP contribution. I think this will really help me out. - jjwdesign

You should also have a look at the HL7 Tools Directory at

They have a long list of tools, incl php


Respondido 04 Feb 12, 05:02

Alt-F'ing that page isn't showing any php related tools. Did you know of one in particular? - un codificador

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.