Esempio n. 1
0
 /**
  * @return Segments
  * @throws Exception
  */
 private function setPID()
 {
     $this->patient = $this->p->load($this->patient)->one();
     if ($this->patient == false) {
         throw new \Exception('Error: Patient not found during setPID, Record # ' . $this->patient);
     }
     $this->patient = (object) $this->patient;
     $this->patient->age = Patient::getPatientAgeByDOB($this->patient->DOB);
     $pid = $this->hl7->addSegment('PID');
     $pid->setValue('1', 1);
     //		if($this->notEmpty($this->patient->pubpid)){
     //			$pid->setValue('2.3', $this->patient->pubpid);
     //		}else if($this->notEmpty($this->patient->pid)){
     //			$pid->setValue('2.3', $this->patient->pid);
     //		}
     //		if($this->notEmpty($this->patient->pubpid)){
     //			$pid->setValue('3.1', $this->patient->pubpid);
     if ($this->notEmpty($this->patient->pid)) {
         $pid->setValue('3.1', $this->patient->pid);
     }
     $pid->setValue('3.4', 'GaiaEHR');
     $pid->setValue('3.5', 'MR');
     // IDNumber Type (HL70203) MR = Medical Record
     if ($this->patient->age['DMY']['years'] == 0) {
         //			$pid->setValue('5.1.1', '', 0);
         $pid->setValue('5.7', 'S', 1);
     } else {
         if ($this->notEmpty($this->patient->lname)) {
             $pid->setValue('5.1.1', $this->patient->lname);
         }
         if ($this->notEmpty($this->patient->fname)) {
             $pid->setValue('5.2', $this->patient->fname);
         }
         if ($this->notEmpty($this->patient->mname)) {
             $pid->setValue('5.3', $this->patient->mname);
         }
         $pid->setValue('5.7', 'L');
     }
     // This has to be taken on Patient Contacts
     $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 = 'MTH';
     $ContactRecord = $this->PatientContacts->load($filters)->one();
     if ($this->notEmpty($ContactRecord)) {
         $pid->setValue('6.1', $ContactRecord['first_name'] . ' ' . $ContactRecord['middle_name'] . ' ' . $ContactRecord['last_name']);
         $pid->setValue('6.2', $ContactRecord['first_name'] . ' ' . $ContactRecord['middle_name'] . ' ' . $ContactRecord['last_name']);
     }
     if ($this->notEmpty($this->patient->DOB)) {
         $pid->setValue('7.1', $this->date($this->patient->DOB));
     }
     if ($this->notEmpty($this->patient->sex)) {
         $pid->setValue('8', $this->patient->sex);
     }
     if ($this->notEmpty($this->patient->alias)) {
         $pid->setValue('9.2', $this->patient->alias);
     }
     if ($this->notEmpty($this->patient->race)) {
         $pid->setValue('10.1', $this->patient->race);
         $pid->setValue('10.2', $this->hl7->race($this->patient->race));
         //Race Text
         $pid->setValue('10.3', 'CDCREC');
         // Race Name of Coding System
     }
     // Patient Address taken Patient Contact (SELF)
     $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['street_mailing_address'])) {
         if ($this->notEmpty($ContactRecord['street_mailing_address'])) {
             $pid->setValue('11.1.1', $ContactRecord['street_mailing_address']);
         }
         if ($this->notEmpty($ContactRecord['city'])) {
             $pid->setValue('11.3', $ContactRecord['city']);
         }
         if ($this->notEmpty($ContactRecord['state'])) {
             $pid->setValue('11.4', $ContactRecord['state']);
         }
         if ($this->notEmpty($ContactRecord['zip'])) {
             $pid->setValue('11.5', $ContactRecord['zip']);
         }
         if ($this->notEmpty($ContactRecord['country'])) {
             $pid->setValue('11.6', $ContactRecord['country']);
         }
         if ($this->notEmpty($ContactRecord['street_mailing_address'])) {
             $pid->setValue('11.7', 'L');
             // Address Type L = Legal Address
         }
         $pid->setValue('11.9', '25025');
     }
     // Patient Phone Number taken from Patient Contact (SELF)
     if ($this->notEmpty($ContactRecord['phone_use_code']) && $this->notEmpty($ContactRecord['phone_area_code']) && $this->notEmpty($ContactRecord['phone_local_number'])) {
         $phone = $this->phone($ContactRecord['phone_use_code'] . $ContactRecord['phone_area_code'] . $ContactRecord['phone_local_number']);
         $pid->setValue('13.2', 'PRN');
         // PhoneNumber‐Home
         $pid->setValue('13.6', $ContactRecord['zip']);
         // Area/City Code
         $pid->setValue('13.7', $phone);
         // LocalNumber
     }
     //		if($this->notEmpty($this->patient->work_phone)){
     //		    $phone = $this->phone($this->patient->work_phone);
     //			$PID->setValue('13.2', 'PRN'); // PhoneNumber‐Home
     //			$PID->setValue('13.6', $phone['zip']); // Area/City Code
     //			$PID->setValue('13.7', $phone['number']); // LocalNumber
     //		}
     if ($this->notEmpty($this->patient->language)) {
         $pid->setValue('15.1', $this->patient->language);
     }
     if ($this->notEmpty($this->patient->marital_status)) {
         $pid->setValue('16.1', $this->patient->marital_status);
         // EthnicGroup Identifier
         $pid->setValue('16.2', $this->hl7->marital($this->patient->marital_status));
         // EthnicGroup Text
         $pid->setValue('16.3', 'CDCREC');
         // Name of Coding System
     }
     if ($this->notEmpty($this->patient->pubaccount)) {
         $pid->setValue('18.1', $this->patient->pubaccount);
     }
     if ($this->notEmpty($this->patient->SS)) {
         $pid->setValue('19', $this->patient->SS);
     }
     // Patient Drivers License Information
     if ($this->notEmpty($this->patient->drivers_license)) {
         $pid->setValue('20.1', $this->patient->drivers_license);
         if ($this->notEmpty($this->patient->drivers_license_state)) {
             $pid->setValue('20.2', $this->patient->drivers_license_state);
         }
         if ($this->notEmpty($this->patient->drivers_license_exp)) {
             $pid->setValue('20.3', $this->date($this->patient->drivers_license_exp));
         }
     }
     if ($this->notEmpty($this->patient->ethnicity)) {
         if ($this->patient->ethnicity == 'H') {
             $pid->setValue('22.1', '2135-2');
             $pid->setValue('22.3', 'CDCREC');
         } elseif ($this->patient->ethnicity == 'N') {
             $pid->setValue('22.1', '2186-5');
             $pid->setValue('22.3', 'CDCREC');
         } else {
             $pid->setValue('22.1', '$this->patient->ethnicity');
         }
     }
     if ($this->notEmpty($this->patient->birth_place)) {
         $pid->setValue('23', $this->patient->birth_place);
     }
     if ($this->notEmpty($this->patient->birth_multiple)) {
         $pid->setValue('24', $this->patient->birth_multiple);
     }
     if ($this->notEmpty($this->patient->birth_order)) {
         $pid->setValue('25', $this->patient->birth_order);
     }
     if ($this->notEmpty($this->patient->citizenship)) {
         $pid->setValue('26.1', $this->patient->citizenship);
     }
     if ($this->notEmpty($this->patient->is_veteran)) {
         $pid->setValue('27.1', $this->patient->is_veteran);
     }
     if ($this->notEmpty($this->patient->death_date) && $this->notEmpty($this->patient->deceased)) {
         $pid->setValue('29.1', $this->date($this->patient->death_date));
         $pid->setValue('30', 'Y');
     }
     if ($this->notEmpty($this->patient->update_date)) {
         $pid->setValue('33.1', $this->date($this->patient->update_date));
     }
     return $pid;
 }
Esempio n. 2
0
 /**
  * @return Segments
  * @throws Exception
  */
 private function setPID()
 {
     $this->patient = $this->p->load($this->patient)->one();
     if ($this->patient == false) {
         throw new \Exception('Error: Patient not found during setPID, Record # ' . $this->patient);
     }
     $this->patient = (object) $this->patient;
     $this->patient->age = Patient::getPatientAgeByDOB($this->patient->DOB);
     $pid = $this->hl7->addSegment('PID');
     $pid->setValue('1', 1);
     if ($this->notEmpty($this->patient->pubpid)) {
         $pid->setValue('2.3', $this->patient->pubpid);
     }
     if ($this->notEmpty($this->patient->pid)) {
         $pid->setValue('3.1', $this->patient->pid);
     }
     $pid->setValue('3.5', 'MR');
     // IDNumber Type (HL70203) MR = Medical Record
     if ($this->patient->age['DMY']['years'] == 0) {
         //			$pid->setValue('5.1.1', '', 0);
         $pid->setValue('5.7', 'S', 1);
     } else {
         if ($this->notEmpty($this->patient->lname)) {
             $pid->setValue('5.1.1', $this->patient->lname);
         }
         if ($this->notEmpty($this->patient->fname)) {
             $pid->setValue('5.2', $this->patient->fname);
         }
         if ($this->notEmpty($this->patient->mname)) {
             $pid->setValue('5.3', $this->patient->mname);
         }
         $pid->setValue('5.7', 'L');
     }
     if ($this->notEmpty($this->patient->mothers_name)) {
         $pid->setValue('6.2', $this->patient->mothers_name);
     }
     if ($this->notEmpty($this->patient->DOB)) {
         $pid->setValue('7.1', $this->date($this->patient->DOB));
     }
     if ($this->notEmpty($this->patient->sex)) {
         $pid->setValue('8', $this->patient->sex);
     }
     if ($this->notEmpty($this->patient->alias)) {
         $pid->setValue('9.2', $this->patient->alias);
     }
     if ($this->notEmpty($this->patient->race)) {
         $pid->setValue('10.1', $this->patient->race);
         $pid->setValue('10.2', $this->hl7->race($this->patient->race));
         //Race Text
         $pid->setValue('10.3', 'CDCREC');
         // Race Name of Coding System
     }
     if ($this->notEmpty($this->patient->address)) {
         $pid->setValue('11.1.1', $this->patient->address);
     }
     if ($this->notEmpty($this->patient->city)) {
         $pid->setValue('11.3', $this->patient->city);
     }
     if ($this->notEmpty($this->patient->state)) {
         $pid->setValue('11.4', $this->patient->state);
     }
     if ($this->notEmpty($this->patient->zipcode)) {
         $pid->setValue('11.5', $this->patient->zipcode);
     }
     if ($this->notEmpty($this->patient->country)) {
         $pid->setValue('11.6', $this->patient->country);
     }
     if ($this->notEmpty($this->patient->address)) {
         $pid->setValue('11.7', 'P');
         // Address Type P = Permanent
     }
     $pid->setValue('11.9', '25025');
     if ($this->notEmpty($this->patient->home_phone)) {
         $phone = $this->phone($this->patient->home_phone);
         $pid->setValue('13.2', 'PRN');
         // PhoneNumber‐Home
         $pid->setValue('13.6', $phone['zip']);
         // Area/City Code
         $pid->setValue('13.7', $phone['number']);
         // LocalNumber
     }
     //		if($this->notEmpty($this->patient->work_phone)){
     //		    $phone = $this->phone($this->patient->work_phone);
     //			$PID->setValue('13.2', 'PRN'); // PhoneNumber‐Home
     //			$PID->setValue('13.6', $phone['zip']); // Area/City Code
     //			$PID->setValue('13.7', $phone['number']); // LocalNumber
     //		}
     if ($this->notEmpty($this->patient->language)) {
         $pid->setValue('15.1', $this->patient->language);
     }
     if ($this->notEmpty($this->patient->marital_status)) {
         $pid->setValue('16.1', $this->patient->marital_status);
         // EthnicGroup Identifier
         $pid->setValue('16.2', $this->hl7->marital($this->patient->marital_status));
         // EthnicGroup Text
         $pid->setValue('16.3', 'CDCREC');
         // Name of Coding System
     }
     if ($this->notEmpty($this->patient->pubaccount)) {
         $pid->setValue('18.1', $this->patient->pubaccount);
     }
     if ($this->notEmpty($this->patient->SS)) {
         $pid->setValue('19', $this->patient->SS);
     }
     if ($this->notEmpty($this->patient->drivers_license)) {
         $pid->setValue('20.1', $this->patient->drivers_license);
     }
     if ($this->notEmpty($this->patient->drivers_license_state)) {
         $pid->setValue('20.2', $this->patient->drivers_license_state);
     }
     if ($this->notEmpty($this->patient->drivers_license_exp)) {
         $pid->setValue('20.3', $this->date($this->patient->drivers_license_exp));
     }
     if ($this->notEmpty($this->patient->ethnicity)) {
         if ($this->patient->ethnicity == 'H') {
             $pid->setValue('22.1', '2135-2');
             $pid->setValue('22.3', 'CDCREC');
         } elseif ($this->patient->ethnicity == 'N') {
             $pid->setValue('22.1', '2186-5');
             $pid->setValue('22.3', 'CDCREC');
         } else {
             $pid->setValue('22.1', '$this->patient->ethnicity');
         }
     }
     if ($this->notEmpty($this->patient->birth_place)) {
         $pid->setValue('23', $this->patient->birth_place);
     }
     if ($this->notEmpty($this->patient->birth_multiple)) {
         $pid->setValue('24', $this->patient->birth_multiple);
     }
     if ($this->notEmpty($this->patient->birth_order)) {
         $pid->setValue('25', $this->patient->birth_order);
     }
     if ($this->notEmpty($this->patient->citizenship)) {
         $pid->setValue('26.1', $this->patient->citizenship);
     }
     if ($this->notEmpty($this->patient->is_veteran)) {
         $pid->setValue('27.1', $this->patient->is_veteran);
     }
     if ($this->notEmpty($this->patient->death_date)) {
         $pid->setValue('29.1', $this->date($this->patient->death_date));
     }
     //		if($this->notEmpty($this->patient->deceased)){
     //			$pid->setValue('30', $this->patient->deceased);
     //		}
     if ($this->notEmpty($this->patient->update_date)) {
         $pid->setValue('33.1', $this->date($this->patient->update_date));
     }
     return $pid;
 }