/** * Generate content message * * @param CAffectation $affectation Movement * @param bool $referent Is referring ? * * @return void */ function generateFromOperation(CAffectation $affectation, $referent) { $evenementsPatients = $this->documentElement; $evenementPatient = $this->addElement($evenementsPatients, "evenementPatient"); $mouvementPatient = $this->addElement($evenementPatient, "mouvementPatient"); $actionConversion = array("create" => "création", "store" => "modification", "delete" => "suppression"); $affectation->loadLastLog(); $action = $affectation->_ref_last_log->type ? $affectation->_ref_last_log->type : "create"; $this->addAttribute($mouvementPatient, "action", $actionConversion[$action]); $affectation->loadRefSejour(); $affectation->_ref_sejour->loadNDA(); $affectation->_ref_sejour->loadRefPatient(); $affectation->_ref_sejour->loadRefPraticien(); $patient = $this->addElement($mouvementPatient, "patient"); // Ajout du patient $this->addPatient($patient, $affectation->_ref_sejour->_ref_patient, $referent); $venue = $this->addElement($mouvementPatient, "venue"); // Ajout de la venue $this->addVenue($venue, $affectation->_ref_sejour, $referent); // Ajout du mouvement (1 seul dans notre cas pas l'historique) $mouvements = $this->addElement($mouvementPatient, "mouvements"); $this->addMouvement($mouvements, $affectation); // Traitement final $this->purgeEmptyElements(); }
if ($sejour->sortie_reelle) { $sortie_sejour = $sejour->sortie_reelle; } $where = array(); $where["entree"] = "<= '" . $sortie_sejour . "'"; $where["sortie"] = ">= '" . $sortie_sejour . "'"; $where["function_id"] = "IS NOT NULL"; $affectatione = new CAffectation(); /** @var CAffectation[] $blocages_lit */ $blocages_lit = $affectatione->loadList($where); $where["function_id"] = "IS NULL"; foreach ($blocages_lit as $key => $blocage) { $blocage->loadRefLit()->loadRefChambre()->loadRefService(); $where["lit_id"] = "= '{$blocage->lit_id}'"; if (!$sejour->_id && $affectatione->loadObject($where)) { $affectatione->loadRefSejour(); $affectatione->_ref_sejour->loadRefPatient(); $jusqua = CMbDT::transform($affectatione->sortie, null, "%Hh%Mmin %d-%m-%Y") . " (" . $affectatione->_ref_sejour->_ref_patient->_view; $blocage->_ref_lit->_view .= " indisponible jusqu'à " . $jusqua . ")"; } } $exchange_source = CExchangeSource::get("mediuser-" . CAppUI::$user->_id, "smtp"); $_functions = array(); if ($chir->_id) { $_functions = $chir->loadBackRefs("secondary_functions"); } $op->loadRefChir2(); $op->loadRefChir3(); $op->loadRefChir4(); if (!$op->_id) { $op->_time_op = $op->temp_operation = "00:00:00";
$list_mode_sortie = $mode_sortie->loadGroupList($where); } } $where = array(); $where["entree"] = "<= '" . CMbDT::dateTime() . "'"; $where["sortie"] = ">= '" . CMbDT::dateTime() . "'"; $where["function_id"] = "IS NOT NULL"; $affectation = new CAffectation(); /** @var CAffectation[] $blocages_lit */ $blocages_lit = $affectation->loadList($where); $where["function_id"] = "IS NULL"; foreach ($blocages_lit as $blocage) { $blocage->loadRefLit()->loadRefChambre()->loadRefService(); $where["lit_id"] = "= '{$blocage->lit_id}'"; if ($affectation->loadObject($where)) { $sejour = $affectation->loadRefSejour(); $patient = $sejour->loadRefPatient(); $blocage->_ref_lit->_view .= " indisponible jusqu'à " . CMbDT::transform($affectation->sortie, null, "%Hh%Mmin %d-%m-%Y"); $blocage->_ref_lit->_view .= " (" . $patient->_view . " (" . strtoupper($patient->sexe) . ") "; $blocage->_ref_lit->_view .= CAppUI::conf("dPurgences age_patient_rpu_view") ? $patient->_age . ")" : ")"; } } // Tableau de contraintes pour les champs du RPU // Contraintes sur le mode d'entree / provenance //$contrainteProvenance[6] = array("", 1, 2, 3, 4); $contrainteProvenance[7] = array("", 1, 2, 3, 4); $contrainteProvenance[8] = array("", 5, 8); // Contraintes sur le mode de sortie / destination $contrainteDestination["mutation"] = array("", 1, 2, 3, 4); $contrainteDestination["transfert"] = array("", 1, 2, 3, 4); $contrainteDestination["normal"] = array("", 6, 7);
$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(); } $smarty = new CSmartyDP(); $smarty->assign("affectation", $affectation); $smarty->assign("lit", $lit); $smarty->assign("lit_id", $lit_id); $smarty->assign("sejour_maman", $sejour_maman); $smarty->assign("urgence", $urgence); $smarty->assign("from_tempo", $from_tempo); $smarty->display("inc_edit_affectation.tpl");
/** * Chargement des affectations dans les couloirs */ function loadAffectationsCouloirs($where, $order = null, $praticien_id = null, $prestation_id = null) { $group_id = CGroups::loadCurrent()->_id; $systeme_presta = CAppUI::conf("dPhospi prestations systeme_prestations", "CGroups-{$group_id}"); $ljoin = array("sejour" => "affectation.sejour_id = sejour.sejour_id", "patients" => "sejour.patient_id = patients.patient_id", "users_mediboard" => "sejour.praticien_id = users_mediboard.user_id", "users" => "users.user_id = users_mediboard.user_id"); if ($praticien_id) { $where["sejour.praticien_id"] = " = '{$praticien_id}'"; } if ($order == null) { $order = "users_mediboard.function_id, sejour.entree_prevue, patients.nom, patients.prenom"; } $where["affectation.lit_id"] = " IS NULL"; $affectation = new CAffectation(); /* @var CAffectation[] $affectations*/ $affectations = $affectation->loadList($where, $order, null, null, $ljoin); $sejours = CMbObject::massLoadFwdRef($affectations, "sejour_id"); CMbObject::massLoadFwdRef($sejours, "praticien_id"); CMbObject::massLoadFwdRef($sejours, "patient_id"); $tab_affectations = array(); foreach ($affectations as $affectation) { $affectation->loadRefsAffectations(); $affectation->loadRefSejour()->loadRefPatient(); $affectation->_ref_prev->loadRefLit(); $affectation->_ref_next->loadRefLit(); $sejour =& $affectation->_ref_sejour; $sejour->loadRefPrestation(); $sejour->loadRefsOperations(); $sejour->loadNDA(); $sejour->loadRefPraticien(); $sejour->loadRefPatient(); $sejour->_ref_patient->loadRefDossierMedical(false); if ($systeme_presta == "expert" && $prestation_id) { $sejour->loadLiaisonsForPrestation($prestation_id); } // Chargement des droits CMU $sejour->getDroitsCMU(); foreach ($sejour->_ref_operations as $operation_id => $curr_operation) { $sejour->_ref_operations[$operation_id]->loadExtCodesCCAM(); } $tab_affectations[$affectation->service_id][] = $affectation; } $dossiers = CMbArray::pluck($affectations, "_ref_sejour", "_ref_patient", "_ref_dossier_medical"); CDossierMedical::massCountAntecedentsByType($dossiers, "deficience"); return $tab_affectations; }