public function __construct($path_foder) { $list_files = glob($path_foder); foreach ($list_files as $filename) { printf("{$filename} size " . filesize($filename) . " " . date('Ymd H:i:s') . "\n"); if (fopen($filename, "r")) { $myfile = fopen($filename, "r") or die("Unable to open file!"); $hl7 = new HL7(fread($myfile, filesize($filename))); $message = $hl7->get_message(); if ($hl7->valid) { if ($message["PID"][3] == "754258") { echo "message_date : " . $message["MSH"][6] . " "; echo "patient_id : " . $message["PID"][3] . " "; echo "order_number : " . $message["ORC"][2] . " "; echo "transaction_date : " . $message["ORC"][9] . " "; echo "order_comment : " . $message["NTE"][3] . " "; //echo "test_id :".$message["OBX"][3]; มันเป็น array //echo "test_name :".$message["OBX"][3]; มันเป็น array echo "result : " . $message["OBX"][5] . " "; echo "unit : " . $message["OBX"][6] . " "; echo "reference_range : " . $message["OBX"][7] . " "; //echo "validation_date : ".$message["OBX"][15]." "; มันเป็น array //echo "user_id :".$message["OBX"][16]." "; มันเป็น array print_r($message); } //$hn = $message["PID"][3]; //printf("hn = " . $hn . "\n"); fclose($myfile); } else { echo "Unable to read file!"; } } else { echo "Unable to open file!"; } } }
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ require_once './lib/hl7.php'; /** * การอ่านไฟล์ข้อมูลผลแลปผู้ป่วยจาก LIS * 1. อ่านไฟล์ HL7 ผลแลปอยู่ในโฟลเดอร์ * 2. วิเคราะห์ไฟล์แยกส่วนข้อมูลเพื่อสามารถจัดเตรียมนำเข้าฐานข้อมูลได้ * 3. ส่งข้อมูลเข้าฐานข้อมูล * */ $path_filename = "./lis/res/151010206004213.hl7"; try { $hl7 = new HL7($path_filename); print_r($hl7->get_message()); print_r($hl7->segment_count); } catch (Exception $ex) { echo 'Caught exception: ', $ex->getMessage(), "\n"; }
public function saveMsg() { $foo = new stdClass(); $foo->msg_type = $this->type; $foo->message = $this->hl7->getMessage(); $foo->date_processed = date('Y-m-d H:i:s'); $foo->isOutbound = true; $foo->status = 1; // 0 = hold, 1 = processing, 2 = queue, 3 = processed, 4 = error $foo->foreign_address = $this->to['address'] . (isset($this->to['port']) ? $this->to['port'] : ''); $foo->foreign_facility = $this->to['facility']; $foo->foreign_application = $this->to['application_name']; $foo = $this->m->save($foo); $this->msg = (object) $foo['data']; return $this->msg; }
/** * @param null|string $segment * @param bool $all * @return array|bool */ protected function getChildren($segment = null, $all = false) { $children = []; $start = false; $stop = false; $segments = $this->hl7->getSegments(); for ($i = array_search($this, $segments); $i < count($segments); $i++) { if ($stop) { break; } $cls = get_class($segments[$i]); if ($start == false) { $start = $cls == get_class($segments[$i]); continue; } if ($segment == $cls && array_search($cls, $this->children) !== false) { $children[] = $segments[$i]; continue; } $stop = !$all; } return $children; }
/** * @param array $PID * @param HL7 $hl7 * * @return array */ protected function PidToPatient($PID, $hl7) { $p = array(); if ($this->notEmpty($PID[2][1])) { $p['pubpid'] = $PID[2][1]; } // Patient ID (External ID) if ($this->notEmpty($PID[3][1])) { $p['pid'] = $PID[3][1]; } // Patient ID (Internal ID) if ($this->notEmpty($PID[5][2])) { $p['fname'] = $PID[5][2]; } // Patient Name... if ($this->notEmpty($PID[5][3])) { $p['mname'] = $PID[5][3]; } // if ($this->notEmpty($PID[5][1][1])) { $p['lname'] = $PID[5][1][1]; } // if ($this->notEmpty($PID[6][3])) { $p['mothers_name'] = "{$PID[6][2]} {$PID[6][3]} {$PID[6][1][1]}"; } // Mother’s Maiden Name if ($this->notEmpty($PID[7][1])) { $p['DOB'] = $hl7->time($PID[7][1]); } // Date/Time of Birth if ($this->notEmpty($PID[8])) { $p['sex'] = $PID[8]; } // Sex if ($this->notEmpty($PID[9][3])) { $p['alias'] = "{$PID[9][2]} {$PID[9][3]} {$PID[9][1][1]}"; } // Patient Alias if ($this->notEmpty($PID[10][1])) { $p['race'] = $PID[10][1]; } // Race if ($this->notEmpty($PID[11][1][1])) { $p['address'] = $PID[11][1][1]; } // Patient Address if ($this->notEmpty($PID[11][3])) { $p['city'] = $PID[11][3]; } // if ($this->notEmpty($PID[11][4])) { $p['state'] = $PID[11][4]; } // if ($this->notEmpty($PID[11][5])) { $p['zipcode'] = $PID[11][5]; } // if ($this->notEmpty($PID[11][6])) { $p['country'] = $PID[11][6]; } // Country Code if ($this->notEmpty($PID[13][7])) { $p['home_phone'] = "{$PID[13][7]} . '-' . {$PID[13][1]}"; } // Phone Number – Home if ($this->notEmpty($PID[14][7])) { $p['work_phone'] = "{$PID[14][7]} . '-' . {$PID[14][1]}"; } // Phone Number – Business if ($this->notEmpty($PID[15][1])) { $p['language'] = $PID[15][1]; } // Primary Language if ($this->notEmpty($PID[16][1])) { $p['marital_status'] = $PID[16][1]; } // Marital Status //if($this->notEmpty($PID[17])) // $p['00'] = $PID[17]; // Religion if ($this->notEmpty($PID[18][1])) { $p['pubaccount'] = $PID[18][1]; } // Patient Account Number if ($this->notEmpty($PID[19])) { $p['SS'] = $PID[19]; } // SSN Number – Patient if ($this->notEmpty($PID[20][1])) { $p['drivers_license'] = $PID[20][1]; } // Driver’s License Number - Patient if ($this->notEmpty($PID[20][2])) { $p['drivers_license_state'] = $PID[20][2]; } // Driver’s License State - Patient if ($this->notEmpty($PID[20][3])) { $p['drivers_license_exp'] = $PID[20][3]; } // Driver’s License Exp Date - Patient //if($this->notEmpty($PID[21])) // $p['00'] = $PID[21]; // Mother’s Identifier if ($this->notEmpty($PID[22][1])) { $p['ethnicity'] = $PID[22][1]; } // Ethnic Group if ($this->notEmpty($PID[23])) { $p['birth_place'] = $PID[23]; } // Birth Place if ($this->notEmpty($PID[24])) { $p['birth_multiple'] = $PID[24]; } // Multiple Birth Indicator if ($this->notEmpty($PID[25])) { $p['birth_order'] = $PID[25]; } // Birth Order if ($this->notEmpty($PID[26][1])) { $p['citizenship'] = $PID[26][1]; } // Citizenship if ($this->notEmpty($PID[27][1])) { $p['is_veteran'] = $PID[27][1]; } // Veterans Military Status if ($this->notEmpty($PID[27][1])) { $p['death_date'] = $PID[29][1]; } // Patient Death Date and Time if ($this->notEmpty($PID[30])) { $p['deceased'] = $PID[30]; } // Patient Death Indicator if ($this->notEmpty($PID[33][1])) { $p['update_date'] = $hl7->time($PID[33][1]); } // Last update time stamp return $p; }
public static function generateORC(array $data = array(), $raw = false) { $orc = parent::generateORC(array(), true); $orc[2] = ''; // empty $orc[3] = ''; // empty $orc[4] = ''; // empty $orc[5] = ''; // empty $orc[6] = ''; // empty $orc[7] = ''; // empty $orc[8] = ''; // empty $orc[9] = ''; // empty $orc[10] = ''; // empty $orc[11] = ''; // empty $orc12 = array(); // ORC‐12: Ordering Provider $orc12[] = '1234'; // ORC‐12.1: ID Number $orc122 = array(); // ORC‐12.2: Family Name $orc122[] = 'Admit'; // ORC‐12.2.1: Surname $orc12[] = implode('^', $orc122); $orc12[] = 'Alan'; // ORC‐12.3: Given Name $orc12[] = ''; // empty $orc12[] = ''; // empty $orc12[] = ''; // empty $orc12[] = ''; // empty $orc12[] = ''; // empty $orc129 = array(); // ORC‐12.9: Assigning Authority $orc129[] = 'ABC Medical Center'; // ORC‐12.9.1: Namespace ID $orc129[] = '2.16.840.1.113883.19.4.6'; // ORC‐12.9.2: Universal ID $orc129[] = 'ISO'; // ORC‐12.9.3: Universal ID Type $orc12[] = implode('&', $orc129); $orc[12] = implode('^', $orc12); $orc[13] = ''; // empty $orc[14] = ''; // empty $orc[15] = ''; // empty $orc[16] = ''; // empty $orc[17] = ''; // empty $orc[18] = ''; // empty $orc[19] = ''; // empty $orc[20] = ''; // empty $orc21 = array(); // ORC‐21: Ordering Facility Name $orc21[] = 'Level Seven Healthcare'; // ORC‐21.1: Organization Name $orc21[] = 'L'; // ORC‐21.2: Organization Name Type Code $orc21[] = ''; // empty $orc21[] = ''; // empty $orc21[] = ''; // empty $orc216 = array(); // ORC‐21.6: Assigning Authority $orc216[] = 'ABC Medical Center'; // ORC‐21.6.1: Namespace ID $orc216[] = '2.16.840.1.113883.19.4.6'; // ORC‐21.6.2: Universal ID $orc216[] = 'ISO'; // ORC‐21.6.3: Universal ID Type $orc21[] = implode('&', $orc216); $orc21[] = 'XX'; // ORC‐21.7: Identifier Type Code $orc21[] = ''; // empty $orc21[] = ''; // empty $orc21[] = '1234'; // ORC‐21.10: Organization Identifier $orc[21] = implode('^', $orc21); $orc22 = array(); // ORC‐22: Ordering Facility Address $orc221 = array(); // ORC‐22.1; Street Address $orc221[] = '1005 Healthcare Drive'; // ORC‐22.1.1: Street or Mailing Address $orc22[] = implode('^', $orc221); $orc22[] = ''; // empty $orc22[] = 'Ann Arbor'; // ORC‐22.3: City $orc22[] = 'MI'; // ORC‐22.4: State or Province $orc22[] = '48103'; // ORC‐22.5: Zip Code $orc22[] = ''; // empty $orc22[] = 'B'; // ORC‐22.7: Address Type $orc[22] = implode('^', $orc22); $orc23 = array(); // ORC‐23: Ordering Facility Phone Number $orc23[] = ''; // empty $orc23[] = ''; // empty $orc23[] = ''; // empty $orc23[] = ''; // empty $orc23[] = ''; // empty $orc23[] = '734'; // ORC‐23.6: Area/City Code $orc23[] = '5553001'; // ORC‐23.7: Local Number $orc[23] = implode('^', $orc23); $orc24 = array(); // ORC‐24: Ordering Provider Address $orc241 = array(); // ORC‐24.1: Street Address $orc241[] = '4444 Healthcare Drive'; // ORC‐24.1.1: Street or Mailing Address $orc24[] = implode('^', $orc241); $orc24[] = ''; // empty $orc24[] = 'Ann Arbor'; // ORC‐24.3: City $orc24[] = 'MI'; // ORC‐24.4: State or Province $orc24[] = '48103'; // ORC‐24.5: Zip Code $orc24[] = ''; // empty $orc24[] = 'B'; // ORC‐24.7: Address Type $orc[24] = implode('^', $orc24); if ($raw) { return $orc; } return implode('|', $orc); }
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ require_once './orr_lib/hl7.php'; /** * การอ่านไฟล์ข้อมูลผลแลปผู้ป่วยจาก LIS * 1. อ่านไฟล์ HL7 ผลแลปอยู่ในโฟลเดอร์ * 2. วิเคราะห์ไฟล์แยกส่วนข้อมูลเพื่อสามารถจัดเตรียมนำเข้าฐานข้อมูลได้ * 3. ส่งข้อมูลเข้าฐานข้อมูล * */ $path_filename = "./ext/lis/res/151010206004213.hl7"; try { $hl7 = new HL7($path_filename); print_r($hl7->segment_count); $message = $hl7->get_message(); //print_r($message); $result = array(); /** * คำสั่งคัดเฉพาะ secment ที่ต้องการ */ foreach ($message as $key => $value) { if ($value->name = 'OBX') { $result[] = $value; } } print_r($result); } catch (Exception $ex) { echo 'Caught exception: ', $ex->getMessage(), "\n";