/** * Mapping et enregistrement de la naissance * * @param CSejour $newVenue Admit * @param array $data Datas * * @return string|null */ function mapAndStoreNaissance(CSejour $newVenue, $data) { if ($this->queryTextNode("PV1.4", $data["PV1"]) != "N") { return null; } // Récupération du séjour de la maman if (!($mother_AN = $this->getANMotherIdentifier($data["PID"]))) { return CAppUI::tr("CHL7Event-AA-E227"); } $sender = $this->_ref_sender; $idex_mother = CIdSante400::getMatch("CSejour", $sender->_tag_sejour, $mother_AN); if (!$idex_mother->_id) { return CAppUI::tr("CHL7Event-AA-E228"); } $sejour_mother = new CSejour(); $sejour_mother->load($idex_mother->object_id); // Récupération de l'IPP de la maman if (!($mother_PI = $this->getPIMotherIdentifier($data["PID"]))) { return CAppUI::tr("CHL7Event-AA-E229"); } if (CIdSante400::getMatch("CPatient", $sender->_tag_patient, $mother_PI)->object_id != $sejour_mother->patient_id) { return CAppUI::tr("CHL7Event-AA-E230"); } $naissance = new CNaissance(); $naissance->sejour_enfant_id = $newVenue->_id; $naissance->sejour_maman_id = $sejour_mother->_id; $naissance->grossesse_id = $sejour_mother->grossesse_id; $naissance->loadMatchingObject(); $naissance->rang = $this->queryTextNode("PID.25", $data["PID"]); // On récupère l'entrée réelle ssi msg A01 pour indiquer l'heure de la naissance if ($this->_ref_exchange_hl7v2->code == "A01") { $naissance->date_time = $this->queryTextNode("PV1.44", $data["PV1"]); } // Notifier les autres destinataires autre que le sender $naissance->_eai_sender_guid = $sender->_guid; return $naissance->store(); }
/** * Trigger after event store * * @param CMbObject $mbObject Object * * @return void */ function onAfterStore(CMbObject $mbObject) { if (!$this->isHandled($mbObject)) { return false; } /** @var CInteropReceiver $receiver */ $receiver = $mbObject->_receiver; $receiver->getInternationalizationCode($this->transaction); // Traitement Sejour if ($mbObject instanceof CSejour) { $sejour = $mbObject; $sejour->loadRefPatient(); // Si on ne souhaite explicitement pas de synchro if ($sejour->_no_synchro) { return; } // Si on est en train de créer un séjour et qu'il s'agit d'une naissance $current_log = $sejour->loadLastLog(); if ($current_log->type == "create" && $sejour->_naissance) { return; } // Si Serveur if (CAppUI::conf('smp server')) { return; } // Si le group_id du séjour est différent de celui du destinataire if ($sejour->group_id != $receiver->group_id) { return; } // Destinataire gère seulement les non facturables if ($receiver->_configs["send_no_facturable"] == "0" && $sejour->facturable) { return; } // Destinataire gère seulement les facturables if ($receiver->_configs["send_no_facturable"] == "2" && !$sejour->facturable) { return; } // Passage du séjour d'urgence en hospit, pas de génération de A06 if ($sejour->_en_mutation) { return; } // Si on ne gère les séjours du bébé on ne transmet pas séjour si c'est un séjour enfant if (!$receiver->_configs["send_child_admit"]) { $naissance = new CNaissance(); $naissance->sejour_enfant_id = $sejour->_id; $naissance->loadMatchingObject(); if ($naissance->_id) { return; } } // Recherche si on est sur un séjour de mutation $rpu = new CRPU(); $rpu->mutation_sejour_id = $sejour->_id; $rpu->loadMatchingObject(); if ($rpu->_id) { $sejour_rpu = $rpu->loadRefSejour(); if (!$sejour->_cancel_hospitalization && $sejour_rpu->mode_sortie != "mutation") { return; } } $current_affectation = null; $code = null; // Cas où : // * on est sur un séjour d'urgences qui n'est pas le relicat // * on est en train de réaliser la mutation /** @var CRPU $rpu */ $rpu = $sejour->loadRefRPU(); if ($rpu && $rpu->_id && $rpu->sejour_id != $rpu->mutation_sejour_id && $sejour->fieldModified("mode_sortie", "mutation") && !$sejour->UHCD) { $sejour = $rpu->loadRefSejourMutation(); $sejour->loadRefPatient(); $sejour->loadLastLog(); $sejour->_receiver = $receiver; $code = "A06"; // On récupère l'affectation courante qui n'a pas été transmise (affectation suite à la mutation) $current_affectation = $sejour->getCurrAffectation(); $sejour->_ref_hl7_affectation = $current_affectation; } elseif ($sejour->fieldModified("type", "urg") && $sejour->_cancel_hospitalization) { $sejour->loadRefPatient(); $sejour->loadLastLog(); $sejour->_receiver = $receiver; $code = "A07"; // On récupère l'affectation courante qui n'a pas été transmise (affectation suite à la mutation) $current_affectation = $sejour->getCurrAffectation(); $sejour->_ref_hl7_affectation = $current_affectation; } elseif ($rpu && $rpu->mutation_sejour_id && $rpu->sejour_id != $rpu->mutation_sejour_id) { return; } $code = $code ? $code : $this->getCodeSejour($sejour); // Dans le cas d'une création et que l'on renseigne entrée réelle et sortie réelle, // il est nécessaire de créer deux flux (A01 et A03) if ($sejour->_ref_last_log->type == "create" && $sejour->entree_reelle && $sejour->sortie_reelle) { $code = "A01"; // Cas où :très souvent // * on est l'initiateur du message // * le destinataire ne supporte pas le message if (!$this->isMessageSupported($this->transaction, $this->message, $code, $receiver)) { return; } if (!$sejour->_NDA) { // Génération du NDA dans le cas de la création, ce dernier n'était pas créé if ($msg = $sejour->generateNDA()) { CAppUI::setMsg($msg, UI_MSG_ERROR); } $NDA = new CIdSante400(); $NDA->loadLatestFor($sejour, $receiver->_tag_sejour); $sejour->_NDA = $NDA->id400; } $patient = $sejour->_ref_patient; $patient->loadIPP($receiver->group_id); if (!$patient->_IPP) { if ($msg = $patient->generateIPP()) { CAppUI::setMsg($msg, UI_MSG_ERROR); } } // Cas où lors de l'entrée réelle j'ai une affectation qui n'a pas été envoyée if ($sejour->fieldModified("entree_reelle") && !$sejour->_old->entree_reelle) { $current_affectation = $sejour->getCurrAffectation(); } $this->createMovement($code, $sejour, $current_affectation); // Envoi de l'événement $this->sendITI($this->profil, $this->transaction, $this->message, $code, $sejour); $code = "A03"; } if (!$code) { return; } // Cas où : // * on est l'initiateur du message // * le destinataire ne supporte pas le message if (!$this->isMessageSupported($this->transaction, $this->message, $code, $receiver)) { return; } if (!$sejour->_NDA) { // Génération du NDA dans le cas de la création, ce dernier n'était pas créé if ($msg = $sejour->generateNDA()) { CAppUI::setMsg($msg, UI_MSG_ERROR); } $NDA = new CIdSante400(); $NDA->loadLatestFor($sejour, $receiver->_tag_sejour); $sejour->_NDA = $NDA->id400; } $patient = $sejour->_ref_patient; $patient->loadIPP($receiver->group_id); if (!$patient->_IPP) { if ($msg = $patient->generateIPP()) { CAppUI::setMsg($msg, UI_MSG_ERROR); } } // Cas où lors de l'entrée réelle j'ai une affectation qui n'a pas été envoyée if ($sejour->fieldModified("entree_reelle") && !$sejour->_old->entree_reelle) { $current_affectation = $sejour->getCurrAffectation(); } $this->createMovement($code, $sejour, $current_affectation); // Envoi de l'événement $this->sendITI($this->profil, $this->transaction, $this->message, $code, $sejour); } // Traitement Affectation if ($mbObject instanceof CAffectation) { $affectation = $mbObject; $current_log = $affectation->_ref_current_log; if (!$current_log || $affectation->_no_synchro || !in_array($current_log->type, array("create", "store"))) { return; } // Affectation non liée à un séjour $sejour = $affectation->loadRefSejour(); if (!$sejour->_id) { return; } // Destinataire gère seulement les non facturables if ($receiver->_configs["send_no_facturable"] == "0" && $sejour->facturable) { return; } // Destinataire gère seulement les facturables if ($receiver->_configs["send_no_facturable"] == "2" && !$sejour->facturable) { return; } // Première affectation des urgences on ne la transmet pas, seulement pour l'évènement de bascule // Sauf si nous sommes dans un séjour d'UHCD if ($affectation->_mutation_urg && !$sejour->UHCD) { return; } // Si on ne gère les séjours du bébé on ne transmet pas l'affectation si c'est un séjour enfant if (!$receiver->_configs["send_child_admit"]) { $naissance = new CNaissance(); $naissance->sejour_enfant_id = $sejour->_id; $naissance->loadMatchingObject(); if ($naissance->_id) { return; } } // Pas d'envoie d'affectation si la patient n'est pas sortie des urgences $rpu = new CRPU(); $rpu->mutation_sejour_id = $sejour->_id; $rpu->loadMatchingObject(); if ($rpu->_id) { $sejour_rpu = $rpu->loadRefSejour(); if (!$affectation->_mutation_urg && $sejour_rpu->mode_sortie != "mutation") { return; } } // Pas d'envoie d'affectation pour les séjours reliquats // Sauf si le séjour est en UHCD $rpu = $sejour->loadRefRPU(); if ($rpu && $rpu->mutation_sejour_id && $rpu->sejour_id != $rpu->mutation_sejour_id && !$sejour->UHCD) { return; } // Si le group_id du séjour est différent de celui du destinataire if ($sejour->group_id != $receiver->group_id) { return; } // On envoie pas les affectations prévisionnelles if (!$receiver->_configs["send_provisional_affectation"] && $sejour->_etat == "preadmission") { return; } $first_affectation = $sejour->loadRefFirstAffectation(); $code = $this->getCodeAffectation($affectation, $first_affectation); // Cas où : // * on est l'initiateur du message // * le destinataire ne supporte pas le message if (!$this->isMessageSupported($this->transaction, $this->message, $code, $receiver)) { return; } $sejour->loadRefPatient(); $sejour->_receiver = $receiver; $patient = $sejour->_ref_patient; $patient->loadIPP($receiver->group_id); if (!$patient->_IPP) { if ($msg = $patient->generateIPP()) { CAppUI::setMsg($msg, UI_MSG_ERROR); } } $this->createMovement($code, $sejour, $affectation); $service = $affectation->loadRefService(); $curr_affectation = $sejour->loadRefCurrAffectation(); // On envoie pas de mouvement antérieur à la dernière affectation if (($service->uhcd || $service->radiologie || $service->urgence) && $affectation->sortie < $curr_affectation->sortie) { return; } // Ne pas envoyer la sortie si le séjour a une entrée réelle et si on modifie ou créé un affectation if (!$receiver->_configs["send_expected_discharge_with_affectation"] && $sejour->entree_reelle) { $sejour->sortie_prevue = null; } // Envoi de l'événement $this->sendITI($this->profil, $this->transaction, $this->message, $code, $mbObject); } // Traitement Naissance if ($mbObject instanceof CNaissance) { $current_log = $mbObject->loadLastLog(); if ($current_log->type != "create") { return; } $naissance = $mbObject; if (!$this->isMessageSupported($this->transaction, $this->message, "A28", $receiver)) { return; } $sejour_enfant = $naissance->loadRefSejourEnfant(); // Création du bébé $enfant = $sejour_enfant->_ref_patient; $enfant->loadIPP($receiver->group_id); $enfant->_receiver = $receiver; $enfant->_naissance_id = $naissance->_id; if (!$enfant->_IPP) { if ($msg = $enfant->generateIPP()) { CAppUI::setMsg($msg, UI_MSG_ERROR); } } // Envoi pas les patients qui n'ont pas d'IPP if (!$receiver->_configs["send_all_patients"] && !$enfant->_IPP) { return; } // Envoi du A28 pour la création du bébé $this->sendITI($this->profil, $this->transaction, $this->message, "A28", $enfant); $enfant->_IPP = null; // Si on gère les séjours du bébé on transmet le séjour ! if ($receiver->_configs["send_child_admit"]) { $sejour_enfant->_receiver = $receiver; // Si le group_id du séjour est différent de celui du destinataire if ($sejour_enfant->group_id != $receiver->group_id) { return; } $code = $this->getCodeBirth($sejour_enfant); // Cas où : // * on est l'initiateur du message // * le destinataire ne supporte pas le message if (!$this->isMessageSupported($this->transaction, $this->message, $code, $receiver)) { return; } if (!$sejour_enfant->_NDA) { // Génération du NDA dans le cas de la création, ce dernier n'était pas créé if ($msg = $sejour_enfant->generateNDA()) { CAppUI::setMsg($msg, UI_MSG_ERROR); } $NDA = new CIdSante400(); $NDA->loadLatestFor($sejour_enfant, $receiver->_tag_sejour); $sejour_enfant->_NDA = $NDA->id400; } $current_affectation = null; // Cas où lors de l'entrée réelle j'ai une affectation qui n'a pas été envoyée if ($sejour_enfant->fieldModified("entree_reelle") && !$sejour_enfant->_old->entree_reelle) { $current_affectation = $sejour_enfant->getCurrAffectation(); } $this->createMovement($code, $sejour_enfant, $current_affectation); // Envoi de l'événement $this->sendITI($this->profil, $this->transaction, $this->message, $code, $sejour_enfant); } } }
/** * 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); }
CCanDo::checkEdit(); $affectation_id = CValue::get("affectation_id"); $lit_id = CValue::get("lit_id"); $urgence = CValue::get("urgence"); $from_tempo = CValue::get("from_tempo", 0); $affectation = new CAffectation(); $affectation->load($affectation_id); $lit = new C**t(); $lit->load($affectation->lit_id); if ($urgence) { $service_urgence = CGroups::loadCurrent()->service_urgences_id; $affectation->function_id = $service_urgence; } $sejour_maman = null; if (CModule::getActive("maternite") && $affectation->sejour_id) { $naissance = new CNaissance(); $naissance->sejour_enfant_id = $affectation->sejour_id; $naissance->loadMatchingObject(); if ($naissance->_id) { $sejour_maman = $naissance->loadRefSejourMaman(); $sejour_maman->loadRefPatient(); } } if ($affectation->_id) { $affectation->loadRefSejour()->loadRefPatient(); } else { $affectation->lit_id = $lit_id; $lit->load($lit_id); $lit->loadRefChambre()->loadRefService(); $affectation->entree = CMbDT::dateTime(); }
/** * 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); }
/** * Birth's counter * * @return int */ static function countNaissances() { $group_id = CGroups::loadCurrent()->_id; $where = array("fausse_couche IS NULL OR fausse_couche = 'sup_15'", "DATE_FORMAT(naissance, '%Y') = " . CMbDT::transform(CMbDT::date(), null, "%Y"), "num_naissance IS NOT NULL", "sejour.group_id = '{$group_id}'"); $ljoin = array("sejour" => "naissance.sejour_enfant_id = sejour.sejour_id", "patients" => "sejour.patient_id = patients.patient_id"); $naissance = new CNaissance(); return $naissance->countList($where, null, $ljoin); }
$naissance = new CNaissance(); $naissance->sejour_maman_id = $sejour_maman_id; $naissance->sejour_enfant_id = $sejour_enfant->_id; $naissance->operation_id = $operation_id; $naissance->grossesse_id = $grossesse->_id; $naissance->rang = $rang; $naissance->_heure = $heure; $naissance->date_time = "{$date} {$heure}"; $naissance->hors_etab = $hors_etab; $naissance->num_naissance = $num_naissance; $naissance->fausse_couche = $fausse_couche; $naissance->rques = $rques; storeObject($naissance); } else { $validation_naissance = false; $naissance = new CNaissance(); $naissance->load($naissance_id); $naissance->rang = $rang; $naissance->hors_etab = $hors_etab; $naissance->num_naissance = $num_naissance; $naissance->fausse_couche = $fausse_couche; $naissance->rques = $rques; if (!$naissance->date_time && $date_time) { $validation_naissance = true; $naissance->operation_id = $operation_id; } $naissance->date_time = $date_time; storeObject($naissance); $sejour = $naissance->loadRefSejourEnfant(); $patient = new CPatient(); $patient->load($sejour->patient_id);
* @link http://www.mediboard.org */ $naissance_id = CValue::get("naissance_id"); $sejour_id = CValue::get("sejour_id"); $operation_id = CValue::get("operation_id"); $provisoire = CValue::get("provisoire", 0); $sejour_id = CValue::get("sejour_id"); $callback = CValue::get("callback"); $constantes = new CConstantesMedicales(); $patient = new CPatient(); $patient->naissance = CMbDT::date(); $sejour = new CSejour(); $sejour->load($sejour_id); $parturiente = $sejour->loadRefPatient(); $anonmymous = $parturiente ? is_numeric($parturiente->nom) : false; $naissance = new CNaissance(); if ($naissance_id) { $naissance->load($naissance_id); // Quand la naissance existe, le praticien à modifier est // celui du séjour de l'enfant. $sejour = $naissance->loadRefSejourEnfant(); $patient = $sejour->loadRefPatient(); $constantes = $patient->getFirstConstantes(); // Heure courante sur la naissance et date courante sur le patient // pour transformer le dossier provisoire en naissance if (!$naissance->date_time) { $naissance->date_time = CMbDT::dateTime(); $patient->naissance = CMbDT::date(); } } else { if (!$provisoire) {
/** * 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[] = $sejour->facturable ? "F" : "N"; // 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) $naissance = new CNaissance(); $naissance->sejour_enfant_id = $sejour->_id; $naissance->loadMatchingObject(); // Cas d'une naissance $data[] = $naissance->_id ? "Y" : "N"; // 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[] = $this->getPV245($receiver, $sejour); // PV2-46: Patient Status Effective Date (DT) (optional) $data[] = null; // PV2-47: Expected LOA Return Date/Time (TS) (optional) if ($event->code == "A21" && $this->curr_affectation) { $data[] = $this->curr_affectation->sortie; } else { $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); }
<?php /** * $Id$ * * @category Maternite * @package Mediboard * @author SARL OpenXtrem <*****@*****.**> * @license OXOL, see http://www.mediboard.org/public/OXOL * @version $Revision$ * @link http://www.mediboard.org */ $start = CValue::get('start', CMbDT::date()); $end = CValue::get('end', CMbDT::date()); $simulation = CValue::get('simulation'); $naissance = new CNaissance(); $where = array(); $where[] = "date_time BETWEEN '{$start} 00:00:00' AND '{$end} 23:59:59' "; $where["by_caesarean"] = " != '1' "; /** @var CNaissance[] $naissances */ $naissances = $naissance->loadList($where); foreach ($naissances as $key => $_naissance) { $bloc = $_naissance->loadRefOperation()->loadRefSalle()->loadRefBloc(); if ($bloc->_id && $bloc->type == 'obst') { unset($naissances[$key]); continue; } } $smarty = new CSmartyDP(); $smarty->assign("naissances", $naissances); $smarty->assign("naissance", $naissance);
// 3. Créer la naissance $patient = new CPatient(); $patient->nom = $nom ? $nom : $parturiente->nom; $patient->prenom = $prenom ? $prenom : "provi"; $patient->civilite = "enf"; $patient->naissance = $terme_prevu; storeObject($patient); if (!$prenom) { $patient->prenom = $patient->_id; $patient->store(); } $sejour_enfant = new CSejour(); $sejour_enfant->patient_id = $patient->_id; $sejour_enfant->entree_prevue = CMbDT::dateTime(); $sejour_enfant->sortie_prevue = max($sejour_enfant->entree_prevue, $sejour->sortie); $sejour_enfant->praticien_id = $praticien_id ? $praticien_id : $sejour->praticien_id; $sejour_enfant->group_id = $sejour->group_id; $sejour_enfant->_naissance = true; storeObject($sejour_enfant); $naissance = new CNaissance(); $naissance->grossesse_id = $grossesse->_id; $naissance->sejour_maman_id = $sejour->_id; $naissance->sejour_enfant_id = $sejour_enfant->_id; $naissance->operation_id = $operation_id; $naissance->num_naissance = CAppUI::conf("maternite CNaissance num_naissance") + $naissance->countList(); storeObject($naissance); echo CAppUI::getMsg(); if ($callback) { CAppUI::callbackAjax($callback); } CApp::rip();