我知道这是一个旧线程,但我一直在研究一个用于处理HL7的PHP类.
我想知道人们会想要什么样的功能.
我的类允许您将HL7v2.x消息分解为多维数组.
我正在研究一些常见的事情,例如获取患者的全名,以及找到字符串的位置.
这是分解消息的基本功能.它使用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