コード例 #1
0
 /**
  * Build LCH segement
  *
  * @param CHL7v2Event $event Event
  *
  * @return null
  */
 function build(CHL7v2Event $event)
 {
     parent::build($event);
     $entity = $this->entity;
     $code = $this->code;
     $primary_key = array_search(get_class($entity), CHL7v2EventMFN::$entities);
     $primary_key = $primary_key . $entity->_id;
     mbTrace($entity);
     // LCH-1: Primary Key Value -LCH - LCH (PL) (Requis)
     $data[] = $primary_key;
     // LCH-2: Segment Action Code - LCH (ID) (Optional)
     $data[] = null;
     // LCH-3: Segment Unique Key - LCH (EI) (Optional)
     $data[] = null;
     // LCH-4: Location Characteristic ID - LCH (CWE) (Requis)
     $HL7_value = CHL7v2TableEntry::mapTo("7878", $code);
     $data[] = array(array($HL7_value, CHL7v2TableEntry::getDescription("7878", $HL7_value), "L"));
     // if si dans la chaine tu as RSPNSBL
     // alors :
     // $user = $entity->loadRefUser();
     // $user->$code
     // else
     // $entity->$code
     // LCH-5: Location Characteristic Value - LCH (CWE) (Requis)
     $data[] = null;
     $this->fill($data);
 }
コード例 #2
0
 /**
  * Build event
  *
  * @param CMbObject $object Object
  *
  * @see parent::build()
  *
  * @return void
  */
 function build($object)
 {
     parent::build($object);
     // Message Header
     $this->addMSH();
     // Master File Identification
     $this->addMFI();
     foreach ($object->_objects as $_entity) {
         // Master File Entry
         $this->addMFE($_entity);
         // Location Identification
         $this->addLOC($_entity);
         // Location Characteristic
         foreach (CHL7v2TableEntry::getTable("7878", false) as $_code) {
             if (!$_code) {
                 continue;
             }
             $this->addLCH($_entity, $_code);
         }
         // Location Relationship
         /*  $this->addLRL();*/
     }
 }
コード例 #3
0
 /**
  * Get NK1 segment
  *
  * @param DOMNode  $node       Node
  * @param CPatient $newPatient Person
  *
  * @return void
  */
 function getNK1(DOMNode $node, CPatient $newPatient)
 {
     $sender = $this->_ref_sender;
     $NK1_2 = $this->queryNode("NK1.2", $node);
     $nom = $this->queryTextNode("XPN.1/FN.1", $NK1_2);
     $prenom = $this->queryTextNode("XPN.2", $NK1_2);
     if ($prenom == "") {
         $prenom = null;
     }
     $parente = $this->queryTextNode("NK1.3/CE.1", $node);
     $parente_autre = null;
     if ($parente == "OTH") {
         $parente_autre = $this->queryTextNode("NK1.3/CE.2", $node);
     }
     $NK1_4 = $this->queryNode("NK1.4", $node);
     $adresse = $this->queryTextNode("XAD.1/SAD.1", $NK1_4);
     $cp = $this->queryTextNode("XAD.5", $NK1_4);
     $ville = $this->queryTextNode("XAD.3", $NK1_4);
     $NK1_5 = $this->queryNodes("NK1.5", $node)->item(0);
     $tel = null;
     if ($NK1_5) {
         $tel = $this->queryTextNode("XTN.12", $NK1_5);
         if (!$tel) {
             $tel = $this->queryTextNode("XTN.1", $NK1_5);
         }
     }
     $relation = $this->queryTextNode("NK1.7/CE.1", $node);
     $relation_autre = null;
     if ($relation == "O") {
         $relation_autre = $this->queryTextNode("NK1.7/CE.2", $node);
     }
     $corres_patient = new CCorrespondantPatient();
     $corres_patient->patient_id = $newPatient->_id;
     $corres_patient->nom = $nom;
     $corres_patient->prenom = $prenom;
     $corres_patient->loadMatchingObjectEsc();
     $corres_patient->adresse = $adresse;
     $corres_patient->cp = $cp;
     $corres_patient->ville = $ville;
     $corres_patient->tel = $tel;
     $corres_patient->parente = CHL7v2TableEntry::mapFrom("63", $parente);
     $corres_patient->parente_autre = $parente_autre;
     $corres_patient->relation = CHL7v2TableEntry::mapFrom("131", $relation);
     $corres_patient->relation_autre = $relation_autre;
     // Notifier les autres destinataires autre que le sender
     $corres_patient->_eai_sender_guid = $sender->_guid;
     $corres_patient->store();
 }
コード例 #4
0
 /**
  * Build PV1 segement
  *
  * @param CHL7v2Event $event Event
  *
  * @return null
  */
 function build(CHL7v2Event $event)
 {
     parent::build($event);
     $receiver = $event->_receiver;
     $group = $receiver->_ref_group;
     $sejour = $this->sejour;
     $data = array();
     // PV1-1: Set ID - PV1 (SI) (optional)
     $data[] = $this->set_id;
     // PV1-2: Patient Class (IS)
     // Table - 0004
     // E - Emergency - Passage aux Urgences - Arrivée aux urgences
     // I - Inpatient - Hospitalisation
     // N - Not Applicable - Non applicable -
     // O - Outpatient - Actes et consultation externe
     // R - Recurring patient - Séances
     // Cas de la transaction ITI-30 "Patient Identity Field"
     if (!$sejour) {
         $data[] = "N";
         $this->fill($data);
         return;
     }
     $data[] = CHL7v2TableEntry::mapTo("4", $sejour->type);
     // PV1-3: Assigned Patient Location (PL) (optional)
     $data[] = $this->getPL($receiver, $sejour, $this->curr_affectation);
     // PV1-4: Admission Type (IS) (optional)
     // Table - 0007
     // C  - Confort (chirurgie esthétique)
     // L  - Accouchement maternité
     // N  - Nouveau né
     // R  - Routine (par défaut)
     // U  - Caractère d'urgence aigue du problème quel que soit le service d'entrée
     // RM - Rétrocession du médicament
     // IE - Prestation inter-établissements
     $naissance = new CNaissance();
     $naissance->sejour_enfant_id = $sejour->_id;
     $naissance->loadMatchingObject();
     // Cas d'une naissance
     if ($naissance->_id) {
         $data[] = "N";
     } elseif ($sejour->type_pec == "O") {
         $data[] = "L";
     } else {
         $data[] = "R";
     }
     // PV1-5: Preadmit Number (CX) (optional)
     if ($receiver->_configs["build_PV1_5"] == "none") {
         $data[] = null;
     } else {
         if (CHL7v2Message::$build_mode == "simple") {
             $data[] = array($sejour->_id);
         } else {
             $sejour->loadNPA($group->_id);
             $data[] = $sejour->_NPA ? array(array($sejour->_NPA, null, null, $this->getAssigningAuthority("FINESS", $group->finess), "RI")) : null;
         }
     }
     // PV1-6: Prior Patient Location (PL) (optional)
     $data[] = $this->getPreviousPL($receiver, $sejour);
     // PV1-7: Attending Doctor (XCN) (optional repeating)
     $sejour->loadRefPraticien();
     $data[] = $this->getXCN($sejour->_ref_praticien, $receiver);
     // PV1-8: Referring Doctor (XCN) (optional repeating)
     $data[] = $sejour->adresse_par_prat_id ? $this->getXCN($sejour->loadRefAdresseParPraticien(), $receiver) : null;
     // PV1-9: Consulting Doctor (XCN) (optional repeating)
     $data[] = null;
     // PV1-10: Hospital Service (IS) (optional)
     $data[] = $this->getPV110($receiver, $sejour, $this->curr_affectation);
     // PV1-11: Temporary Location (PL) (optional)
     if ($receiver->_configs["build_PV1_11"] == "uf_medicale") {
         $affectation_id = isset($this->curr_affectation->_id) ? $this->curr_affectation->_id : null;
         $ufs = $sejour->getUFs(null, $affectation_id);
         $uf_medicale = isset($ufs["medicale"]) ? $ufs["medicale"] : null;
         if (isset($uf_medicale->_id)) {
             $data[] = array(array($uf_medicale->code));
         } else {
             $data[] = null;
         }
     } else {
         $data[] = null;
     }
     // PV1-12: Preadmit Test Indicator (IS) (optional)
     $data[] = null;
     // PV1-13: Re-admission Indicator (IS) (optional)
     $data[] = null;
     // PV1-14: Admit Source (IS) (optional)
     $data[] = $this->getPV114($receiver, $sejour);
     // PV1-15: Ambulatory Status (IS) (optional repeating)
     $data[] = null;
     // PV1-16: VIP Indicator (IS) (optional)
     // Table - 0099
     // P - Public
     // I - Incognito
     $data[] = $sejour->loadRefPatient()->vip ? "I" : "P";
     // PV1-17: Admitting Doctor (XCN) (optional repeating)
     if ($receiver->_configs["build_PV1_17"] == "none") {
         $data[] = null;
     } else {
         $data[] = $this->getXCN($sejour->_ref_praticien, $receiver);
     }
     // PV1-18: Patient Type (IS) (optional)
     $data[] = null;
     // PV1-19: Visit Number (CX) (optional)
     $sejour->loadNDA($group->_id);
     $identifiers = array();
     $NDA = $sejour->_NDA;
     if (!$sejour->_NDA && !CValue::read($receiver->_configs, "send_not_master_NDA")) {
         $NDA = "===NDA_MISSING===";
     }
     if ($receiver->_configs["build_PV1_19"] == "simple") {
         $identifiers[] = $NDA;
     } else {
         if ($receiver->_configs["build_NDA"] == "PV1_19") {
             $identifiers[] = $NDA ? array($NDA, null, null, $this->getAssigningAuthority("FINESS", $group->finess), "AN") : array();
         } else {
             /* @todo Gestion des séances */
             $identifiers[] = array($sejour->_id, null, null, $this->getAssigningAuthority("mediboard"), "RI");
         }
         // Ajout des identifiants des acteurs d'intégration
         $this->fillActorsIdentifiers($identifiers, $sejour, $receiver);
     }
     $data[] = $identifiers;
     // PV1-20: Financial Class (FC) (optional repeating)
     $data[] = $sejour->loadRefPrestation()->code;
     // PV1-21: Charge Price Indicator (IS) (optional)
     // Table - 0032
     $data[] = $sejour->loadRefChargePriceIndicator()->code;
     // PV1-22: Courtesy Code (IS) (optional)
     // Table - 0045
     // Y - Demande de chambre particulière
     // N - Pas de demande de chambre particulière
     $data[] = $sejour->chambre_seule ? "Y" : "N";
     // PV1-23: Credit Rating (IS) (optional)
     $data[] = null;
     // PV1-24: Contract Code (IS) (optional repeating)
     $data[] = null;
     // PV1-25: Contract Effective Date (DT) (optional repeating)
     $data[] = null;
     // PV1-26: Contract Amount (NM) (optional repeating)
     $data[] = $this->getPV126($receiver, $sejour);
     // PV1-27: Contract Period (NM) (optional repeating)
     $data[] = null;
     // PV1-28: Interest Code (IS) (optional)
     $data[] = null;
     // PV1-29: Transfer to Bad Debt Code (IS) (optional)
     $data[] = null;
     // PV1-30: Transfer to Bad Debt Date (DT) (optional)
     $data[] = null;
     // PV1-31: Bad Debt Agency Code (IS) (optional)
     $data[] = null;
     // PV1-32: Bad Debt Transfer Amount (NM) (optional)
     $data[] = null;
     // PV1-33: Bad Debt Recovery Amount (NM) (optional)
     $data[] = null;
     // PV1-34: Delete Account Indicator (IS) (optional)
     $data[] = null;
     // PV1-35: Delete Account Date (DT) (optional)
     $data[] = null;
     // PV1-36: Discharge Disposition (IS) (optional)
     $sejour->loadRefsAffectations();
     $data[] = $this->getPV136($receiver, $sejour);
     // PV1-37: Discharged to Location (DLD) (optional)
     $data[] = $sejour->etablissement_sortie_id && ($event->code == "A03" || $event->code == "A16" || $event->code == "A21") ? array($sejour->loadRefEtablissementTransfert()->finess) : null;
     // PV1-38: Diet Type (CE) (optional)
     $data[] = null;
     // PV1-39: Servicing Facility (IS) (optional)
     $data[] = null;
     // PV1-40: Bed Status (IS) (optional)
     // Interdit par IHE France
     $data[] = null;
     // PV1-41: Account Status (IS) (optional)
     // Utilisation que pour les événements A03 et Z99
     // Table - 0117
     // D - C'était la dernière venue pour ce dossier administratif
     // N - Ce n'était pas la dernière venue pour ce dossier administratif
     if ($event->code == "A03" || $event->code == "Z99") {
         $data[] = $sejour->type != "seances" && $sejour->sortie_reelle ? "D" : "N";
     } else {
         $data[] = null;
     }
     // PV1-42: Pending Location (PL) (optional)
     $data[] = null;
     // PV1-43: Prior Temporary Location (PL) (optional)
     $data[] = null;
     // PV1-44: Admit Date/Time (TS) (optional)
     $data[] = $sejour->entree_reelle;
     // PV1-45: Discharge Date/Time (TS) (optional repeating)
     $data[] = $sejour->sortie_reelle;
     // PV1-46: Current Patient Balance (NM) (optional)
     $data[] = null;
     // PV1-47: Total Charges (NM) (optional)
     $data[] = null;
     // PV1-48: Total Adjustments (NM) (optional)
     $data[] = null;
     // PV1-49: Total Payments (NM) (optional)
     $data[] = null;
     // PV1-50: Alternate Visit ID (CX) (optional)
     // Cas de l'utilisation du rang
     if (CAppUI::conf("dPplanningOp CSejour use_dossier_rang")) {
         $sejour->loadNRA($group->_id);
         if (CHL7v2Message::$build_mode == "simple") {
             $data[] = array($sejour->_ref_NRA->id400);
         }
     } else {
         $data[] = null;
     }
     // PV1-51: Visit Indicator (IS) (optional)
     $data[] = null;
     // PV1-52: Other Healthcare Provider (XCN) (optional repeating)
     $data[] = null;
     $this->fill($data);
 }
コード例 #5
0
 /**
  * Build ERR segement
  *
  * @param CHL7v2Event $event Event
  *
  * @return null
  */
 function build(CHL7v2Event $event)
 {
     parent::build($event);
     $version = $event->message->version;
     $error = $this->error;
     $acknowledgment = $this->acknowledgment;
     $data = array();
     if ($error) {
         // ERR-1: Error Code and Location (ELD) (optional repeating)
         if ($version < "2.5") {
             $data[] = $error->getCodeLocation();
             return $this->fill($data);
         }
         $data[] = null;
         // ERR-2: Error Location (ERL) (optional repeating)
         $data[] = array($error->getLocation());
         // ERR-3: HL7 Error Code (CWE)
         $data[] = array($error->getHL7Code());
         if ($error->level == CHL7v2Error::E_ERROR) {
             // ERR-4: Severity (ID)
             // Table - 0516
             // W - Warning - Transaction successful, but there may issues
             // I - Information - Transaction was successful but includes information e.g., inform patient
             // E - Error - Transaction was unsuccessful
             $data[] = "E";
             // ERR-5: Application Error Code (CWE) (optional)
             $data[] = array(array("E002", CAppUI::tr("CHL7Event-AR-E002")));
         } else {
             $data[] = "W";
             $data[] = array();
         }
         // ERR-6: Application Error Parameter (ST) (optional repeating)
         $data[] = null;
         // ERR-7: Diagnostic Information (TX) (optional)
         $data[] = null;
         // ERR-8: User Message (TX) (optional)
         $data[] = CAppUI::tr("CHL7v2Exception-{$error->code}") . ($error->data ? " ({$error->data})" : "");
         // ERR-9: Inform Person Indicator (IS) (optional repeating)
         $data[] = null;
         // ERR-10: Override Type (CWE) (optional)
         $data[] = null;
         // ERR-11: Override Reason Code (CWE) (optional repeating)
         $data[] = null;
         // ERR-12: Help Desk Contact Point (XTN) (optional repeating)
         $data[] = null;
     } else {
         // ERR-1: Error Code and Location (ELD) (optional repeating)
         if ($version < "2.5") {
             $data[] = array(array(null, null, null, array($acknowledgment->hl7_error_code, CHL7v2TableEntry::getDescription("357", $acknowledgment->hl7_error_code), null, $acknowledgment->_mb_error_code, CAppUI::tr("CHL7Event-{$acknowledgment->ack_code}-{$acknowledgment->_mb_error_code}"), null)));
             return $this->fill($data);
         }
         $data[] = null;
         // ERR-2
         $data[] = array(array(0, 0));
         // ERR-3
         $data[] = array(array($acknowledgment->hl7_error_code, CHL7v2TableEntry::getDescription("357", $acknowledgment->hl7_error_code)));
         // ERR-4
         $data[] = $acknowledgment->severity;
         // ERR-5
         $data[] = array(array($acknowledgment->_mb_error_code, CAppUI::tr("CHL7Event-{$acknowledgment->ack_code}-{$acknowledgment->_mb_error_code}")));
         // ERR-6
         $data[] = null;
         // ERR-7
         $data[] = null;
         // ERR-8
         $data[] = $acknowledgment->comments;
         // ERR-9
         $data[] = null;
         // ERR-10
         $data[] = null;
         // ERR-11
         $data[] = null;
         // ERR-12
         $data[] = null;
     }
     $this->fill($data);
 }
コード例 #6
0
 /**
  * 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);
 }
コード例 #7
0
 function countEntries()
 {
     $table_entry = new CHL7v2TableEntry();
     $table_entry->number = $this->number;
     return $this->_count_entries = $table_entry->countMatchingList();
 }
コード例 #8
0
 /**
  * Populating QPD-3 demographics fields
  *
  * @param CMbObject $object    Object
  * @param string    $mb_field  Field spec
  * @param string    $hl7_field The number of a field
  * @param null      $mapTo     Map to table HL7
  *
  * @return array
  */
 function setDemographicsFields(CMbObject $object, $mb_field, $hl7_field, $mapTo = null)
 {
     if (!$object->{$mb_field}) {
         return;
     }
     $seg = null;
     switch ($object->_class) {
         case "CPatient":
             $seg = "PID";
             break;
         case "CSejour":
             $seg = "PV1";
             break;
         default:
     }
     if (!$seg) {
         return;
     }
     $value = $mapTo ? CHL7v2TableEntry::mapTo($mapTo, $object->{$mb_field}) : $object->{$mb_field};
     $spec = $object->_specs[$mb_field];
     if ($spec instanceof CDateSpec || $spec instanceof CBirthDateSpec) {
         $value = CHL7v2::getDate($value);
     }
     return array("@{$seg}.{$hl7_field}", $value);
 }
コード例 #9
0
<?php

/* $Id $ */
/**
 * @package Mediboard
 * @subpackage hl7
 * @version $Revision:$
 * @author SARL OpenXtrem
 * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 */
CCanDo::checkAdmin();
$table_number = CValue::getOrSession("table_number");
$table_entry = new CHL7v2TableEntry();
$table_entry->number = $table_number;
$table_entries = $table_entry->loadMatchingList("user");
$table_entry->user = 1;
$table_description = new CHL7v2TableDescription();
$table_description->number = $table_number;
$table_description->loadMatchingObject();
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("table_entry", $table_entry);
$smarty->assign("table_description", $table_description);
$smarty->assign("table_entries", $table_entries);
$smarty->display("inc_refresh_modal_HL7_table.tpl");
コード例 #10
0
 /**
  * Get PL : person location
  *
  * @param CInteropReceiver $receiver    Receiver
  * @param CSejour          $sejour      Admit
  * @param CAffectation     $affectation Affectation
  *
  * @return array
  */
 function getPL(CInteropReceiver $receiver, CSejour $sejour, CAffectation $affectation = null)
 {
     $group = $sejour->loadRefEtablissement();
     $default_name = null;
     if ($receiver && $receiver->_id && isset($receiver->_configs)) {
         $default_name = $receiver->_configs["build_PV1_3_1_default"];
     }
     if (!$affectation) {
         // Chargement de l'affectation courante
         $affectation = $sejour->getCurrAffectation();
         // Si on n'a pas d'affectation on va essayer de chercher la première
         if (!$affectation->_id) {
             $affectation = $sejour->loadRefFirstAffectation();
         }
     }
     $affectation->loadRefLit()->loadRefChambre();
     $current_uf = $sejour->getUFs(null, $affectation->_id);
     $name = null;
     if ($receiver && $receiver->_id && isset($receiver->_configs)) {
         switch ($receiver->_configs["build_PV1_3_1"]) {
             case "UF":
                 $name = $current_uf["hebergement"]->code;
                 break;
             case "service":
                 if ($affectation->_id) {
                     $name = $affectation->loadRefService()->nom;
                 }
                 if (!$name) {
                     $name = $sejour->loadRefService()->nom;
                 }
                 break;
             default:
         }
     }
     $pl1 = $name ? $name : $default_name;
     return array(array($pl1, $this->getPL2($receiver, $affectation), $this->getPL3($receiver, $affectation), $this->getGroupAssigningAuthority($sejour->loadRefEtablissement()), $this->getPL5($receiver), null, CHL7v2TableEntry::mapTo("307", $group->_id)));
 }
 /**
  * Get PV1 QPD element
  *
  * @param DOMNode $node QPD element
  *
  * @return array
  */
 function getRequestSejour(DOMNode $node)
 {
     $PV1 = array();
     // Patient class
     if (($PV1_2 = $this->getDemographicsFields($node, "CSejour", "2")) || ($PV1_2 = $this->getDemographicsFields($node, "CSejour", "2.1"))) {
         $PV1 = array_merge($PV1, array("type" => CHL7v2TableEntry::mapFrom(4, $PV1_2)));
     }
     return $PV1;
 }
コード例 #12
0
 /**
  * Build PV2 segement
  *
  * @param CHL7v2Event $event Event
  *
  * @return null
  */
 function build(CHL7v2Event $event)
 {
     $data = array();
     $sejour = $this->sejour;
     $receiver = $event->_receiver;
     parent::build($event);
     // PV2-1: Prior Pending Location (PL) (optional)
     $data[] = null;
     // PV2-2: Accommodation Code (CE) (optional)
     $data[] = null;
     // PV2-3: Admit Reason (Psychiatrie) (CE) (optional)
     // Table - 9000
     // HL  - Hospitalisation libre
     // HO  - Placement d'office
     // HDT - Hospitalisation à la demande d'un tiers
     $triggers = array("A01", "A05", "A06", "A14", "Z99");
     if ($sejour->type == "psy" && in_array($event->code, $triggers)) {
         $data[] = CHL7v2TableEntry::mapTo("9000", $sejour->modalite);
     } else {
         $data[] = null;
     }
     // PV2-4: Transfer Reason (CE) (optional)
     $data[] = null;
     // PV2-5: Patient Valuables (ST) (optional repeating)
     $data[] = null;
     // PV2-6: Patient Valuables Location (ST) (optional)
     $data[] = null;
     // PV2-7: Visit User Code (IS) (optional repeating)
     // Table - 0130
     // TN - Nouveau médecin traitant (le patient a changé de médecin traitant ou déclaré ce médecin pour la 1ère fois)
     // TD - accès direct spécifique
     // TU - urgence: (le patient arrive aux urgences, sans recommandation du médecin traitant)
     // TH - hors résidence habituelle
     // TR - le patient est envoyé par le remplaçant du médecin traitant
     // MR - Médecin consulté = remplaçant du médecin traitant
     // TO - patient orienté par le médecin traitant (le patient consulte un autre médecin sur conseil du médecin traitant)
     // ME - consultation du médecin traitant = médecin consulté
     // 1V - 1ère consultation du médecin traitant pour avis
     // IT - soins itératifs en accord avec le médecin traitant (D162-1-6 Alinéas 1 ou 2)
     // AG - le patient a moins de 16 ans au moment de la consultation (Pas de code B2)
     // MT - le patient est envoyé par le médecin du travail de l'hôpital (Pas de code B2)
     // CS - accès hors coordination (acces sur initiative du patient sans consultation du médecin traitant)
     // SM - le patient n'a pas de médecin traitant
     // ML - Militaire sur prescription médicale des armées (Art D162-1-6 SS) (patient non envoyé par le médecin traitant)
     // EM - Exclusion médicale (tabagisme, alcoolisme, ..) (Art D162-1-6 SS) (patient non envoyé par le médecin traitant)
     // NT - Le patient est orienté par un médecin qui n'est pas son médecin traitant
     // PI - L'exécutant est un médecin généraliste primo installé récemment
     // ZD - L'exécutant est un médecin généraliste s'installant en zone médicalement déficitaire
     // AL - Actes et consultations prévus dans le cadre du protocole de soins ALD D162-1-6 Alinéa 3
     // PS - Actes et consultations intervenant dans le cadre de la permanence de soins ALD D162-1-6 Alinéa 5
     // AM - Aide médicale d'état (AME) (Pas de code B2)
     // CI - Etranger pris en charge dans le cadre de conventions internationales (Pas de code B2)
     // ET - Etranger pris en charge - autres situations (situation régulière)
     // MI - Migrants de passage (L254-1)
     // DT - Parcours de soins non actif (parcours de soins débuté avant la date d'application de la réglementation)
     // MA - Cas particulier de la caisse de Mayotte
     // AS - Autre situation
     $data[] = "TN";
     // PV2-8: Expected Admit Date/Time (TS) (optional)
     $data[] = $sejour->entree_prevue;
     // PV2-9: Expected Discharge Date/Time (TS) (optional)
     $data[] = $sejour->sortie_prevue;
     // PV2-10: Estimated Length of Inpatient Stay (NM) (optional)
     $data[] = null;
     // PV2-11: Actual Length of Inpatient Stay (NM) (optional)
     $data[] = null;
     // PV2-12: Visit Description (ST) (optional)
     $data[] = $sejour->libelle;
     // PV2-13: Referral Source Code (XCN) (optional repeating)
     $data[] = null;
     // PV2-14: Previous Service Date (DT) (optional)
     $data[] = null;
     // PV2-15: Employment Illness Related Indicator (ID) (optional)
     $data[] = null;
     // PV2-16: Purge Status Code (IS) (optional)
     $data[] = null;
     // PV2-17: Purge Status Date (DT) (optional)
     $data[] = null;
     // PV2-18: Special Program Code (IS) (optional)
     $data[] = null;
     // PV2-19: Retention Indicator (ID) (optional)
     $data[] = null;
     // PV2-20: Expected Number of Insurance Plans (NM) (optional)
     $data[] = null;
     // PV2-21: Visit Publicity Code (IS) (optional)
     $data[] = null;
     // PV2-22: Visit Protection Indicator (ID) (optional)
     // Table - 0136
     // Y - Oui - Accès protégé à l'information du patient
     // N - Non - Accès normal à l'information du patient
     $data[] = $sejour->loadRefPatient()->vip ? "Y" : "N";
     // PV2-23: Clinic Organization Name (XON) (optional repeating)
     $data[] = null;
     // PV2-24: Patient Status Code (IS) (optional)
     $data[] = null;
     // PV2-25: Visit Priority Code (IS) (optional)
     $data[] = null;
     // PV2-26: Previous Treatment Date (DT) (optional)
     $data[] = null;
     // PV2-27: Expected Discharge Disposition (IS) (optional)
     $data[] = null;
     // PV2-28: Signature on File Date (DT) (optional)
     $data[] = null;
     // PV2-29: First Similar Illness Date (DT) (optional)
     $data[] = null;
     // PV2-30: Patient Charge Adjustment Code (CE) (optional)
     $data[] = null;
     // PV2-31: Recurring Service Code (IS) (optional)
     $data[] = null;
     // PV2-32: Billing Media Code (ID) (optional)
     $data[] = null;
     // PV2-33: Expected Surgery Date and Time (TS) (optional)
     $data[] = null;
     // PV2-34: Military Partnership Code (ID) (optional)
     $data[] = null;
     // PV2-35: Military Non-Availability Code (ID) (optional)
     $data[] = null;
     // PV2-36: Newborn Baby Indicator (ID) (optional)
     $data[] = null;
     // PV2-37: Baby Detained Indicator (ID) (optional)
     $data[] = null;
     // PV2-38: Mode of Arrival Code (CE) (optional)
     // Table - 0430
     // 0 - Police
     // 1 - SAMU, SMUR terrestre
     // 2 - Ambulance publique
     // 3 - Ambulance privée
     // 4 - Taxi
     // 5 - Moyens personnels
     // 6 - SAMU, SMUR hélicoptère
     // 7 - Pompier
     // 8 - VSL
     // 9 - Autre
     if ($sejour->type == "urg") {
         $data[] = CHL7v2TableEntry::mapTo("0430", $sejour->transport);
     } else {
         $data[] = null;
     }
     // PV2-39: Recreational Drug Use Code (CE) (optional repeating)
     $data[] = null;
     // PV2-40: Admission Level of Care Code (CE) (optional)
     $data[] = null;
     // PV2-41: Precaution Code (CE) (optional repeating)
     $data[] = null;
     // PV2-42: Patient Condition Code (CE) (optional)
     $data[] = null;
     // PV2-43: Living Will Code (IS) (optional)
     $data[] = null;
     // PV2-44: Organ Donor Code (IS) (optional)
     $data[] = null;
     // PV2-45: Advance Directive Code (CE) (optional repeating)
     $data[] = null;
     // PV2-46: Patient Status Effective Date (DT) (optional)
     $data[] = null;
     // PV2-47: Expected LOA Return Date/Time (TS) (optional)
     $data[] = null;
     // PV2-48: Expected Pre-admission Testing Date/Time (TS) (optional)
     $data[] = null;
     // PV2-49: Notify Clergy Code (IS) (optional repeating)
     $data[] = null;
     $this->fill($data);
 }
コード例 #13
0
ファイル: do_receive_mllp.php プロジェクト: fbone/mediboard4
      $ERR->build($error);
      
      $message->appendChild($ERR);*/
    $now = CMbDT::format(null, "%Y%m%d%H%M%S");
    $ACK = "MSH|^~\\&|" . CAppUI::conf("hl7 sending_application") . "|" . CAppUI::conf("hl7 sending_facility") . "|||{$now}||ACK|{$now}|P|2.5||||||" . CHL7v2TableEntry::mapTo("211", CApp::$encoding);
    $ACK .= "\r" . "MSA|AR|{$now}";
    $ACK .= "\r" . "ERR||0^0|207|E|E200^Acteur inconnu|||||||";
    ob_clean();
    echo $ACK;
    CApp::rip();
}
/** @var CSenderMLLP $sender_mllp */
$sender_mllp = CMbObject::loadFromGuid($source_mllp->name);
// Dispatch EAI
try {
    $ack = CEAIDispatcher::dispatch($message, $sender_mllp);
} catch (CHL7v2Exception $e) {
    $sender_mllp->getConfigs(new CExchangeHL7v2());
    $configs = $sender_mllp->_configs;
    $now = CMbDT::format(null, "%Y%m%d%H%M%S");
    $sending_app = CAppUI::conf("hl7 sending_application");
    $sending_fac = CAppUI::conf("hl7 sending_facility");
    $recv_app = isset($configs["receiving_application"]) ? $configs["receiving_application"] : $sender_mllp->nom;
    $recv_fac = isset($configs["receiving_facility"]) ? $configs["receiving_facility"] : $sender_mllp->nom;
    $ack = "MSH|^~\\&|{$sending_app}|{$sending_fac}|{$recv_app}|{$recv_fac}|{$now}||ACK^R01^ACK|{$now}|P|2.6||||||" . CHL7v2TableEntry::mapTo("211", CApp::$encoding);
    $ack .= "\r\n" . "MSA|CR|{$now}";
    $ack .= "\r\n" . "ERR||0^0|207|E|E200^" . $e->getMessage() . "|||||||";
}
ob_clean();
echo $ack;
CApp::rip();
コード例 #14
0
 /**
  * Build MSH segement
  *
  * @param CHL7v2Event $event Event
  *
  * @return null
  */
 function build(CHL7v2Event $event)
 {
     parent::build($event);
     $message = $event->message;
     // Dans le cas d'un segment MSH la création peut-être soit : receiver / sender (ack)
     $actor = isset($event->_sender->_id) ? $event->_sender : $event->_receiver;
     $actor->loadRefGroup();
     $actor->loadConfigValues();
     $data = array();
     // MSH-1: Field Separator (ST)
     $data[] = $message->fieldSeparator;
     // MSH-2: Encoding Characters (ST)
     $data[] = substr($message->getEncodingCharacters(), 1);
     // MSH-3: Sending Application (HD) (optional)
     $data[] = CAppUI::conf("hl7 sending_application");
     // MSH-4: Sending Facility (HD) (optional)
     $data[] = CAppUI::conf("hl7 sending_facility");
     // MSH-5: Receiving Application (HD) (optional)
     $data[] = isset($actor->_configs["receiving_application"]) ? $actor->_configs["receiving_application"] : $actor->nom;
     // MSH-6: Receiving Facility (HD) (optional)
     $data[] = isset($actor->_configs["receiving_facility"]) ? $actor->_configs["receiving_facility"] : $actor->nom;
     // MSH-7: Date/Time Of Message (TS)
     $data[] = CMbDT::dateTime();
     // MSH-8: Security (ST) (optional)
     $data[] = null;
     // MSH-9: Message Type (MSG)
     $data[] = $event->msg_codes;
     // MSH-10: Message Control ID (ST)
     $data[] = $event->_exchange_hl7v2->_id;
     // MSH-11: Processing ID (PT)
     // Table 103
     // D - Debugging
     // P - Production
     // T - Training
     $data[] = CAppUI::conf("instance_role") == "prod" ? "P" : "D";
     // MSH-12: Version ID (VID)
     $data[] = CHL7v2::prepareHL7Version($event->version);
     // MSH-13: Sequence Number (NM) (optional)
     $data[] = null;
     // MSH-14: Continuation Pointer (ST) (optional)
     $data[] = null;
     // MSH-15: Accept Acknowledgment Type (ID) (optional)
     // Table 155
     // AL - Always
     // NE - Never
     // ER - Error/reject conditions only
     // SU - Successful completion only
     $data[] = null;
     // MSH-16: Application Acknowledgment Type (ID) (optional)
     // Table 155
     // AL - Always
     // NE - Never
     // ER - Error/reject conditions only
     // SU - Successful completion only
     $data[] = null;
     // MSH-17: Country Code (ID) (optional)
     // FRA = 250
     $data[] = CHL7v2TableEntry::mapTo("399", "250");
     // MSH-18: Character Set (ID) (optional repeating)
     $encoding = isset($actor->_configs["encoding"]) ? $actor->_configs["encoding"] : "UTF-8";
     $data[] = CHL7v2TableEntry::mapTo("211", $encoding);
     // MSH-19: Principal Language Of Message (CE) (optional)
     $data[] = array("FR");
     // MSH-20: Alternate Character Set Handling Scheme (ID) (optional)
     $data[] = null;
     // MSH-21: Message Profile Identifier (EI) (optional repeating)
     $data[] = null;
     $this->fill($data);
 }
コード例 #15
0
 /**
  * Récupération du mode de sortie PMSI
  *
  * @param DOMNode $node     ZFM Node
  * @param CSejour $newVenue Admit
  *
  * @return void
  */
 function getModeSortiePMSI(DOMNode $node, CSejour $newVenue)
 {
     $newVenue->mode_sortie = CHL7v2TableEntry::mapFrom("9001", $this->queryTextNode("ZFM.2", $node));
 }
コード例 #16
0
 /**
  * Build NK1 segement
  *
  * @param CHL7v2Event $event Event
  *
  * @return null
  */
 function build(CHL7v2Event $event)
 {
     parent::build($event);
     $correspondant = $this->correspondant;
     $message = $event->message;
     // NK1-1: Set ID - NK1 (SI)
     $data[] = $this->set_id;
     // NK1-2: NK Name (XPN) (optional repeating)
     $data[] = $this->getXPN($correspondant, $event->_receiver);
     // NK1-3: Relationship (CE) (optional)
     // Table 0063 - Relationship
     $relationships = array(CHL7v2TableEntry::mapTo("63", $correspondant->parente));
     if ($correspondant->parente == "autre") {
         $relationships[] = $correspondant->parente_autre;
     }
     $data[] = array($relationships);
     // NK1-4: Address (XAD) (optional repeating)
     $linesAdress = explode("\n", $correspondant->adresse, 2);
     $data[] = array(array(CValue::read($linesAdress, 0), str_replace("\n", $message->componentSeparator, CValue::read($linesAdress, 1)), $correspondant->ville, null, $correspondant->cp));
     // NK1-5: Phone Number (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 ($correspondant->tel) {
         $phones[] = array(null, "PRN", "PH", null, null, null, null, null, null, null, null, $correspondant->tel);
     }
     if ($correspondant->mob) {
         $phones[] = array(null, "PRN", "CP", null, null, null, null, null, null, null, null, $correspondant->mob);
     }
     if ($correspondant->email) {
         $phones[] = array(null, "NET", "Internet", $correspondant->email);
     }
     $data[] = $phones;
     // NK1-6: Business Phone Number (XTN) (optional repeating)
     $data[] = null;
     // NK1-7: Contact Role (CE) (optional)
     // Table - 0131
     $data[] = array(array(CHL7v2TableEntry::mapTo("131", $correspondant->relation), $correspondant->relation == "autre" ? $correspondant->relation_autre : null));
     // NK1-8: Start Date (DT) (optional)
     $data[] = null;
     // NK1-9: End Date (DT) (optional)
     $data[] = null;
     // NK1-10: Next of Kin / Associated Parties Job Title (ST) (optional)
     $data[] = null;
     // NK1-11: Next of Kin / Associated Parties Job Code/Class (JCC) (optional)
     $data[] = null;
     // NK1-12: Next of Kin / Associated Parties Employee Number (CX) (optional)
     $data[] = null;
     // NK1-13: Organization Name - NK1 (XON) (optional repeating)
     $data[] = null;
     // NK1-14: Marital Status (CE) (optional)
     $data[] = null;
     // NK1-15: Administrative Sex (IS) (optional)
     $data[] = null;
     // NK1-16: Date/Time of Birth (TS) (optional)
     $data[] = null;
     // NK1-17: Living Dependency (IS) (optional repeating)
     $data[] = null;
     // NK1-18: Ambulatory Status (IS) (optional repeating)
     $data[] = null;
     // NK1-19: Citizenship (CE) (optional repeating)
     $data[] = null;
     // NK1-20: Primary Language (CE) (optional)
     $data[] = null;
     // NK1-21: Living Arrangement (IS) (optional)
     $data[] = null;
     // NK1-22: Publicity Code (CE) (optional)
     $data[] = null;
     // NK1-23: Protection Indicator (ID) (optional)
     $data[] = null;
     // NK1-24: Student Indicator (IS) (optional)
     $data[] = null;
     // NK1-25: Religion (CE) (optional)
     // Interdit IHE France
     $data[] = null;
     // NK1-26: Mother's Maiden Name (XPN) (optional repeating)
     $data[] = null;
     // NK1-27: Nationality (CE) (optional)
     $data[] = null;
     // NK1-28: Ethnic Group (CE) (optional repeating)
     // Interdit IHE France
     $data[] = null;
     // NK1-29: Contact Reason (CE) (optional repeating)
     $data[] = null;
     // NK1-30: Contact Person's Name (XPN) (optional repeating)
     $data[] = null;
     // NK1-31: Contact Person's Telephone Number (XTN) (optional repeating)
     $data[] = null;
     // NK1-32: Contact Person's Address (XAD) (optional repeating)
     $data[] = null;
     // NK1-33: Next of Kin/Associated Party's Identifiers (CX) (optional repeating)
     $data[] = null;
     // NK1-34: Job Status (IS) (optional)
     $data[] = null;
     // NK1-35: Race (CE) (optional repeating)
     // Interdit IHE France
     $data[] = null;
     // NK1-36: Handicap (IS) (optional)
     $data[] = null;
     // NK1-37: Contact Person Social Security Number (ST) (optional)
     $data[] = null;
     // NK1-38: Next of Kin Birth Place (ST) (optional)
     $data[] = null;
     // NK1-39: VIP Indicator (IS) (optional)
     $data[] = null;
     $this->fill($data);
 }
コード例 #17
0
 /**
  * Build PID segement
  *
  * @param CHL7v2Event $event Event
  *
  * @return null
  */
 function build(CHL7v2Event $event)
 {
     parent::build($event);
     $message = $event->message;
     $receiver = $event->_receiver;
     $group = $receiver->loadRefGroup();
     $patient = $this->patient;
     $mother = null;
     $sejour_maman = null;
     $naissance = null;
     if ($patient->_naissance_id) {
         $naissance = new CNaissance();
         $naissance->load($patient->_naissance_id);
         $sejour_maman = $naissance->loadRefSejourMaman();
         $sejour_maman->loadNDA($group->_id);
         $sejour_maman->loadRefPatient()->loadIPP($group->_id);
         $mother = $sejour_maman->_ref_patient;
     }
     $data = array();
     // PID-1: Set ID - PID (SI) (optional)
     $data[] = $this->set_id;
     // PID-2: Patient ID (CX) (optional)
     $data[] = null;
     // PID-3: Patient Identifier List (CX) (repeating)
     $data[] = $this->getPersonIdentifiers($patient, $group, $receiver);
     // PID-4: Alternate Patient ID - PID (CX) (optional repeating)
     $data[] = null;
     // PID-5: Patient Name (XPN) (repeating)
     $data[] = $this->getXPN($patient, $receiver);
     // PID-6: Mother's Maiden Name (XPN) (optional repeating)
     if ($patient->nom_jeune_fille && $receiver->_configs["build_PID_6"] == "nom_naissance") {
         $anonyme = is_numeric($patient->nom);
         $mode_identito_vigilance = $receiver->_configs["mode_identito_vigilance"];
         $prenom = CPatient::applyModeIdentitoVigilance($patient->prenom, true, $mode_identito_vigilance, $anonyme);
         $nom_jf = CPatient::applyModeIdentitoVigilance($patient->nom_jeune_fille, true, $mode_identito_vigilance, $anonyme);
         $data[] = array(array($nom_jf, $prenom, null, null, null, null, null, "L"));
     } else {
         // Dans le cas d'une naissance on va mettre l'identité de la mère
         $data[] = $mother ? $this->getXPN($mother, $receiver) : null;
     }
     // PID-7: Date/Time of Birth (TS) (optional)
     if ($patient->_naissance_id) {
         $data[] = $naissance->date_time;
     } else {
         if ($patient->naissance) {
             $data[] = CMbDT::isLunarDate($patient->naissance) ? null : $patient->naissance;
         } else {
             $data[] = null;
         }
     }
     // PID-8: Administrative Sex (IS) (optional)
     // Table - 0001
     // F - Female
     // M - Male
     // O - Other
     // U - Unknown
     // A - Ambiguous
     // N - Not applicable
     $sexe = CHL7v2TableEntry::mapTo("1", $patient->sexe);
     $data[] = $sexe ?: "U";
     // 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, null, $patient->cp, CPaysInsee::getAlpha3($patient->pays_insee), "H");
     }
     if ($receiver->_configs["build_PID_11"] == "simple") {
         $address = array(reset($address));
     } else {
         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) {
         $phones[] = $this->getXTN($receiver, $patient->tel, "PRN", "PH");
     }
     if ($patient->tel2) {
         // Pour le portable on met soit PRN ou ORN
         $phones[] = $this->getXTN($receiver, $patient->tel2, $receiver->_configs["build_cellular_phone"], "CP");
     }
     if ($patient->tel_autre) {
         $phones[] = $this->getXTN($receiver, $patient->tel_autre, $receiver->_configs["build_other_residence_number"], "PH");
     }
     if ($patient->email) {
         $phones[] = array(null, "NET", "Internet", $patient->email);
     }
     if ($receiver->_configs["build_PID_13"] === "simple") {
         $phones = array(reset($phones));
     }
     $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) (table 0002)(optional)
     $data[] = $patient->situation_famille;
     // PID-17: Religion (CE) (optional)
     $data[] = null;
     // PID-18: Patient Account Number (CX) (optional)
     if ($this->sejour && $receiver->_configs["build_NDA"] == "PID_18") {
         switch ($build_PID_18 = $receiver->_configs["build_PID_18"]) {
             case 'normal':
             case 'simple':
             case 'sejour_id':
                 $sejour = $this->sejour;
                 $sejour->loadNDA($group->_id);
                 $NDA = $sejour->_NDA;
                 if ($build_PID_18 == "sejour_id" && !$sejour->_NDA) {
                     $data[] = array(array($sejour->_id, null, null, $this->getAssigningAuthority("mediboard"), "RI"));
                     break;
                 }
                 if (!$sejour->_NDA && !CValue::read($receiver->_configs, "send_not_master_NDA")) {
                     $NDA = "===NDA_MISSING===";
                 }
                 if ($build_PID_18 == "simple") {
                     $data[] = $NDA;
                 } else {
                     // Même traitement que pour l'IPP
                     switch ($receiver->_configs["build_PID_3_4"]) {
                         case 'actor':
                             $assigning_authority = $this->getAssigningAuthority("actor", null, $receiver);
                             break;
                         case 'domain':
                             // Master domain
                             $group_domain = new CGroupDomain();
                             $group_domain->group_id = $group->_id;
                             $group_domain->master = 1;
                             $group_domain->object_class = "CSejour";
                             $group_domain->loadMatchingObject();
                             $domain = $group_domain->loadRefDomain();
                             $assigning_authority = $this->getAssigningAuthority("domain", null, null, $domain);
                             break;
                         default:
                             $assigning_authority = $this->getAssigningAuthority("FINESS", $group->finess);
                             break;
                     }
                     $data[] = $NDA ? array(array($NDA, null, null, $assigning_authority, "AN")) : null;
                 }
                 break;
             default:
                 $data[] = null;
         }
     } else {
         $data[] = null;
     }
     // PID-19: SSN Number - Patient (ST) (forbidden)
     switch ($receiver->_configs["build_PID_19"]) {
         case 'matricule':
             $data[] = $patient->matricule;
             break;
         default:
             $data[] = null;
             break;
     }
     // PID-20: Driver's License Number - Patient (DLN) (optional)
     $data[] = null;
     // PID-21: Mother's Identifier (CX) (optional repeating)
     // Même traitement que pour l'IPP
     switch ($receiver->_configs["build_PID_3_4"]) {
         case 'actor':
             $assigning_authority = $this->getAssigningAuthority("actor", null, $receiver);
             break;
         default:
             $assigning_authority = $this->getAssigningAuthority("FINESS", $group->finess);
             break;
     }
     if ($this->sejour) {
         $naissance = new CNaissance();
         $naissance->sejour_enfant_id = $this->sejour->_id;
         $naissance->loadMatchingObject();
         if ($naissance->_id) {
             $sejour_maman = $naissance->loadRefSejourMaman();
             $sejour_maman->loadNDA($group->_id);
             $sejour_maman->loadRefPatient()->loadIPP($group->_id);
             $mother = $sejour_maman->_ref_patient;
             $identifiers = array();
             if ($mother->_IPP) {
                 $identifiers[] = array($mother->_IPP, null, null, $assigning_authority, "PI");
             }
             if ($sejour_maman->_NDA) {
                 $identifiers[] = array($sejour_maman->_NDA, null, null, $assigning_authority, "AN");
             }
             $data[] = $identifiers;
         } else {
             $data[] = null;
         }
     } else {
         if ($mother) {
             $identifiers = array();
             if ($mother->_IPP) {
                 $identifiers[] = array($mother->_IPP, null, null, $assigning_authority, "PI");
             }
             if ($sejour_maman->_NDA) {
                 $identifiers[] = array($sejour_maman->_NDA, null, null, $assigning_authority, "AN");
             }
             $data[] = $identifiers;
         } else {
             $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)
     switch ($receiver->_configs["build_PID_31"]) {
         case 'avs':
             $data[] = $patient->avs;
             break;
         default:
             $data[] = null;
             break;
     }
     // PID-32: Identity Reliability Code (IS) (optional repeating)
     // Table - 0445
     // VIDE  - Identité non encore qualifiée
     // PROV  - Provisoire
     // VALI  - Validé
     // DOUB  - Doublon ou esclave
     // DESA  - Désactivé
     // DPOT  - Doublon potentiel
     // DOUA  - Doublon avéré
     // COLP  - Collision potentielle
     // COLV  - Collision validée
     // FILI  - Filiation
     // CACH  - Cachée
     // ANOM  - Anonyme
     // IDVER - Identité vérifiée par le patient
     // RECD  - Reçue d'un autre domaine
     // IDRA  - Identité rapprochée dans un autre domaine
     // USUR  - Usurpation
     // HOMD  - Homonyme detecté
     // HOMA  - Homonyme avéré
     if (CAppUI::conf("dPpatients CPatient manage_identity_status", $receiver->_ref_group)) {
         //todo voir pour DPOT
         $data[] = array($patient->status, $patient->vip ? "CACH" : null);
     } else {
         $data[] = array(is_numeric($patient->nom) ? "ANOM" : "VALI");
     }
     // PID-33: Last Update Date/Time (TS) (optional)
     $data[] = $event->last_log->date;
     // 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);
 }