4

I've been reading 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?

mario
  • 144,265
  • 20
  • 237
  • 291
a coder
  • 7,530
  • 20
  • 84
  • 131
  • any new tools for this. I have the same problem – userJT Jun 07 '12 at 20:51
  • @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. – a coder Jun 11 '12 at 19:25

4 Answers4

7

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;

                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
DavidRothbauer
  • 123
  • 1
  • 6
  • One of my interfaces uses customized HL7 2.7.. would be interested to see how this handles it. – a coder Nov 10 '14 at 16:27
  • 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 Nov 10 '14 at 16:36
  • 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 Dec 20 '16 at 10:29
  • 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 Dec 24 '16 at 18:33
4

Take a look a the 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.

Mike Stonis
  • 2,184
  • 14
  • 24
3

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 - https://github.com/senaranya/HL7

Aranya Sen
  • 974
  • 8
  • 13
  • 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. – a coder Nov 16 '17 at 17:35
  • 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 Nov 16 '17 at 18:12
  • Maybe a search feature to return segments/field/index values of matches. – a coder Nov 16 '17 at 18:14
  • That's an excellent idea! I'll add it in my to-do list. Thank you – Aranya Sen Nov 16 '17 at 18:18
  • 1
    This is excellent Aranya! Thank you for this PHP contribution. I think this will really help me out. – jjwdesign Oct 11 '18 at 14:05
  • Do we have any solution for php 5 – Pankaj Agrawal Mar 08 '19 at 11:01
  • That library doesn't tackle the most important part which is the formatted Clinical Report. – Jhourlad Estrella Sep 22 '21 at 04:03
-2

You should also have a look at the HL7 Tools Directory at www.HL7.com.au/HL7-Tools.htm

They have a long list of tools, incl php

HTH