public static function generate($patient, $provider) { if (!$patient instanceof Patient) { $patientId = (int) $patient; $patient = new Patient(); $patient->personId = $patientId; $patient->populate(); } self::$patient = $patient; if (!$provider instanceof Provider) { $providerId = (int) $provider; $provider = new Provider(); $provider->personId = $providerId; $provider->populate(); } self::$provider = $provider; $building = Building::getBuildingDefaultLocation($provider->personId); self::$providerBuilding = $building; $data = array(); $data[] = self::generateMSH(array('buildingName' => $building->name)); $data[] = self::generateSFT(); $data[] = self::generatePID($patient); $order = new OrderLabTest(); $iterator = $order->getIteratorByPersonId($patient->personId); foreach ($iterator as $orderLabTest) { $data[] = self::generateORC($orderLabTest->order->provider); $result = array(); $result['orderLabTest'] = $orderLabTest; $loinc = new ProcedureCodesLOINC(); $loinc->loincNum = $orderLabTest->labTest; $loinc->populate(); $result['loinc'] = $loinc; $orderId = (int) $orderLabTest->orderId; $labTest = new LabTest(); $labTest->populateByLabOrderId($orderId); $result['labTest'] = $labTest; $data[] = self::generateOBR($result); $labsIterator = new LabsIterator(); $labsIterator->setFilters(array('orderId' => $orderId)); foreach ($labsIterator as $row) { $result['result'] = $row; $data[] = self::generateOBX($result); } $data[] = self::generateSPM($orderLabTest->collectionSample); } return implode("\n", $data); }
public function getLabTestInfoAction() { $labTestId = $this->_getParam('labTestId'); $loinc = new ProcedureCodesLOINC(); $loinc->loincNum = $labTestId; $loinc->populate(); $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $json->suppressExit = true; $json->direct($loinc->toArray()); }
public static function generateOBX(array $data, $raw = false) { static $obxCtr = 1; $loincNum = $data['orderLabTest']->labTest; if (!isset(self::$loincodes[$loincNum])) { $loinc = new ProcedureCodesLOINC(); $loinc->loincNum = $loincNum; $loinc->populate(); self::$loincodes[$loincNum] = $loinc; } if (!isset($loinc)) { $loinc = self::$loincodes[$loincNum]; } $obx = array('OBX'); $obx[1] = $obxCtr++; // OBX‐1: SetID–OBX //$obx[2] = 'NM'; // OBX‐2: Value Type $obx3 = array(); // OBX‐3: Observation ID $obx3[] = $loincNum; // OBX‐3.1: Identifier $obx3[] = $loinc->shortname; // OBX‐3.2: Text //$obx3[] = 'LN'; // OBX‐3.3: Coding System $obx[3] = implode('^', $obx3); $obx[4] = '1'; // OBX‐4: Observation Sub‐ID $obx[5] = $data['result']->value; // OBX‐5: Observation Value $units = $data['result']->units; $unitsOfMeasure = DataTables::$unitsOfMeasure; $tmp = strtoupper($units); $unitsText = isset($unitsOfMeasure[$tmp]) ? $unitsOfMeasure[$tmp] : ''; $obx6 = array(); // OBX‐6: Units $obx6[] = $units; // OBX‐6.1: Identifier $obx6[] = $unitsText; // OBX‐6.2: Text $obx6[] = 'ISO+'; // 'UCUM'; // OBX‐6.3: Coding System if (strlen($units) > 0) { $obx6 = array(); } $obx[6] = implode('^', $obx6); $obx[7] = $data['result']->referenceRange; // OBX‐7: References Range $obx[8] = $data['result']->abnormalFlag; // OBX‐8: Abnormal Flags/Susceptibility $obx[9] = ''; // empty $obx[10] = ''; // empty $obx[11] = $data['result']->resultStatus; // OBX‐11: Observation Result Status $obx[12] = ''; // empty $obx[13] = ''; // empty $obx14 = array(); $obx14[] = date('YmdHiO', strtotime($data['result']->observationTime)); // OBX‐14.1: Date/Time of the Observation $obx[14] = implode('^', $obx14); $obx[15] = ''; // empty $obx[16] = ''; // empty $obx17 = array(); // OBX‐17: Observation Method $obx17[] = $data['result']->identifier; // OBX.17.1: Identifier $obx[17] = implode('^', $obx17); $obx[18] = ''; // empty $obx19 = array(); $obx19[] = date('YmdHiO', strtotime($data['result']->observationTime)); // OBX‐19.1: Date/Time of the Analysis $obx[19] = implode('^', $obx19); // $obx[20] = ''; // empty $obx[21] = ''; // empty $obx[22] = ''; // empty $obx23 = array(); // OBX‐23: Performing Organization Name $obx23[] = 'Lab'; // OBX‐23.1: Organization Name $obx23[] = 'L'; // OBX‐23.2: Organization Name Type Code $obx23[] = ''; // empty $obx23[] = ''; // empty $obx23[] = ''; // empty $obx236 = array(); // OBX‐23.6: Assigning Authority $obx236[] = 'CLIA'; // OBX‐23.6.1: Namespace ID $obx236[] = '2.16.840.1.113883.19.4.6'; // OBX‐23.6.2: Universal ID $obx236[] = 'ISO'; // OBX‐23.6.3: Universal ID Type $obx236 = array(); // temporarily set to an empty value $obx23[] = implode('&', $obx236); // $obx23[] = 'XX'; // OBX‐23.7: Identifier Type Code $obx23[] = ''; // empty $obx23[] = ''; // empty $obx23[] = '1236'; // OBX‐23.10: Organization Identifier $obx23 = array(); // temporarily set to an empty value $obx[23] = implode('^', $obx23); $obx24 = array(); // OBX‐24: Performing Organization Address $obx241 = array(); // OBX‐24.1: Street Address $obx241[] = '3434 Industrial Lane'; // OBX‐24.1.1: Street or Mailing Address $obx24[] = implode('^', $obx241); $obx24[] = ''; // empty $obx24[] = 'Ann Arbor'; // OBX‐24.3: City $obx24[] = 'MI'; // OBX‐24.4: State or Province $obx24[] = '48103'; // OBX‐24.5: Zip Code $obx24[] = ''; // empty $obx24[] = 'B'; // OBX‐24.7: Address Type $obx24 = array(); // temporarily set to empty value $obx[24] = implode('^', $obx24); if ($raw) { return $obx; } return implode('|', $obx); }
public function getDisplayCollectionSample() { $collectionSample = $this->collectionSample; $sampleTypesTable = ProcedureCodesLOINC::sampleTypesTable(); if (isset($sampleTypesTable[$collectionSample])) { $collectionSample = $sampleTypesTable[$collectionSample]; } return $collectionSample; }