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?
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