Esempio n. 1
0
 function sendVXU($params)
 {
     try {
         // set these globally to be used by MSH and PID
         $this->to = $params->to;
         $this->from = $params->from;
         $this->patient = $params->pid;
         $this->encounter = isset($params->eid) ? $params->eid : 0;
         $this->type = 'VXU';
         // MSH
         $msh = $this->setMSH();
         $msh->setValue('9.1', 'VXU');
         $msh->setValue('9.2', 'V04');
         $msh->setValue('9.3', 'VXU_V04');
         // PID
         $this->setPID();
         // PV1
         $this->setPV1();
         // Variable Objects to pass filter to MatchaCup
         $filters = new stdClass();
         $filters->filter[0] = new stdClass();
         $filters->filter[1] = new stdClass();
         // Load the List option model, to do lookups in the Value Code Sets
         $ListOptions = MatchaModel::setSenchaModel('App.model.administration.ListOptions');
         // PD1 - 3.4.10 PD1 - Patient Additional Demographic Segment
         // If the Publicity is set, on the patient contacts compile this HL7 Message line
         $filters = new stdClass();
         $filters->filter[0] = new stdClass();
         $filters->filter[1] = new stdClass();
         $filters->filter[0]->property = 'pid';
         $filters->filter[0]->value = $this->patient->pid;
         $filters->filter[1]->property = 'relationship';
         $filters->filter[1]->value = 'SEL';
         $ContactRecord = $this->PatientContacts->load($filters)->one();
         if ($this->notEmpty($ContactRecord)) {
             $PD1 = $this->hl7->addSegment('PD1');
             $filters->filter[0]->property = 'list_id';
             $filters->filter[0]->value = 132;
             $filters->filter[1]->property = 'code';
             $filters->filter[1]->value = $ContactRecord->publicity;
             $Record = $ListOptions->load($filters)->one();
             $PD1->setValue('11.1', $Record['option_value']);
             $PD1->setValue('11.2', $Record['option_name']);
             $PD1->setValue('11.3', $Record['code_type']);
             $PD1->setValue('16', 'A');
             $PD1->setValue('17', $this->date($this->patient->create_date, false));
             $PD1->setValue('18', $this->date($this->patient->create_date, false));
         }
         // NK1 - 3.4.5 NK1 - Next of Kin / Associated Parties Segment
         $filters->filter[0]->property = 'pid';
         $filters->filter[0]->value = $params->pid;
         $filters->filter[1] = new stdClass();
         $Records = $this->PatientContacts->load($filters)->all();
         $transactionID = 0;
         foreach ($Records as $Record) {
             $transactionID++;
             $PD1 = $this->hl7->addSegment('NK1');
             $PD1->setValue('1', $transactionID);
             $PD1->setValue('2.1', $Record['middle_name'] . ' ' . $Record['last_name']);
             $PD1->setValue('2.2', $Record['first_name']);
             $PD1->setValue('2.7', 'L');
             $PD1->setValue('3.1', $Record['relationship']);
             $filters->filter[0]->property = 'list_id';
             $filters->filter[0]->value = 134;
             $filters->filter[1]->property = 'option_value';
             $filters->filter[1]->value = $Record['relationship'];
             $List = $ListOptions->load($filters)->one();
             $PD1->setValue('3.2', $List['option_name']);
             $PD1->setValue('3.3', $List['code_type']);
             $PD1->setValue('4.1', $Record['street_mailing_address']);
             $PD1->setValue('4.3', $Record['city']);
             $PD1->setValue('4.4', $Record['state']);
             $PD1->setValue('4.5', $Record['zip']);
             $PD1->setValue('4.6', $Record['country']);
             $PD1->setValue('4.7', 'L');
             $PD1->setValue('5.2', 'PRN');
             $PD1->setValue('5.3', 'PH');
             $PD1->setValue('5.6', $Record['phone_area_code']);
             $PD1->setValue('5.7', $Record['phone_local_number']);
         }
         $this->i = MatchaModel::setSenchaModel('App.model.patient.PatientImmunization');
         include_once ROOT . '/dataProvider/Immunizations.php';
         include_once ROOT . '/dataProvider/Services.php';
         $immunization = new Immunizations();
         $EncounterServices = new Services();
         // Immunizations loop
         foreach ($params->immunizations as $i) {
             $immu = $this->i->load($i)->one();
             // ORC - 4.5.1 ORC - Common Order Segment
             $ORC = $this->hl7->addSegment('ORC');
             $ORC->setValue('1', 'RE');
             //HL70119
             $ORC->setValue('3.1', 'GAIA10001');
             $ORC->setValue('3.2', $immu['id']);
             // RXA - 4.14.7 RXA - Pharmacy/Treatment Administration Segment
             $RXA = $this->hl7->addSegment('RXA');
             $RXA->setValue('3.1', $this->date($immu['administered_date']));
             //Date/Time Start of Administration
             $RXA->setValue('4.1', $this->date($immu['administered_date']));
             //Date/Time End of Administration
             //Administered Code
             $RXA->setValue('5.1', $immu['code']);
             //Identifier
             $RXA->setValue('5.2', $immu['vaccine_name']);
             //Text
             $RXA->setValue('5.3', $immu['code_type']);
             //Name of Coding System
             if ($this->isPresent($immu['administer_amount'])) {
                 $RXA->setValue('6', $immu['administer_amount']);
                 //Administered Amount
                 $RXA->setValue('7.1', $immu['administer_units']);
                 //Identifier
                 $RXA->setValue('7.2', $immu['administer_units']);
                 // Text
                 $RXA->setValue('7.3', 'UCUM');
                 //Name of Coding System HL70396
             } else {
                 $RXA->setValue('6', '999');
                 //Administered Amount
             }
             $RXA->setValue('15', $immu['lot_number']);
             //Substance LotNumbers
             // get immunization manufacturer info
             $mvx = $immunization->getMvxByCode($immu['manufacturer']);
             $mText = isset($mvx['manufacturer']) ? $mvx['manufacturer'] : '';
             //Substance ManufacturerName
             $RXA->setValue('17.1', $immu['manufacturer']);
             //Identifier
             $RXA->setValue('17.2', $mText);
             //Text
             $RXA->setValue('17.3', 'MVX');
             //Name of Coding System HL70396
             $RXA->setValue('21', 'A');
             //Action Code
             // RXR - 4.14.2 RXR - Pharmacy/Treatment Route Segment
             $RXR = $this->hl7->addSegment('RXR');
             // Route
             $filters->filter[0]->property = 'list_id';
             $filters->filter[0]->value = 6;
             $filters->filter[1]->property = 'option_value';
             $filters->filter[1]->value = $immu['route'];
             $Record = $ListOptions->load($filters)->one();
             $RXR->setValue('1.1', $Record['option_value']);
             $RXR->setValue('1.2', $Record['option_name']);
             $RXR->setValue('1.3', $Record['code_type']);
             // Administration Site
             $filters->filter[0]->property = 'list_id';
             $filters->filter[0]->value = 119;
             $filters->filter[1]->property = 'code';
             $filters->filter[1]->value = $immu['administration_site'];
             $Record = $ListOptions->load($filters)->one();
             $RXR->setValue('2.1', $Record['option_value']);
             $RXR->setValue('2.2', $Record['option_name']);
             $RXR->setValue('2.3', $Record['code_type']);
             // OBX - 7.4.2 OBX - Observation/Result Segment
             $filters->filter[0]->property = 'eid';
             $filters->filter[0]->value = $immu['eid'];
             $filters->filter[1]->property = 'pid';
             $filters->filter[1]->value = $immu['pid'];
             $Records = $EncounterServices->getEncounterServicesByEIDandPID($filters);
             $obxCount = 1;
             foreach ($Records as $Record) {
                 $OBX = $this->hl7->addSegment('OBX');
                 $OBX->setValue('1', $obxCount);
                 $OBX->setValue('2', 'CE');
                 $OBX->setValue('3.1', '64994-7');
                 $OBX->setValue('3.2', 'Vaccine funding program eligibility category');
                 $OBX->setValue('3.3', 'LN');
                 $OBX->setValue('4', $Record['eid']);
                 $OBX->setValue('5.1', $Record['financial_class']);
                 $OBX->setValue('5.2', $Record['financial_name']);
                 $OBX->setValue('5.3', $Record['code_type']);
                 $OBX->setValue('11', 'F');
                 $OBX->setValue('17.1', 'VXC40');
                 $OBX->setValue('17.2', 'Eligibility captured at the immunization level');
                 $OBX->setValue('17.3', 'CDCPHINVS');
                 $obxCount++;
             }
             $OBX = $this->hl7->addSegment('OBX');
             $OBX->setValue('1', $obxCount);
             $OBX->setValue('2', 'CE');
             $OBX->setValue('3.1', '30956-7');
             $OBX->setValue('3.2', 'vaccine type');
             $OBX->setValue('3.3', 'LN');
             $OBX->setValue('4', $immu['id']);
             $OBX->setValue('5.1', $immu['code']);
             $OBX->setValue('5.2', $immu['vaccine_name']);
             $OBX->setValue('5.3', $immu['code_type']);
             $OBX->setValue('11', 'F');
             $obxCount++;
             $OBX = $this->hl7->addSegment('OBX');
             $OBX->setValue('1', $obxCount);
             $OBX->setValue('2', 'TS');
             $OBX->setValue('3.1', '29768-9');
             $OBX->setValue('3.2', 'Date vaccine information statement published');
             $OBX->setValue('3.3', 'LN');
             $OBX->setValue('4', $immu['id']);
             $OBX->setValue('5', $this->date($immu['education_doc_published'], false));
             $OBX->setValue('11', 'F');
             $obxCount++;
             $OBX = $this->hl7->addSegment('OBX');
             $OBX->setValue('1', $obxCount);
             $OBX->setValue('2', 'TS');
             $OBX->setValue('3.1', '29769-7');
             $OBX->setValue('3.2', 'Date vaccine information statement presented');
             $OBX->setValue('3.3', 'LN');
             $OBX->setValue('4', $immu['id']);
             $OBX->setValue('5', $this->date($immu['education_date'], false));
             $OBX->setValue('11', 'F');
         }
         $msgRecord = $this->saveMsg();
         if (isset($params->delivery) && ($params->delivery = 'download')) {
             return;
         }
         if ($this->to['route'] == 'file') {
             $response = $this->Save();
         } else {
             $response = $this->Send();
         }
         $msgRecord->response = $response['message'];
         if ($response['success']) {
             $msgRecord->status = 3;
             $this->m->save($msgRecord);
         } else {
             $msgRecord->status = preg_match('/^socket/', $response['message']) ? 2 : 4;
             // if socket error put back in queue
             $msgRecord->error = $response['message'];
             $this->m->save($msgRecord);
         }
         return ['success' => true];
     } catch (Exception $Error) {
         return ['success' => false];
     }
 }
Esempio n. 2
0
 function sendVXU($params)
 {
     // set these globally to be used by MSH and PID
     $this->to = $params->to;
     $this->from = $params->from;
     $this->patient = $params->pid;
     $this->encounter = isset($params->eid) ? $params->eid : 0;
     $this->type = 'VXU';
     // MSH
     $msh = $this->setMSH();
     $msh->setValue('9.1', 'VXU');
     $msh->setValue('9.2', 'V04');
     //		$msh->setValue('9.3', 'VXU_V04');
     // PID
     $this->setPID();
     // PV1
     $this->setPV1();
     $this->i = MatchaModel::setSenchaModel('App.model.patient.PatientImmunization');
     include_once ROOT . '/dataProvider/Immunizations.php';
     $immunization = new Immunizations();
     // immunizations loop
     foreach ($params->immunizations as $i) {
         $immu = $this->i->load($i)->one();
         // ROC
         $roc = $this->hl7->addSegment('ORC');
         $roc->setValue('1', 'RE');
         //HL70119
         // RXA
         $rxa = $this->hl7->addSegment('RXA');
         $rxa->setValue('3.1', $this->date($immu['administered_date']));
         //Date/Time Start of Administration
         $rxa->setValue('4.1', $this->date($immu['administered_date']));
         //Date/Time End of Administration
         //Administered Code
         $rxa->setValue('5.1', $immu['code']);
         //Identifier
         $rxa->setValue('5.2', $immu['vaccine_name']);
         //Text
         $rxa->setValue('5.3', $immu['code_type']);
         //Name of Coding System
         if ($this->isPresent($immu['administer_amount'])) {
             $rxa->setValue('6', $immu['administer_amount']);
             //Administered Amount
             $rxa->setValue('7.1', $immu['administer_amount']);
             //Identifier
             $rxa->setValue('7.2', 'millimeters');
             //Text
             $rxa->setValue('7.3', 'ISO+');
             //Name of Coding System HL70396
         } else {
             $rxa->setValue('6', '999');
             //Administered Amount
         }
         $rxa->setValue('15', $immu['lot_number']);
         //Substance LotNumbers
         // get immunization manufacturer info
         $mvx = $immunization->getMvxByCode($immu['manufacturer']);
         $mText = isset($mvx['manufacturer']) ? $mvx['manufacturer'] : '';
         //Substance ManufacturerName
         $rxa->setValue('17.1', $immu['manufacturer']);
         //Identifier
         $rxa->setValue('17.2', $mText);
         //Text
         $rxa->setValue('17.3', 'MVX');
         //Name of Coding System HL70396
         $rxa->setValue('21', 'A');
         //Action Code
     }
     $msgRecord = $this->saveMsg();
     if ($this->to['route'] == 'file') {
         $response = $this->Save();
     } else {
         $response = $this->Send();
     }
     $msgRecord->response = $response['message'];
     if ($response['success']) {
         $msgRecord->status = 3;
         $this->m->save($msgRecord);
     } else {
         $msgRecord->status = preg_match('/^socket/', $response['message']) ? 2 : 4;
         // if socket error put back in queue
         $msgRecord->error = $response['message'];
         $this->m->save($msgRecord);
     }
 }