HL7 parser / writer for PHP

I read HL7 files with a home script, but I'm looking for something a little more reliable. I checked the Net_HL7 Pear module, but there is no documentation, and since 2009 it does not look without updates.

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

+5
source share
4 answers

I know this is an old thread, but I was working on a PHP class to work with HL7.

I wonder what features people will want.

My class allows me to split the HL7v2.x message into a multidimensional array.

I am working on some common things, such as getting the patient’s full name and finding the location of the string.

, . MSH.2, .

.

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;

                exit;

            }

            $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 {
                       $j=0;

                       $sf = explode(FLD_SEP,$seg);

                       foreach($sf as $f) {



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

                           $j++;

                       }


                   }

                   $i++;
               }
            }

                    //define('PT_NAME',$out['PID'][5][0],true);

                    return $out;


                } //end parsemsg
+6
+4
+1

All Articles