/** * Method getRecordTarget() * @return array */ private function getRecordTarget() { $patientData = $this->patientData; $Insurance = new Insurance(); $insuranceData = $Insurance->getPatientPrimaryInsuranceByPid($this->pid); $recordTarget['patientRole']['id'] = ['@attributes' => ['root' => '2.16.840.1.113883.19.5', 'extension' => $patientData['pid']]]; $recordTarget['patientRole']['addr'] = $this->addressBuilder('HP', $patientData['address'], $patientData['city'], $patientData['state'], $patientData['zipcode'], $patientData['country'], date('Ymd')); $recordTarget['patientRole']['telecom'] = $this->telecomBuilder($patientData['home_phone'], 'H'); $recordTarget['patientRole']['patient']['name'] = ['@attributes' => ['use' => 'L']]; $recordTarget['patientRole']['patient']['name']['given'][] = $patientData['fname']; if ($patientData['mname'] != '') { $recordTarget['patientRole']['patient']['name']['given'][] = $patientData['mname']; } $recordTarget['patientRole']['patient']['name']['family'] = $patientData['lname']; if ($patientData['title'] != '') { $recordTarget['patientRole']['patient']['name']['suffix'] = ['@attributes' => ['qualifier' => 'TITLE'], '@value' => isset($patientData['title']) ? $patientData['title'] : '']; } $recordTarget['patientRole']['patient']['administrativeGenderCode'] = ['@attributes' => ['code' => $patientData['sex'], 'codeSystemName' => 'AdministrativeGender', 'codeSystem' => '2.16.840.1.113883.5.1']]; if ($patientData['sex'] == 'F') { $recordTarget['patientRole']['patient']['administrativeGenderCode']['@attributes']['displayName'] = 'Female'; } elseif ($patientData['sex'] == 'M') { $recordTarget['patientRole']['patient']['administrativeGenderCode']['@attributes']['displayName'] = 'Male'; } $recordTarget['patientRole']['patient']['birthTime'] = ['@attributes' => ['value' => preg_replace('/(\\d{4})-(\\d{2})-(\\d{2}) \\d{2}:\\d{2}:\\d{2}/', '$1$2$3', $patientData['DOB'])]]; if (isset($patientData['marital_status']) && $patientData['marital_status'] != '') { $recordTarget['patientRole']['patient']['maritalStatusCode'] = ['@attributes' => ['code' => $patientData['marital_status'], 'codeSystemName' => 'MaritalStatusCode', 'displayName' => $this->CombosData->getDisplayValueByListIdAndOptionValue(12, $patientData['marital_status']), 'codeSystem' => '2.16.840.1.113883.5.2']]; } else { $recordTarget['patientRole']['patient']['maritalStatusCode'] = ['@attributes' => ['nullFlavor' => 'NA', 'codeSystemName' => 'MaritalStatusCode', 'codeSystem' => '2.16.840.1.113883.5.2']]; } if (isset($patientData['race']) && $patientData['race'] != '') { $recordTarget['patientRole']['patient']['raceCode'] = ['@attributes' => ['code' => $patientData['race'], 'codeSystemName' => 'Race & Ethnicity - CDC', 'displayName' => $this->CombosData->getDisplayValueByListIdAndOptionValue(14, $patientData['race']), 'codeSystem' => '2.16.840.1.113883.6.238']]; } else { $recordTarget['patientRole']['patient']['raceCode'] = ['@attributes' => ['nullFlavor' => 'NA', 'codeSystemName' => 'Race & Ethnicity - CDC', 'codeSystem' => '2.16.840.1.113883.6.238']]; } if (isset($patientData['ethnicity']) && $patientData['ethnicity'] != '') { $recordTarget['patientRole']['patient']['ethnicGroupCode'] = ['@attributes' => ['code' => $patientData['ethnicity'] == 'H' ? '2135-2' : '2186-5', 'codeSystemName' => 'Race & Ethnicity - CDC', 'displayName' => $this->CombosData->getDisplayValueByListIdAndOptionValue(59, $patientData['ethnicity']), 'codeSystem' => '2.16.840.1.113883.6.238']]; } else { $recordTarget['patientRole']['patient']['ethnicGroupCode'] = ['@attributes' => ['nullFlavor' => 'NA', 'codeSystemName' => 'Race & Ethnicity - CDC', 'codeSystem' => '2.16.840.1.113883.6.238']]; } $recordTarget['patientRole']['patient']['birthplace']['place']['addr'] = $this->addressBuilder(false, false, false, false, false, ''); if (isset($patientData['language']) && $patientData['language'] != '') { $recordTarget['patientRole']['patient']['languageCommunication']['languageCode']['@attributes']['code'] = $patientData['language']; } else { $recordTarget['patientRole']['patient']['languageCommunication']['languageCode']['@attributes']['nullFlavor'] = 'NI'; } $org = []; $org['id']['@attributes'] = ['root' => '2.16.840.1.113883.4.6', 'assigningAuthorityName' => 'CCD-Author']; $org['name']['prefix'] = $this->facility['name']; $org['telecom'] = $this->telecomBuilder($this->facility['phone'], 'WP'); $org['addr'] = $this->addressBuilder('WP', $this->facility['address'] . ' ' . $this->facility['address_cont'], $this->facility['city'], $this->facility['state'], $this->facility['postal_code'], $this->facility['country_code']); $recordTarget['patientRole']['providerOrganization'] = $org; unset($Patient, $patientData, $Insurance, $insuranceData); return $recordTarget; }
/** * Method getRecordTarget() * * The recordTarget records the administrative and demographic data of the patient whose health information * is described by the clinical document; each recordTarget must contain at least one patientRole element * * @return array */ private function getRecordTarget() { $patientData = $this->patientData; $Insurance = new Insurance(); $insuranceData = $Insurance->getPatientPrimaryInsuranceByPid($this->pid); $PatientContactRecord = $this->PatientContacts->getSelfContact($this->pid); $recordTarget['patientRole']['id'] = ['@attributes' => ['root' => '2.16.840.1.113883.19.5', 'extension' => $patientData['pid']]]; // If the Self Contact information address is set, include it in the CCD if (isset($PatientContactRecord['street_mailing_address'])) { $recordTarget['patientRole']['addr'] = $this->addressBuilder('HP', $PatientContactRecord['street_mailing_address'], $PatientContactRecord['city'], $PatientContactRecord['state'], $PatientContactRecord['zip'], $PatientContactRecord['country'], date('Ymd')); } // If the Self Contact information phone is present, include it in the CCD if (isset($PatientContactRecord['phone_use_code']) && isset($PatientContactRecord['phone_area_code']) && isset($PatientContactRecord['phone_local_number'])) { $recordTarget['patientRole']['telecom'] = $this->telecomBuilder($PatientContactRecord['phone_use_code'] . $PatientContactRecord['phone_area_code'] . $PatientContactRecord['phone_local_number'], 'HP'); } // Patient Name $recordTarget['patientRole']['patient']['name'] = ['@attributes' => ['use' => 'L']]; $recordTarget['patientRole']['patient']['name']['given'][] = $patientData['fname']; if ($patientData['mname'] != '') { $recordTarget['patientRole']['patient']['name']['given'][] = $patientData['mname']; } $recordTarget['patientRole']['patient']['name']['family'] = $patientData['lname']; if ($patientData['title'] != '') { $recordTarget['patientRole']['patient']['name']['suffix'] = ['@attributes' => ['qualifier' => 'TITLE'], '@value' => isset($patientData['title']) ? $patientData['title'] : '']; } // values are M, F, or UM more info... // http://phinvads.cdc.gov/vads/ViewValueSet.action?id=8DE75E17-176B-DE11-9B52-0015173D1785 $recordTarget['patientRole']['patient']['administrativeGenderCode'] = ['@attributes' => ['code' => $patientData['sex'], 'codeSystemName' => 'AdministrativeGender', 'codeSystem' => '2.16.840.1.113883.5.1']]; // Patient Sex if ($patientData['sex'] == 'F') { $recordTarget['patientRole']['patient']['administrativeGenderCode']['@attributes']['displayName'] = 'Female'; } elseif ($patientData['sex'] == 'M') { $recordTarget['patientRole']['patient']['administrativeGenderCode']['@attributes']['displayName'] = 'Male'; } // Patient Date of Birth $recordTarget['patientRole']['patient']['birthTime'] = ['@attributes' => ['value' => preg_replace('/(\\d{4})-(\\d{2})-(\\d{2}) \\d{2}:\\d{2}:\\d{2}/', '$1$2$3', $patientData['DOB'])]]; if (isset($patientData['marital_status']) && $patientData['marital_status'] != '') { $recordTarget['patientRole']['patient']['maritalStatusCode'] = ['@attributes' => ['code' => $patientData['marital_status'], 'codeSystemName' => 'MaritalStatusCode', 'displayName' => $this->CombosData->getDisplayValueByListIdAndOptionValue(12, $patientData['marital_status']), 'codeSystem' => '2.16.840.1.113883.5.2']]; } else { $recordTarget['patientRole']['patient']['maritalStatusCode'] = ['@attributes' => ['nullFlavor' => 'NA', 'codeSystemName' => 'MaritalStatusCode', 'codeSystem' => '2.16.840.1.113883.5.2']]; } // Patient Race if (isset($patientData['race']) && $patientData['race'] != '') { $recordTarget['patientRole']['patient']['raceCode'] = ['@attributes' => ['code' => $patientData['race'], 'codeSystemName' => 'Race & Ethnicity - CDC', 'displayName' => $this->CombosData->getDisplayValueByListIdAndOptionValue(14, $patientData['race']), 'codeSystem' => '2.16.840.1.113883.6.238']]; } else { $recordTarget['patientRole']['patient']['raceCode'] = ['@attributes' => ['nullFlavor' => 'NA', 'codeSystemName' => 'Race & Ethnicity - CDC', 'codeSystem' => '2.16.840.1.113883.6.238']]; } // Patient Ethnicity if (isset($patientData['ethnicity']) && $patientData['ethnicity'] != '') { $recordTarget['patientRole']['patient']['ethnicGroupCode'] = ['@attributes' => ['code' => $patientData['ethnicity'] == 'H' ? '2135-2' : '2186-5', 'codeSystemName' => 'Race & Ethnicity - CDC', 'displayName' => $this->CombosData->getDisplayValueByListIdAndOptionValue(59, $patientData['ethnicity']), 'codeSystem' => '2.16.840.1.113883.6.238']]; } else { $recordTarget['patientRole']['patient']['ethnicGroupCode'] = ['@attributes' => ['nullFlavor' => 'NA', 'codeSystemName' => 'Race & Ethnicity - CDC', 'codeSystem' => '2.16.840.1.113883.6.238']]; } $recordTarget['patientRole']['patient']['birthplace']['place']['addr'] = $this->addressBuilder(false, false, false, false, false, ''); // Patient Prefered language if (isset($patientData['language']) && $patientData['language'] != '') { $recordTarget['patientRole']['patient']['languageCommunication']['languageCode']['@attributes']['code'] = $patientData['language']; } else { $recordTarget['patientRole']['patient']['languageCommunication']['languageCode']['@attributes']['nullFlavor'] = 'NI'; } $org = []; $org['id']['@attributes'] = ['root' => '2.16.840.1.113883.4.6', 'assigningAuthorityName' => 'CCD-Author']; $org['name']['prefix'] = $this->facility['name']; $org['telecom'] = $this->telecomBuilder($this->facility['phone'], 'WP'); $org['addr'] = $this->addressBuilder('WP', $this->facility['address'] . ' ' . $this->facility['address_cont'], $this->facility['city'], $this->facility['state'], $this->facility['postal_code'], $this->facility['country_code']); $recordTarget['patientRole']['providerOrganization'] = $org; unset($Patient, $patientData, $Insurance, $insuranceData); return $recordTarget; }