/** * Build PID segement * * @param CHL7v2Event $event Event * * @return null */ function build(CHL7v2Event $event) { parent::build($event); $message = $event->message; $sender = $event->_sender; $group = $sender->loadRefGroup(); $domains_returned = $this->domains_returned; $patient = $this->patient; $data = array(); // PID-1: Set ID - PID (SI) (optional) $data[] = $this->set_id; // PID-2: Patient ID (CX) (optional) $data[] = null; $identifiers = array(); if (empty($domains_returned)) { $idex = new CIdSante400(); $idex->object_id = $patient->_id; $idex->object_class = "CPatient"; $ljoin = array(); $ljoin[] = "group_domain AS g1 ON g1.domain_id = domain.domain_id AND g1.object_class = 'CPatient'"; foreach ($idex->loadMatchingList() as $_idex) { $domain = new CDomain(); $where["tag"] = " = '{$_idex->tag}'"; $domain->loadObject($where, null, null, $ljoin); if (!$domain->_id) { continue; } $identifiers[] = array($_idex->id400, null, null, $this->getAssigningAuthority("domain", null, null, $domain), "MR"); } } else { foreach ($domains_returned as $_domain_returned) { $assigning_authority = $this->getAssigningAuthority("domain", null, null, $_domain_returned); $identifiers[] = array(CIdSante400::getValueFor($patient, $_domain_returned->tag), null, null, $assigning_authority, "MR"); } } // PID-3: Patient Identifier List (CX) (repeating) $data[] = $identifiers; // PID-4: Alternate Patient ID - PID (CX) (optional repeating) $data[] = null; // PID-5: Patient Name (XPN) (repeating) $data[] = $this->getXPN($patient); // PID-6: Mother's Maiden Name (XPN) (optional repeating) $data[] = null; // PID-7: Date/Time of Birth (TS) (optional) $data[] = CMbDT::isLunarDate($patient->naissance) ? null : $patient->naissance; // PID-8: Administrative Sex (IS) (optional) // Table - 0001 // F - Female // M - Male // O - Other // U - Unknown // A - Ambiguous // N - Not applicable $data[] = CHL7v2TableEntry::mapTo("1", $patient->sexe); // PID-9: Patient Alias (XPN) (optional repeating) $data[] = null; // PID-10: Race (CE) (optional repeating) $data[] = null; // PID-11: Patient Address (XAD) (optional repeating) $address = array(); if ($patient->adresse || $patient->ville || $patient->cp) { $linesAdress = explode("\n", $patient->adresse, 2); $address[] = array(CValue::read($linesAdress, 0), str_replace("\n", $message->componentSeparator, CValue::read($linesAdress, 1)), $patient->ville, $patient->province, $patient->cp, CPaysInsee::getAlpha3($patient->pays_insee), "H"); } if ($patient->lieu_naissance || $patient->cp_naissance || $patient->pays_naissance_insee) { $address[] = array(null, null, $patient->lieu_naissance, null, $patient->cp_naissance, CPaysInsee::getAlpha3($patient->pays_naissance_insee), "BDL"); } $data[] = $address; // PID-12: County Code (IS) (optional) $data[] = null; // PID-13: Phone Number - Home (XTN) (optional repeating) // Table - 0201 // ASN - Answering Service Number // BPN - Beeper Number // EMR - Emergency Number // NET - Network (email) Address // ORN - Other Residence Number // PRN - Primary Residence Number // VHN - Vacation Home Number // WPN - Work Number // Table - 0202 // BP - Beeper // CP - Cellular Phone // FX - Fax // Internet - Internet Address: Use Only If Telecommunication Use Code Is NET // MD - Modem // PH - Telephone // TDD - Telecommunications Device for the Deaf // TTY - Teletypewriter $phones = array(); if ($patient->tel) { $area_city_code = null; $local_number = null; if ($sender->_configs["send_area_local_number"]) { $area_city_code = substr($patient->tel, 0, 3); $local_number = substr($patient->tel, 3); } $phones[] = array(null, "PRN", "PH", null, null, $area_city_code, $local_number, null, null, null, null, $sender->_configs["send_area_local_number"] ? null : $patient->tel); } $data[] = $phones; // PID-14: Phone Number - Business (XTN) (optional repeating) $data[] = null; // PID-15: Primary Language (CE) (optional) $data[] = null; // PID-16: Marital Status (CE) (optional) $data[] = null; // PID-17: Religion (CE) (optional) $data[] = null; // PID-18: Patient Account Number (CX) (optional) if ($this->sejour) { $sejour = $this->sejour; $sejour->loadNDA($group->_id); $domain = new CDomain(); $domain->tag = $sejour->getTagNDA(); $domain->loadMatchingObject(); $data[] = $sejour->_NDA ? array(array($sejour->_NDA, null, null, $this->getAssigningAuthority("domain", null, null, $domain))) : null; } else { $data[] = null; } // PID-19: SSN Number - Patient (ST) (optional) $data[] = $patient->matricule; // PID-20: Driver's License Number - Patient (DLN) (optional) $data[] = null; // PID-21: Mother's Identifier (CX) (optional repeating) $data[] = null; // PID-22: Ethnic Group (CE) (optional repeating) $data[] = null; // PID-23: Birth Place (ST) (optional) $data[] = null; // PID-24: Multiple Birth Indicator (ID) (optional) $data[] = null; // PID-25: Birth Order (NM) (optional) $data[] = $patient->rang_naissance; // PID-26: Citizenship (CE) (optional repeating) $data[] = null; // PID-27: Veterans Military Status (CE) (optional) $data[] = null; // PID-28: Nationality (CE) (optional) $data[] = null; // PID-29: Patient Death Date and Time (TS) (optional) $data[] = $patient->deces ? $patient->deces : null; // PID-30: Patient Death Indicator (ID) (optional) $data[] = $patient->deces ? "Y" : "N"; // PID-31: Identity Unknown Indicator (ID) (optional) $data[] = null; // PID-32: Identity Reliability Code (IS) (optional repeating) $data[] = null; // PID-33: Last Update Date/Time (TS) (optional) $data[] = null; // PID-34: Last Update Facility (HD) (optional) $data[] = null; // PID-35: Species Code (CE) (optional) $data[] = null; // PID-36: Breed Code (CE) (optional) $data[] = null; // PID-37: Strain (ST) (optional) $data[] = null; // PID-38: Production Class Code (CE) (optional) $data[] = null; // PID-39: Tribal Citizenship (CWE) (optional repeating) $data[] = null; $this->fill($data); }
/** * @see parent::extractData */ function extractData() { /** @var CDocumentItem $docItem */ $docItem = $this->mbObject; $this->realm_code = "FR"; $this->langage = $docItem->language; //Récupération du dernier log qui correspond à la date de création de cette version $last_log = $docItem->loadLastLog(); $this->date_creation = $last_log->date; $this->date_author = $last_log->date; $this->targetObject = $object = $docItem->loadTargetObject(); if ($object instanceof CConsultAnesth) { $this->targetObject = $object = $object->loadRefConsultation(); } $this->practicien = $object->loadRefPraticien(); $this->patient = $object->loadRefPatient(); $this->patient->loadLastINS(); $this->patient->loadIPP(); $this->mbObject = $docItem; $this->root = CMbOID::getOIDFromClass($docItem, $this->receiver); $this->practicien->loadRefFunction(); $this->practicien->loadRefOtherSpec(); $group = new CGroups(); $group->load($this->practicien->_group_id); $this->healt_care = CCdaTools::loadEntryJV("CI-SIS_jdv_healthcareFacilityTypeCode.xml", CIdSante400::getValueFor($group, "cda_association_code")); if ($docItem instanceof CFile) { $this->version = "1"; $this->nom = basename($docItem->file_name); } else { $this->version = $docItem->version; $this->nom = $docItem->nom; } $this->id_cda_lot = "{$this->root}.{$docItem->_id}"; $this->id_cda = "{$this->id_cda_lot}.{$this->version}"; $confidentialite = "N"; if ($docItem->private) { $confidentialite = "R"; } $this->confidentialite = CCdaTools::loadEntryJV("CI-SIS_jdv_confidentialityCode.xml", $confidentialite); if ($docItem->type_doc) { $type = explode("^", $docItem->type_doc); $this->code = CCdaTools::loadEntryJV("CI-SIS_jdv_typeCode.xml", $type[1]); } //conformité HL7 $this->templateId[] = $this->createTemplateID("2.16.840.1.113883.2.8.2.1", "HL7 France"); //Conformité CI-SIS $this->templateId[] = $this->createTemplateID("1.2.250.1.213.1.1.1.1", "CI-SIS"); //Confirmité IHE XSD-SD => contenu non structuré $this->templateId[] = $this->createTemplateID("1.3.6.1.4.1.19376.1.2.20", "IHE XDS-SD"); $this->industry_code = CCdaTools::loadEntryJV("CI-SIS_jdv_practiceSettingCode.xml", "ETABLISSEMENT"); $mediaType = "application/pdf"; //Génération du PDF if ($docItem instanceof CFile) { $path = $docItem->_file_path; switch ($docItem->file_type) { case "image/tiff": $mediaType = "image/tiff"; break; case "application/pdf": $mediaType = $docItem->file_type; $path = CCdaTools::generatePDFA($docItem->_file_path); break; case "image/jpeg": case "image/jpg": $mediaType = "image/jpeg"; break; case "application/rtf": $mediaType = "text/rtf"; break; default: $docItem->convertToPDF(); $file = $docItem->loadPDFconverted(); $path = CCdaTools::generatePDFA($file->_file_path); } } else { if ($msg = $docItem->makePDFpreview(1, 0)) { throw new CMbException($msg); } $file = $docItem->_ref_file; $path = CCdaTools::generatePDFA($file->_file_path); } $this->file = $path; $this->mediaType = $mediaType; $service["nullflavor"] = null; switch (get_class($object)) { case "CSejour": /** @var CSejour $object CSejour */ $dp = $object->DP; $service["time_start"] = $object->entree; $service["time_stop"] = $object->sortie; $service["executant"] = $object->loadRefPraticien(); if ($dp) { $service["oid"] = "2.16.840.1.113883.6.3"; $service["code"] = $dp; $service["type_code"] = "cim10"; } else { $service["nullflavor"] = "UNK"; } break; case "COperation": /** @var COperation $object COperation */ $no_acte = 0; foreach ($object->loadRefsActesCCAM() as $_acte_ccam) { if ($_acte_ccam->code_activite === "4" || !$_acte_ccam->_check_coded || $no_acte >= 1) { continue; } $service["time_start"] = $_acte_ccam->execution; $service["time_stop"] = ""; $service["code"] = $_acte_ccam->code_acte; $service["oid"] = "1.2.250.1.213.2.5"; $_acte_ccam->loadRefExecutant(); $service["executant"] = $_acte_ccam->_ref_executant; $service["type_code"] = "ccam"; $no_acte++; } if ($no_acte === 0) { $service["time_start"] = $object->debut_op; $service["time_stop"] = $object->fin_op; $service["executant"] = $object->loadRefPraticien(); $service["nullflavor"] = "UNK"; } break; case "CConsultation": /** @var CConsultation $object CConsultation */ $object->loadRefPlageConsult(); $no_acte = 0; foreach ($object->loadRefsActesCCAM() as $_acte_ccam) { if (!$_acte_ccam->_check_coded || $_acte_ccam->code_activite === "4" || $no_acte >= 1) { continue; } $service["time_start"] = $_acte_ccam->execution; $service["time_stop"] = ""; $service["code"] = $_acte_ccam->code_acte; $service["oid"] = "1.2.250.1.213.2.5"; $_acte_ccam->loadRefExecutant(); $service["executant"] = $_acte_ccam->_ref_executant; $service["type_code"] = "ccam"; $no_acte++; } if ($no_acte === 0) { $service["time_start"] = $object->_datetime; $service["time_stop"] = $object->_date_fin; $service["executant"] = $object->loadRefPraticien(); $service["nullflavor"] = "UNK"; } break; default: } $this->service_event = $service; if ($this->old_version) { $oid = CMbOID::getOIDFromClass($docItem, $this->receiver); $this->old_version = "{$oid}.{$this->old_id}.{$this->old_version}"; } }
/** * Get actors identifiers * * @param array &$identifiers Identifiers * @param CMbObject $object Object * @param CInteropActor $actor Actor * * @return void */ function fillActorsIdentifiers(&$identifiers, CMbObject $object, CInteropActor $actor = null) { if (!$actor->_configs["send_actor_identifier"]) { return; } $domain = new CDomain(); $where = array(); $where["incrementer_id"] = "IS NULL"; $where["actor_id"] = "IS NOT NULL"; /** @var CDomain[] $domains */ $domains = $domain->loadList($where); foreach ($domains as $_domain) { $value = CIdSante400::getValueFor($object, $_domain->tag); if (!$value) { continue; } $identifiers[] = array($value, null, null, $this->getAssigningAuthority("domain", null, null, $_domain), $actor->_configs["build_identifier_authority"] == "PI_AN" ? "PI" : "RI"); } }