global $m, $current_m; if (!isset($current_m)) { $current_m = CValue::get("current_m", $m); } $date_planning = CValue::getOrSession("date_planning", CMbDT::date()); $praticien_id = CValue::getOrSession("planning_chir_id"); $bloc_id = CValue::getOrSession("bloc_id", ""); $show_cancelled = CValue::getOrSession("show_cancelled", 0); $show_operations = CValue::getOrSession("show_operations", 1); $praticiens = new CMediusers(); $praticiens = $praticiens->loadPraticiens(); CMbObject::massLoadFwdRef($praticiens, "function_id"); foreach ($praticiens as $_prat) { $_prat->loadRefFunction(); } $plageOp = new CPlageOp(); $plageOp->canDo(); $bloc = new CBlocOperatoire(); $blocs = $bloc->loadGroupList(); $limit_date = null; $days_limit_future = abs(CAppUI::pref("planning_resa_days_limit")); if ($days_limit_future != 0) { $limit_date = CMbDT::date("+ {$days_limit_future} DAYS", CMbDT::date()); } $limit_past_date = null; $days_limit_past = abs(CAppUI::pref("planning_resa_past_days_limit")); if ($days_limit_past != 0) { $limit_past_date = CMbDT::date("- {$days_limit_past} DAYS", CMbDT::date()); } $smarty = new CSmartyDP("modules/reservation"); $smarty->assign("current_m", $current_m);
} // Création du tableau de visualisation $affichages = array(); foreach ($listDays as $keyDate => $valDate) { foreach (CPlageOp::$hours as $keyHours => $valHours) { foreach (CPlageOp::$minutes as $keyMins => $valMins) { // Initialisation du tableau $affichages["{$keyDate}-{$valHours}:{$valMins}:00"] = "empty"; $affichages["{$keyDate}-HorsPlage"] = array(); } } } $listPlages = array(); $operation = new COperation(); $nbIntervHorsPlage = 0; $listPlage = new CPlageOp(); $nbIntervNonPlacees = 0; foreach ($listDays as $keyDate => $valDate) { // Récupération des plages par jour $where = array(); $where["date"] = "= '{$keyDate}'"; $where["salle_id"] = "= '{$salle->_id}'"; $order = "debut"; $listPlages[$keyDate] = $listPlage->loadList($where, $order); // Récupération des interventions hors plages du jour $where = array(); $where["date"] = "= '{$keyDate}'"; $where["annulee"] = "= '0'"; $where["salle_id"] = "= '{$salle->_id}'"; $order = "time_operation"; /** @var COperation[] $horsPlages */
/** * Charge la liste de plages et opérations pour un jour donné * Analogue à CMediusers::loadRefsForDay * * @param string $date Date to look for * @param bool $second_chir Use chir_2, chir_3 and chir_4 * * @return void */ function loadRefsForDay($date, $second_chir = false) { // Liste des utilisateurs $user = new CMediusers(); $listPrats = $user->loadPraticiens(PERM_READ); // Liste des fonctions $function = new CFunctions(); $listFunctions = $function->loadListWithPerms(PERM_READ); // Plages d'opérations $plage = new CPlageOp(); $conf_chambre_operation = $plage->conf("chambre_operation"); $ljoin = array(); $add_where = ""; $add_or_where = ""; if ($second_chir) { $ljoin["operations"] = "plagesop.plageop_id = operations.plageop_id"; $prepare_prats = CSQLDataSource::prepareIn(array_keys($listPrats)); $add_where = "operations.chir_id " . $prepare_prats . " OR operations.chir_2_id " . $prepare_prats . " OR operations.chir_3_id " . $prepare_prats . " OR operations.chir_4_id " . $prepare_prats; $add_or_where = " OR {$add_where}"; } $where = array(); $where["plagesop.date"] = "= '{$date}'"; $where["plagesop.salle_id"] = "= '{$this->_id}'"; $where[] = "`plagesop`.`chir_id` " . CSQLDataSource::prepareIn(array_keys($listPrats)) . " OR `plagesop`.`spec_id` " . CSQLDataSource::prepareIn(array_keys($listFunctions)) . $add_or_where; $order = "debut"; $this->_ref_plages = $plage->loadList($where, $order, null, "plageop_id", $ljoin); // Chargement d'optimisation CMbObject::massLoadFwdRef($this->_ref_plages, "chir_id"); CMbObject::massLoadFwdRef($this->_ref_plages, "anesth_id"); CMbObject::massLoadFwdRef($this->_ref_plages, "spec_id"); CMbObject::massLoadFwdRef($this->_ref_plages, "salle_id"); CMbObject::massCountBackRefs($this->_ref_plages, "notes"); CMbObject::massCountBackRefs($this->_ref_plages, "affectations_personnel"); foreach ($this->_ref_plages as $_plage) { /** @var CPlageOp $_plage */ $_plage->loadRefChir(); $_plage->loadRefAnesth(); $_plage->loadRefSpec(); $_plage->loadRefSalle(); $_plage->makeView(); $_plage->loadRefsOperations(); $_plage->loadRefsNotes(); $_plage->loadAffectationsPersonnel(); $_plage->_unordered_operations = array(); // Chargement d'optimisation CMbObject::massLoadFwdRef($_plage->_ref_operations, "chir_id"); $sejours = CMbObject::massLoadFwdRef($_plage->_ref_operations, "sejour_id"); CMbObject::massLoadFwdRef($sejours, "patient_id"); foreach ($_plage->_ref_operations as $operation) { $operation->loadRefAnesth(); $operation->loadRefChirs(); $operation->loadRefPatient(); $operation->loadExtCodesCCAM(); $operation->loadRefPlageOp(); if ($conf_chambre_operation) { $operation->loadRefAffectation(); } // Extraire les interventions non placées if ($operation->rank == 0) { $_plage->_unordered_operations[$operation->_id] = $operation; unset($_plage->_ref_operations[$operation->_id]); } } } // Interventions déplacés $deplacee = new COperation(); $ljoin = array(); $ljoin["plagesop"] = "operations.plageop_id = plagesop.plageop_id"; $where = array(); $where["operations.plageop_id"] = "IS NOT NULL"; $where["plagesop.salle_id"] = "!= operations.salle_id"; $where["plagesop.date"] = "= '{$date}'"; $where["operations.salle_id"] = "= '{$this->_id}'"; $where[] = "`plagesop`.`chir_id` " . CSQLDataSource::prepareIn(array_keys($listPrats)) . " OR `plagesop`.`spec_id` " . CSQLDataSource::prepareIn(array_keys($listFunctions)) . $add_or_where; $order = "operations.time_operation"; $this->_ref_deplacees = $deplacee->loadList($where, $order, null, "operation_id", $ljoin); // Chargement d'optimisation CMbObject::massLoadFwdRef($this->_ref_deplacees, "chir_id"); $sejours_deplacees = CMbObject::massLoadFwdRef($this->_ref_deplacees, "sejour_id"); CMbObject::massLoadFwdRef($sejours_deplacees, "patient_id"); foreach ($this->_ref_deplacees as $_deplacee) { /** @var COperation $_deplacee */ $_deplacee->loadRefChirs(); $_deplacee->loadRefPatient(); $_deplacee->loadExtCodesCCAM(); $_deplacee->loadRefPlageOp(); } // Hors plage $urgence = new COperation(); $ljoin = array(); $ljoin["plagesop"] = "operations.plageop_id = plagesop.plageop_id"; $where = array(); $where["operations.date"] = "= '{$date}'"; $where["operations.plageop_id"] = "IS NULL"; $where["operations.salle_id"] = "= '{$this->_id}'"; if ($second_chir) { $where[] = $add_where; } else { $where["operations.chir_id"] = CSQLDataSource::prepareIn(array_keys($listPrats)); } $order = "time_operation, chir_id"; $this->_ref_urgences = $urgence->loadList($where, $order, null, "operation_id"); // Chargement d'optimisation CMbObject::massLoadFwdRef($this->_ref_urgences, "chir_id"); $sejours_urgences = CMbObject::massLoadFwdRef($this->_ref_urgences, "sejour_id"); CMbObject::massLoadFwdRef($sejours_urgences, "patient_id"); foreach ($this->_ref_urgences as $_urgence) { /** @var COperation $_urgence */ $_urgence->loadRefChirs(); $_urgence->loadRefPatient(); $_urgence->loadExtCodesCCAM(); $_urgence->loadRefPlageOp(); if ($conf_chambre_operation) { $_urgence->loadRefAffectation(); } } }
} } // Instanciation du planning $planning = new CPlanningWeek($debut, $debut, $fin, $nbjours, false, null, null, true); if ($user->load($chirSel)) { $planning->title = $user->load($chirSel)->_view; } else { $planning->title = ""; } $planning->guid = $mediuser->_guid; $planning->hour_min = "07"; $planning->hour_max = "20"; $planning->pauses = array("07", "12", "19"); $hours = CPlageconsult::$hours; $plageConsult = new CPlageconsult(); $plageOp = new CPlageOp(); $plagesConsult = array(); $plagesOp = array(); $hours_stop = CPlageconsult::$hours_stop; $hours_start = CPlageconsult::$hours_start; $where = array(); $where["chir_id"] = "= '{$chirSel}'"; $last_day = CMbDT::date("+7 day", $debut); //plages consult $plagesConsult = $plageConsult->loadForDays($chirSel, $debut, $last_day); $color = "#BFB"; foreach ($plagesConsult as $_consult) { $_consult->loadFillRate(); $_consult->countPatients(); $_consult->loadRefChir(); $class = null;
if (!$resp_bloc) { $where[] = "date >= '" . CMbDT::date() . "'"; } $order = "date, debut"; $plage = new CPlageOp(); $listPlages = array(); foreach ($blocs as $_bloc) { $where["salle_id"] = CSQLDataSource::prepareIn(array_keys($_bloc->_ref_salles)); $listPlages[$_bloc->_id] = $plage->loadList($where, $order); if (!count($listPlages[$_bloc->_id])) { unset($listPlages[$_bloc->_id]); } } $time = explode(":", $curr_op_time); $nb_secondes = $time[0] * 3600 + $time[1] * 60; $_plage = new CPlageOp(); foreach ($listPlages as &$_bloc) { foreach ($_bloc as &$_plage) { $_plage->loadRefSalle(); $_plage->multicountOperations($nb_secondes, false); $_plage->loadRefsNotes(); $_plage->loadRefSpec(1); } } // Heures d'admission $config = CAppUI::conf("dPplanningOp CSejour"); $hours = range($config["heure_deb"], $config["heure_fin"]); $mins = range(0, 59, $config["min_intervalle"]); $heure_entree_veille = $config["heure_entree_veille"]; $heure_entree_jour = $config["heure_entree_jour"]; // Horaire souhaité
CCanDo::checkRead(); $deb_personnel = CValue::getOrSession("deb_personnel", CMbDT::date("-1 WEEK")); $fin_personnel = CValue::getOrSession("fin_personnel", CMbDT::date("")); $prat_personnel = CValue::getOrSession("prat_personnel", null); CView::enforceSlave(); $user = CMediusers::get(); $listPrats = $user->loadPraticiens(PERM_READ); $total["duree_prevue"] = "00:00:00"; $total["days_duree_prevue"] = 0; $total["duree_first_to_last"] = "00:00:00"; $total["days_duree_first_to_last"] = 0; $total["duree_reelle"] = "00:00:00"; $total["days_duree_reelle"] = 0; $total["personnel"] = array("iade" => array("days_duree" => 0, "duree" => "00:00:00"), "op" => array("days_duree" => 0, "duree" => "00:00:00"), "op_panseuse" => array("days_duree" => 0, "duree" => "00:00:00")); // Récupération des plages $plage = new CPlageOp(); $listPlages = array(); if ($prat_personnel) { $where = array(); $where["date"] = "BETWEEN '{$deb_personnel}' AND '{$fin_personnel}'"; $where["chir_id"] = "= '{$prat_personnel}'"; $order = "date, salle_id, debut"; /** @var CPlageOp[] $listPlages */ $listPlages = $plage->loadList($where, $order); // Récupération des interventions foreach ($listPlages as &$curr_plage) { /* * Chargement des interventions et des éléments suivants : * - durée prévue * - nombre d'interventions * - nombre d'interventions valides
CStoredObject::massLoadBackRefs($operations, "workflow"); $sejours = CStoredObject::massLoadFwdRef($operations, "sejour_id"); $affectations = CStoredObject::massLoadBackRefs($sejours, "affectations"); CStoredObject::massLoadFwdRef($affectations, "lit_id"); $patients = CStoredObject::massLoadFwdRef($sejours, "patient_id"); $dossiers = CStoredObject::massLoadBackRefs($patients, "dossier_medical"); CDossierMedical::massCountAllergies($dossiers); // Récupération des commentaires $commentaire = new CCommentairePlanning(); $where = array(); $where["debut"] = " <= '{$date_planning} 23:59:59'"; $where["fin"] = " >= '{$date_planning} 00:00:00'"; $where["salle_id"] = CSQLDataSource::prepareIn($salles_ids); $commentaires = $commentaire->loadListWithPerms(PERM_READ, $where); // Récupération des plages opératoires $plageop = new CPlageOp(); $where = array(); $where["date"] = " = '{$date_planning}'"; $where["salle_id"] = CSQLDataSource::prepareIn($salles_ids); $plages = $plageop->loadListWithPerms(PERM_READ, $where); // Création du planning $planning = new CPlanningWeek(0, 0, count($salles), count($salles), false, "auto"); $planning->title = "Planning du " . CMbDT::format($date_planning, CAppUI::conf("longdate")); //load the current bloc if (isset($current_bloc)) { $planning->title .= " - {$current_bloc->nom}"; } $planning->guid = "planning_interv"; $planning->hour_min = str_pad(CAppUI::conf("reservation debut_planning"), 2, 0, STR_PAD_LEFT); $planning->dragndrop = $planning->resizable = CCanDo::edit() ? 1 : 0; //hack for "false => 0"
<?php /** * $Id$ * * @category Cabinet * @package Mediboard * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ * @link http://www.mediboard.org */ CCanDo::checkRead(); $plage_id = CValue::get("plage_id"); $object = new CPlageOp(); $object->load($plage_id); $object->loadRefsNotes(); $object->loadRefChir()->loadRefFunction(); $object->loadRefAnesth()->loadRefFunction(); $object->loadRefSpec(); $object->loadRefsOperations(); $object->loadRefSalle(); foreach ($object->_ref_operations as $_op) { $_op->loadRefPatient()->loadRefPhotoIdentite(); } // smarty $smarty = new CSmartyDP(); $smarty->assign("object", $object); $smarty->display("inc_vw_plageop.tpl");
/** * Récupération de la plage de l'intervention * * @param DOMNode $node Node * @param COperation $operation Intervention * * @return void */ function mappingPlage(DOMNode $node, COperation $operation) { $debut = $this->getDebutInterv($node); // Traitement de la date/heure début, et durée de l'opération $date_op = CMbDT::date($debut); $time_op = CMbDT::time($debut); // Recherche d'une éventuelle plageOp avec la salle $plageOp = new CPlageOp(); $plageOp->chir_id = $operation->chir_id; $plageOp->salle_id = $operation->salle_id; $plageOp->date = $date_op; $plageOps = $plageOp->loadMatchingList(); // Si on a pas de plage on recherche éventuellement une plage dans une autre salle if (count($plageOps) == 0) { $plageOp->salle_id = null; $plageOps = $plageOp->loadMatchingList(); // Si on retrouve des plages alors on ne prend pas en compte la salle du flux if (count($plageOps) > 0) { $operation->salle_id = null; } } foreach ($plageOps as $_plage) { // Si notre intervention est dans la plage Mediboard if (CMbRange::in($time_op, $_plage->debut, $_plage->fin)) { $plageOp = $_plage; break; } } if ($plageOp->_id) { $operation->plageop_id = $plageOp->_id; } else { // Dans le cas où l'on avait une plage sur l'interv on la supprime $operation->plageop_id = ""; $operation->date = $date_op; } }
$filter->_date_min = CValue::get("_date_min", $now); $filter->_date_max = CValue::get("_date_max", $now); $filter->_prat_id = CValue::get("_prat_id"); $filter->_plage = CValue::get("_plage"); $filter->_ranking = CValue::get("_ranking"); $filter->_cotation = CValue::get("_cotation"); $filter->_specialite = CValue::get("_specialite"); $filter->_codes_ccam = CValue::get("_codes_ccam"); $filter->_ccam_libelle = CValue::get("_ccam_libelle", 1); $filterSejour = new CSejour(); $filterSejour->type = CValue::get("type"); $filterSejour->ald = CValue::get("ald"); $group = CGroups::loadCurrent(); //On sort les plages opératoires // Chir - Salle - Horaires $plage = new CPlageOp(); $where = array(); $where["date"] = $ds->prepare("BETWEEN %1 AND %2", $filter->_date_min, $filter->_date_max); $order = "date, salle_id, debut"; $chir_id = CValue::get("chir"); $user = CMediusers::get(); // En fonction du praticien if ($filter->_prat_id) { $where["chir_id"] = $ds->prepare("= %", $filter->_prat_id); } // En fonction de la salle $listBlocs = $group->loadBlocs(PERM_READ); $salle = new CSalle(); $whereSalle = array('bloc_id' => CSQLDataSource::prepareIn(array_keys($listBlocs))); $listSalles = $salle->loadListWithPerms(PERM_READ, $whereSalle); $where["salle_id"] = CSQLDataSource::prepareIn(array_keys($listSalles), $filter->salle_id);
/** * $Id:$ * * @package Mediboard * @subpackage dPpersonnel * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision:$ */ CCanDo::checkEdit(); if (!($plageop_id = CValue::getOrSession("plageop_id"))) { CAppUI::setMsg("Vous devez choisir une plage opératoire", UI_MSG_WARNING); CAppUI::redirect("m=dPbloc&tab=vw_edit_planning"); } // Infos sur la plage opératoire $plage = new CPlageOp(); $plage->load($plageop_id); if (!$plage->temps_inter_op) { $plage->temps_inter_op = "00:00:00"; } // liste des anesthesistes $mediuser = new CMediusers(); $listAnesth = $mediuser->loadListFromType(array("Anesthésiste")); // Chargement du personnel $listPers = $plage->loadPersonnelDisponible(null, true); $affectations_plage = $plage->_ref_affectations_personnel; // Création du template $smarty = new CSmartyDP(); $smarty->assign("affectations_plage", $affectations_plage); $smarty->assign("listPers", $listPers); $smarty->assign("listAnesth", $listAnesth);
/** * @see parent::mine */ function mine($salle_id, $date) { parent::mine($salle_id, $date); // plages $plage_op = new CPlageOp(); $plage_op->date = $date; $plage_op->salle_id = $salle_id; /** @var CPlageOp[] $plages */ $plages = $plage_op->loadMatchingList(); $plages_to_use = array(); $range_plage = array(); foreach ($plages as $kp => $_plage) { if ($_plage->debut >= $_plage->fin) { continue; } $plages_to_use[$kp] = $_plage; CMbRange::union($range_plage, array("lower" => $_plage->debut, "upper" => $_plage->fin)); } $this->nb_plages_planned = count($plages); $this->nb_plages_planned_valid = count($plages_to_use); $this->cumulative_plages_planned = 0; foreach ($range_plage as $_range) { $this->cumulative_plages_planned += CMbDT::minutesRelative($_range["lower"], $_range["upper"]); } // interventions $interv = new COperation(); $interv->salle_id = $salle_id; $interv->date = $date; /** @var COperation[] $intervs */ $intervs = $interv->loadMatchingList(); $interv_to_use = array(); $range_inter = array(); foreach ($intervs as $ki => $_interv) { // cleanup invalid if (!$_interv->entree_salle || !$_interv->sortie_salle || $_interv->entree_salle >= $_interv->sortie_salle) { continue; } $interv_to_use[$ki] = $_interv; CMbRange::union($range_inter, array("lower" => $_interv->entree_salle, "upper" => $_interv->sortie_salle)); } $this->nb_real_interventions = count($intervs); $this->nb_real_intervention_valid = count($interv_to_use); $this->cumulative_real_interventions = 0; foreach ($range_inter as $_range) { $this->cumulative_real_interventions += CMbDT::minutesRelative($_range["lower"], $_range["upper"]); } // opening patient $interv_to_use = array(); $range_inter_opened = array(); foreach ($intervs as $ki => $_interv) { // cleanup invalid if (!$_interv->debut_op || !$_interv->fin_op || $_interv->debut_op >= $_interv->fin_op) { continue; } $interv_to_use[$ki] = $_interv; CMbRange::union($range_inter_opened, array("lower" => $_interv->debut_op, "upper" => $_interv->fin_op)); } $this->nb_interventions_opened_patient = count($intervs); $this->nb_intervention_opened_patient_valid = count($interv_to_use); $this->cumulative_opened_patient = 0; foreach ($range_inter_opened as $_range) { $this->cumulative_opened_patient += CMbDT::minutesRelative($_range["lower"], $_range["upper"]); } // range operation $this->cumulative_plages_minus_interventions = 0; $plages_minus_interv = CMbRange::multiCrop($range_plage, $range_inter); foreach ($plages_minus_interv as $_plage) { $this->cumulative_plages_minus_interventions = CMbDT::minutesRelative($_plage["lower"], $_plage["upper"]); } $this->cumulative_interventions_minus_plages = 0; $interv_minus_plage = CMbRange::multiCrop($range_inter, $range_plage); foreach ($interv_minus_plage as $_plage) { $this->cumulative_interventions_minus_plages = CMbDT::minutesRelative($_plage["lower"], $_plage["upper"]); } return $this; }
<?php /** * dPbloc * * @category Bloc * @package Mediboard * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version SVN: $Id:$ * @link http://www.mediboard.org */ $plageop_id = CValue::post("plageop_id"); $plageop = new CPlageOp(); $plageop->load($plageop_id); $plageop->loadRefsOperations(false, "rank, rank_voulu, horaire_voulu", true); foreach ($plageop->_ref_operations as $_id => $_interv) { if (!$_interv->rank && !$_interv->rank_voulu && !$_interv->horaire_voulu) { unset($plageop->_ref_operations[$_id]); } } if (!empty($plageop->_ref_operations)) { $plageop->reorderOp(CPlageOp::RANK_VALIDATE); } CAppUI::stepAjax("Placement effectué"); CApp::rip();
$ljoin = array(); $ljoin["sejour"] = "operations.sejour_id = sejour.sejour_id"; $ljoin["grossesse"] = "sejour.grossesse_id = grossesse.grossesse_id"; $where = array(); // Interv ou travail qui commence le jour choisi et n'a pas terminé d'accoucher $where[] = "operations.date = '{$date}' OR (\n grossesse.datetime_debut_travail IS NOT NULL AND\n DATE(grossesse.datetime_debut_travail) < '{$date}' AND\n grossesse.datetime_accouchement IS NULL\n)"; $where["operations.chir_id"] = CSQLDataSource::prepareIn(array_keys($listChirs)); $where["sejour.grossesse_id"] = "IS NOT NULL"; /** @var CStoredObject[] $urgences */ $urgences = $operation->loadGroupList($where, "salle_id, chir_id", null, null, $ljoin); $reservation_installed = CModule::getActive("reservation"); $diff_hour_urgence = CAppUI::conf("reservation diff_hour_urgence"); $sejours = CStoredObject::massLoadFwdRef($urgences, "sejour_id"); $patients = CStoredObject::massLoadFwdRef($sejours, "patient_id"); CStoredObject::massLoadFwdRef($sejours, "grossesse_id"); $plage = new CPlageOp(); /** @var COperation[] $urgences */ foreach ($urgences as &$urgence) { $urgence->loadRefsFwd(); $urgence->loadRefAnesth(); $urgence->_ref_chir->loadRefsFwd(); $sejour = $urgence->_ref_sejour; $patient = $sejour->loadRefPatient(); $sejour->loadRefGrossesse(); $dossier_medical = $patient->loadRefDossierMedical(); $dossier_medical->loadRefsAntecedents(); $dossier_medical->countAntecedents(); $dossier_medical->countAllergies(); if ($reservation_installed) { $first_log = $urgence->loadFirstLog(); if (abs(CMbDT::hoursRelative($urgence->_datetime_best, $first_log->date)) <= $diff_hour_urgence) {
$details = CValue::get("details"); $export = CValue::get("export"); $weeks_before = CValue::get("weeks_before"); $weeks_after = CValue::get("weeks_after"); $date = CValue::get("date", CMbDT::date()); $debut = CMbDT::date("-{$weeks_before} week", $date); $debut = CMbDT::date("last sunday", $debut); $fin = CMbDT::date("+{$weeks_after} week", $date); $fin = CMbDT::date("next sunday", $fin); // Liste des Salles $salle = new CSalle(); /** @var CSalle[] $listSalles */ $listSalles = $salle->loadGroupList(); // Plages de Consultations $plageConsult = new CPlageconsult(); $plageOp = new CPlageOp(); $listDays = array(); /** @var CPlageconsult[] $plagesConsult */ $plagesConsult = array(); $plagesOp = array(); $plagesPerDayOp = array(); for ($i = 0; CMbDT::date("+{$i} day", $debut) != $fin; $i++) { $date = CMbDT::date("+{$i} day", $debut); if (in_array("consult", $export)) { $where = array(); $where["chir_id"] = "= '{$prat_id}'"; $where["date"] = "= '{$date}'"; /** @var CPlageconsult[] $plagesPerDayConsult */ $plagesPerDayConsult = $plageConsult->loadList($where); if ($details) { CMbObject::massLoadBackRefs($plagesPerDayConsult, "consultations");
<?php /** * dPbloc * * @category Bloc * @package Mediboard * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version SVN: $Id:$ * @link http://www.mediboard.org */ CCanDo::checkEdit(); if (!($plageop_id = CValue::getOrSession("plageop_id"))) { CAppUI::setMsg("Vous devez choisir une plage opératoire", UI_MSG_WARNING); CAppUI::redirect("m=dPbloc&tab=vw_edit_planning"); } // Infos sur la plage opératoire $plage = new CPlageOp(); $plage->load($plageop_id); if (!$plage->temps_inter_op) { $plage->temps_inter_op = "00:00:00"; } $plage->loadRefsFwd(); $plage->loadRefChir()->loadRefFunction(); $plage->loadRefAnesth()->loadRefFunction(); $plage->loadRefsNotes(); // Création du template $smarty = new CSmartyDP(); $smarty->assign("plage", $plage); $smarty->display("vw_edit_interventions.tpl");
/** * $Id:$ * * @package Mediboard * @subpackage dPbloc * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision:$ */ CCanDo::checkEdit(); $plageop_id = CValue::get("plageop_id"); $list_type = CValue::get("list_type", "left"); $anesth = new CTypeAnesth(); $anesth = $anesth->loadGroupList(); // Infos sur la plage opératoire $plage = new CPlageOp(); $plage->load($plageop_id); $plage->loadRefsFwd(); $intervs = $plage->loadRefsOperations(true, "rank, rank_voulu, horaire_voulu", true, $list_type != "left"); $chirs = CMbObject::massLoadFwdRef($intervs, "chir_id"); CMbObject::massLoadFwdRef($chirs, "function_id"); $sejours = CMbObject::massLoadFwdRef($intervs, "sejour_id"); CMbObject::massLoadFwdRef($sejours, "patient_id"); foreach ($intervs as $_interv) { $_interv->loadRefsFwd(); $_interv->_ref_chir->loadRefFunction(); $_interv->_ref_sejour->loadRefsFwd(); $_interv->_count_affectations_personnel = $_interv->countBackRefs("affectations_personnel"); $patient = $_interv->_ref_sejour->_ref_patient; $patient->loadRefDossierMedical(); $patient->_ref_dossier_medical->countAllergies();
/** * Charge la liste de plages et interventions pour un jour donné * Analogue à CSalle::loadRefsForDay * * @param string $date Date to look for * @param bool $second_chir Use chir_2, chir_3 and chir_4 * * @return void */ function loadRefsForDay($date, $second_chir = false) { $this->loadBackRefs("secondary_functions"); $secondary_specs = array(); foreach ($this->_back["secondary_functions"] as $_sec_spec) { /** @var CSecondaryFunction $_sec_spec */ $_sec_spec->loadRefFunction(); $_sec_spec->loadRefUser(); $_function = $_sec_spec->_ref_function; $secondary_specs[$_function->_id] = $_function; } // Plages d'intervention $plage = new CPlageOp(); $ljoin = array(); $add_where = ""; if ($second_chir) { $ljoin["operations"] = "plagesop.plageop_id = operations.plageop_id"; $add_where = " OR operations.chir_id = '{$this->_id}' OR operations.chir_2_id = '{$this->_id}'\r\n OR operations.chir_3_id = '{$this->_id}' OR operations.chir_4_id = '{$this->_id}'"; } $where = array(); $where["plagesop.date"] = "= '{$date}'"; $where[] = "plagesop.chir_id = '{$this->_id}' OR plagesop.spec_id = '{$this->function_id}' OR plagesop.spec_id " . CSQLDataSource::prepareIn(array_keys($secondary_specs)) . $add_where; $order = "debut"; $this->_ref_plages = $plage->loadList($where, $order, null, "plageop_id", $ljoin); // Chargement d'optimisation CMbObject::massLoadFwdRef($this->_ref_plages, "chir_id"); CMbObject::massLoadFwdRef($this->_ref_plages, "anesth_id"); CMbObject::massLoadFwdRef($this->_ref_plages, "spec_id"); CMbObject::massLoadFwdRef($this->_ref_plages, "salle_id"); CMbObject::massCountBackRefs($this->_ref_plages, "notes"); CMbObject::massCountBackRefs($this->_ref_plages, "affectations_personnel"); foreach ($this->_ref_plages as $_plage) { /** @var CPlageOp $_plage */ $_plage->loadRefChir(); $_plage->loadRefAnesth(); $_plage->loadRefSpec(); $_plage->loadRefSalle(); $_plage->makeView(); $_plage->loadRefsOperations(); $_plage->loadRefsNotes(); $_plage->loadAffectationsPersonnel(); $_plage->_unordered_operations = array(); // Chargement d'optimisation CMbObject::massLoadFwdRef($_plage->_ref_operations, "chir_id"); $sejours = CMbObject::massLoadFwdRef($_plage->_ref_operations, "sejour_id"); CMbObject::massLoadFwdRef($sejours, "patient_id"); foreach ($_plage->_ref_operations as $_operation) { if ($_operation->chir_id != $this->_id && (!$second_chir || $_operation->chir_2_id != $this->_id && $_operation->chir_3_id != $this->_id && $_operation->chir_4_id != $this->_id)) { unset($_plage->_ref_operations[$_operation->_id]); } else { $_operation->_ref_chir = $this; $_operation->loadExtCodesCCAM(); $_operation->updateSalle(); $_operation->loadRefPatient(); // Extraire les interventions non placées if ($_operation->rank == 0) { $_plage->_unordered_operations[$_operation->_id] = $_operation; unset($_plage->_ref_operations[$_operation->_id]); } } } if (count($_plage->_ref_operations) + count($_plage->_unordered_operations) < 1) { unset($this->_ref_plages[$_plage->_id]); } } // Interventions déplacés $deplacee = new COperation(); $ljoin = array(); $ljoin["plagesop"] = "operations.plageop_id = plagesop.plageop_id"; $where = array(); $where["operations.plageop_id"] = "IS NOT NULL"; $where["operations.annulee"] = "= '0'"; $where["plagesop.salle_id"] = "!= operations.salle_id"; $where["plagesop.date"] = "= '{$date}'"; $where[] = "plagesop.chir_id = '{$this->_id}'" . $add_where; $order = "operations.time_operation"; $this->_ref_deplacees = $deplacee->loadList($where, $order, null, "operation_id", $ljoin); // Chargement d'optimisation CMbObject::massLoadFwdRef($this->_ref_deplacees, "chir_id"); $sejours_deplacees = CMbObject::massLoadFwdRef($this->_ref_deplacees, "sejour_id"); CMbObject::massLoadFwdRef($sejours_deplacees, "patient_id"); foreach ($this->_ref_deplacees as $_deplacee) { /** @var COperation $_deplacee */ $_deplacee->loadRefChir(); $_deplacee->loadRefPatient(); $_deplacee->loadExtCodesCCAM(); } // Urgences $urgence = new COperation(); $where = array(); $where["plageop_id"] = "IS NULL"; $where["date"] = "= '{$date}'"; if ($second_chir) { $where[] = "chir_id = '{$this->_id}' OR chir_2_id = '{$this->_id}' OR chir_3_id = '{$this->_id}' OR chir_4_id = '{$this->_id}'"; } else { $where["chir_id"] = "= '{$this->_id}'"; } $where["annulee"] = "= '0'"; $this->_ref_urgences = $urgence->loadList($where, null, null, "operation_id"); // Chargement d'optimisation CMbObject::massLoadFwdRef($this->_ref_urgences, "chir_id"); $sejours_urgences = CMbObject::massLoadFwdRef($this->_ref_urgences, "sejour_id"); CMbObject::massLoadFwdRef($sejours_urgences, "patient_id"); foreach ($this->_ref_urgences as $_urgence) { /** @var COperation $_urgence */ $_urgence->loadRefChir(); $_urgence->loadRefPatient(); $_urgence->loadExtCodesCCAM(); } }
$jour = CMbDT::date("+{$i} day", $debut); $where["date"] = $whereInterv["date"] = $whereHP["date"] = "= '{$jour}'"; if (CAppUI::pref("showIntervPlanning")) { // HORS PLAGE $horsPlage = new COperation(); /** @var COperation[] $horsPlages */ $horsPlages = $horsPlage->loadList($whereHP); CMbObject::massLoadFwdRef($horsPlages, "chir_id"); foreach ($horsPlages as $_horsplage) { $lenght = CMBDT::minutesRelative("00:00:00", $_horsplage->temp_operation); $op = new CPlanningRange($_horsplage->_guid, $jour . " " . $_horsplage->time_operation, $lenght, $_horsplage, "3c75ea", "horsplage"); $planning->addRange($op); } // INTERVENTIONS /** @var CPlageOp[] $intervs */ $interv = new CPlageOp(); $intervs = $interv->loadList($whereInterv); CMbObject::massLoadFwdRef($intervs, "chir_id"); foreach ($intervs as $_interv) { $range = new CPlanningRange($_interv->_guid, $jour . " " . $_interv->debut, CMbDT::minutesRelative($_interv->debut, $_interv->fin), CAppUI::tr($_interv->_class), "bbccee", "plageop"); $planning->addRange($range); } } $plages = $plage->loadList($where); CMbObject::massLoadFwdRef($plages, "chir_id"); /** @var $_plage CPlageconsult */ foreach ($plages as $_plage) { $_plage->loadRefsFwd(1); $_plage->loadRefsConsultations(false); $range = new CPlanningRange($_plage->_guid, $jour . " " . $_plage->debut, CMbDT::minutesRelative($_plage->debut, $_plage->fin)); $range->color = $_plage->color;
/** * @see parent::store() */ function store() { $this->updatePlainFields(); $this->completeField("chir_id", "spec_id"); $old = new CPlageOp(); if ($this->_id) { $old->load($this->_id); $old->loadRefsOperations(); } // Pas de changement de date si on a déjà des interventions if ($this->fieldModified("date") && count($old->_ref_operations)) { return CAppUI::tr("CPlageOp-failed-change_date", count($old->_ref_operations)); } // Erreur si on est en multi-praticiens, qu'il y a des interventions et qu'on veut mettre un praticien if ($this->fieldValued("chir_id") && !$this->unique_chir && $old->spec_id && count($old->_ref_operations)) { mbTrace("all the same to me"); } if (null !== $this->chir_id && $this->_id && !$this->unique_chir) { if (count($old->_ref_operations) && $old->spec_id && $this->chir_id) { return CAppUI::tr("CPlageOp-failed-multi_chir", count($old->_ref_operations)); } } // Si on change de praticien alors qu'il y a déjà des interventions if ($this->fieldAltered("chir_id") && count($old->_ref_operations)) { // Si certaines ne sont pas annulées, on sort if ($this->countOperationsAnnulees() != count($old->_ref_operations)) { return CAppUI::tr("CPlageOp-failed-change_chir", count($old->_ref_operations)); } // Si toutes les interventions sont annulées, on les met hors plage $this->completeField("salle_id", "date"); foreach ($old->_ref_operations as $_op) { $_op->plageop_id = ""; $_op->date = $this->date; $_op->salle_id = $this->salle_id; $_op->store(); } } // Erreur si on créé-modifie une plage sur une salle bloquée $salle = $this->loadRefSalle(); if (count($salle->loadRefsBlocages($this->date))) { return CAppUI::tr("CPlageOp-failed-use_locked_room", $salle->_view); } // Modification du salle_id de la plage -> repercussion sur les interventions if ($this->fieldModified("salle_id")) { foreach ($old->_ref_operations as $_operation) { if ($_operation->salle_id == $old->salle_id) { $_operation->salle_id = $this->salle_id; $_operation->store(false); } } } // Modification du début de la plage ou des minutes entre les interventions $this->completeField("debut", "temps_inter_op"); if ($this->fieldModified("debut") || $this->fieldModified("temps_inter_op")) { if ($this->fieldModified("temps_inter_op")) { $with_cancelled = CAppUI::conf("dPplanningOp COperation save_rank_annulee_validee"); $this->loadRefsOperations($with_cancelled, "rank, rank_voulu, horaire_voulu", true); } $this->reorderOp(); } if (!$this->_id || !$this->original_owner_id && !$this->original_function_id) { $this->original_owner_id = $this->chir_id; $this->original_function_id = $this->spec_id; } return parent::store(); }
* @category Pmsi * @package Mediboard * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @link http://www.mediboard.org */ CCanDo::checkRead(); $date = CValue::getOrSession("date", CMbDT::date()); // Selection des salles $listSalles = new CSalle(); $listSalles = $listSalles->loadGroupList(); $totalOp = 0; $counts = array("sejours" => array("total" => 0, "facturees" => 0), "operations" => array("total" => 0, "facturees" => 0), "urgences" => array("total" => 0, "facturees" => 0)); /** * Comptage des Interventions planifiées */ $plage = new CPlageOp(); $where = array(); $where["date"] = "= '{$date}'"; $where["salle_id"] = CSQLDataSource::prepareIn(array_keys($listSalles)); /** @var CPlageOp[] $plages */ $plages = $plage->loadList($where); /** @var COperation[] $operations */ $operations = CPlageOp::massLoadBackRefs($plages, "operations", null, array("annulee" => "= '0'")); foreach ($plages as $_plage) { $_plage->_ref_operations = $_plage->_back["operations"]; foreach ($_plage->_ref_operations as $_operation) { $counts["operations"]["total"]++; if ($_operation->facture) { $counts["operations"]["facturees"]++; } }
* @version SVN: $Id:$ * @link http://www.mediboard.org */ CCanDo::checkAdmin(); $purge = CView::get("purge", "bool default|0"); $auto = CView::get("auto", "bool default|0"); $max = CView::get("max", "num default|100"); CView::checkin(); $group = CGroups::loadCurrent(); $ljoin["operations"] = "plagesop.plageop_id = operations.plageop_id"; $ljoin["sallesbloc"] = "sallesbloc.salle_id = plagesop.salle_id"; $ljoin["bloc_operatoire"] = "bloc_operatoire.bloc_operatoire_id = sallesbloc.bloc_id"; $where["operations.operation_id"] = "IS NULL"; $where["bloc_operatoire.group_id"] = "= '{$group->_id}'"; $order = "plagesop.date"; $plage = new CPlageOp(); $success_count = 0; $failures = array(); $plages = array(); if ($purge) { /** @var CPlageOp[] $plages */ $plages = $plage->loadList($where, $order, $max, null, $ljoin); foreach ($plages as $_plage) { // Suppression des affectationde personnel if ($affectations = $_plage->loadAffectationsPersonnel()) { foreach ($affectations as $_affectations) { foreach ($_affectations as $_affectation) { $_affectation->delete(); } } }
<?php $purge_start_date = CValue::post('purge_start_date', CMbDT::date()); $purge_limit = CValue::post('purge_limit'); $practitioner_id = CValue::post('practitioner_id'); $just_count = CValue::post('just_count'); if (!$purge_start_date) { CAppUI::stepAjax("common-error-You must select a start date", UI_MSG_ERROR); } $purge_limit = $purge_limit ? $purge_limit : 100; $ds = CSQLDataSource::get('std'); $plage_op = new CPlageOp(); $ljoin = array('operations' => '`plagesop`.`plageop_id` = `operations`.`plageop_id`'); $where = array('plagesop.date' => $ds->prepare('>= ?', $purge_start_date), 'operations.plageop_id' => 'IS NULL'); if ($practitioner_id) { $where['plagesop.chir_id'] = $ds->prepare('= ?', $practitioner_id); } $count = $plage_op->countList($where, null, $ljoin); $msg = '%d CPlageOp to be removed.'; if ($count == 1) { $msg = 'One CPlageOp to be removed.'; } elseif (!$count) { $msg = 'No CPlageOp to be removed.'; } CAppUI::stepAjax("CPlageOp-msg-{$msg}", UI_MSG_OK, $count); if ($just_count || !$count) { CAppUI::js("\$('clean_plage_auto').checked = false"); CApp::rip(); } $plages_op = $plage_op->loadList($where, null, $purge_limit, null, $ljoin); if (!$plages_op) {
/** * @see parent::store() */ function store($reorder = true) { /** @var self $old */ $old = $this->loadOldObject(); $this->completeField("annulee", "rank", "codes_ccam", "plageop_id", "chir_id", "materiel", "commande_mat", "date"); // Si on a une plage, la date est celle de la plage if ($this->plageop_id) { $plage = $this->loadRefPlageOp(); $this->date = $plage->date; } // Si on choisit une plage, on copie la salle if ($this->fieldValued("plageop_id")) { $plage = $this->loadRefPlageOp(); $this->salle_id = $plage->salle_id; } // Cas d'une plage que l'on quitte /** @var CPlageOp $old_plage */ $old_plage = null; if ($this->fieldAltered("plageop_id") && $old->rank) { $old_plage = $old->loadRefPlageOp(); } $comments = $this->prepareAlert(); $place_after_interv_id = $this->_place_after_interv_id; $this->_place_after_interv_id = null; // Pré-remplissage de la durée préop si c'est une nouvelle intervention if (!$this->_id && !$this->duree_preop) { $patient = $this->loadRefSejour()->loadRefPatient(); if ($patient->_annees >= 18) { $this->duree_preop = "00:" . CAppUI::conf("dPplanningOp COperation duree_preop_adulte") . ":00"; } else { $this->duree_preop = "00:" . CAppUI::conf("dPplanningOp COperation duree_preop_enfant") . ":00"; } } // On recopie la sortie réveil possible sur le réel si pas utilisée en config if (!CAppUI::conf("dPsalleOp COperation use_sortie_reveil_reel", CGroups::loadCurrent()->_guid)) { $this->sortie_reveil_reel = $this->sortie_reveil_possible; } // Création d'une alerte si modification du libellé et/ou du côté if ($this->_id && ($this->fieldModified("libelle") || $this->fieldModified("cote"))) { $alerte = ""; $date = CMbDT::dateToLocale(CMbDT::date()); if ($this->fieldModified("libelle")) { $alerte = "Le libellé a été modifié le {$date}\n" . "Ancienne valeur : " . $old->getFormattedValue("libelle") . "\nNouvelle valeur : " . $this->getFormattedValue("libelle"); } $this->createAlert($alerte, true, "libelle"); $alerte = ""; if ($this->fieldModified("cote")) { $alerte = "Le côté a été modifié le {$date} : \n" . "Ancienne valeur : " . $old->getFormattedValue("cote") . "\nNouvelle valeur : " . $this->getFormattedValue("cote"); } $this->createAlert($alerte, true, "cote"); } $sejour = $this->loadRefSejour(); $do_store_sejour = false; // Flag pour storer le séjour une seule fois $do_update_time = false; // Synchronisation des heures d'admission if ($this->fieldModified('horaire_voulu') || $this->fieldModified('temp_operation') || $this->fieldModified('presence_preop') || $this->fieldModified('presence_postop') || $this->fieldModified('date') || $this->fieldModified('time_operation')) { $do_update_time = true; } if ($this->loadRefCommande()->_id && $this->_ref_commande_mat->etat != "annulee") { if ($this->fieldModified("annulee", "1")) { $this->_ref_commande_mat->cancelledOp(); } if ($this->fieldModified("materiel") || $this->fieldModified("date")) { $this->_ref_commande_mat->modifiedOp($this->materiel); } } // Standard storage if ($msg = parent::store()) { return $msg; } if ($do_update_time) { $do_store_sejour = $sejour->checkUpdateTimeAmbu(); } // Création des besoins d'après le protocole sélectionné // Ne le faire que pour une nouvelle intervention // Pour une intervention existante, l'application du protocole // store les protocoles if (CAppUI::conf("dPbloc CPlageOp systeme_materiel") == "expert" && $this->_types_ressources_ids && !$old->_id) { $types_ressources_ids = explode(",", $this->_types_ressources_ids); foreach ($types_ressources_ids as $_type_ressource_id) { $besoin = new CBesoinRessource(); $besoin->type_ressource_id = $_type_ressource_id; $besoin->operation_id = $this->_id; if ($msg = $besoin->store()) { return $msg; } } } $this->createAlert($comments); // Mise à jour du type de PeC du séjour en Chirurgical si pas déja obstétrique $sejour->completeField("type_pec"); if (!$this->_id && $sejour->type_pec != "O") { $sejour->type_pec = "C"; $do_store_sejour = true; } // Cas d'une annulation if (!$this->annulee) { // Si pas une annulation on recupére le sejour // et on regarde s'il n'est pas annulé if ($sejour->annule) { $sejour->annule = 0; $do_store_sejour = true; } // Application des protocoles de prescription en fonction de l'operation->_id if ($this->_protocole_prescription_chir_id || $this->_protocole_prescription_anesth_id) { $sejour->_protocole_prescription_chir_id = $this->_protocole_prescription_chir_id; $sejour->_protocole_prescription_anesth_id = $this->_protocole_prescription_anesth_id; $sejour->applyProtocolesPrescription($this->_id); // On les nullify pour eviter de les appliquer 2 fois $this->_protocole_prescription_anesth_id = null; $this->_protocole_prescription_chir_id = null; $sejour->_protocole_prescription_chir_id = null; $sejour->_protocole_prescription_anesth_id = null; } } elseif ($this->rank != 0 && !CAppUI::conf("dPplanningOp COperation save_rank_annulee_validee")) { $this->rank = 0; $this->time_operation = "00:00:00"; } // Store du séjour (une seule fois) if ($do_store_sejour) { $sejour->store(); } // Vérification qu'on a pas des actes CCAM codés obsolètes if ($this->codes_ccam) { $this->loadRefsActesCCAM(); foreach ($this->_ref_actes_ccam as $keyActe => $acte) { if (stripos($this->codes_ccam, $acte->code_acte) === false) { $this->_ref_actes_ccam[$keyActe]->delete(); } } } $reorder_rank_voulu = $this->_reorder_rank_voulu; $this->_reorder_rank_voulu = null; if ($this->plageop_id) { $plage = $this->loadRefPlageOp(); // Cas de la création dans une plage de spécialité if ($plage->spec_id && $plage->unique_chir) { $plage->chir_id = $this->chir_id; $plage->spec_id = ""; $plage->store(); } // Placement de l'interv selon la preference (placement souhaité) if ($place_after_interv_id) { $plage->loadRefsOperations(false, "rank, rank_voulu, horaire_voulu", true); unset($plage->_ref_operations[$this->_id]); if ($place_after_interv_id == -1) { $reorder = true; $reorder_rank_voulu = true; $plage->_ref_operations = CMbArray::mergeKeys(array($this->_id => $this), $plage->_ref_operations); // To preserve keys (array_unshift does not) } elseif (isset($plage->_ref_operations[$place_after_interv_id])) { $reorder = true; $reorder_rank_voulu = true; CMbArray::insertAfterKey($plage->_ref_operations, $place_after_interv_id, $this->_id, $this); } if ($reorder_rank_voulu) { $plage->_reorder_up_to_interv_id = $this->_id; } } } // Gestion du tarif et precodage des actes if ($this->_bind_tarif && $this->_id) { if ($msg = $this->bindTarif()) { return $msg; } } // Standard storage bis if ($msg = parent::store()) { return $msg; } // Réordonnancement post-store if ($reorder) { // Réordonner la plage que l'on quitte if ($old_plage) { $old_plage->reorderOp(); } $this->_ref_plageop->reorderOp($reorder_rank_voulu ? CPlageOp::RANK_REORDER : null); } return null; }
foreach ($userSel->_back["secondary_functions"] as $_sec_spec) { /** @var CSecondaryFunction $_sec_spec */ $_sec_spec->loadRefFunction(); $_sec_spec->loadRefUser(); $_function = $_sec_spec->_ref_function; $secondary_specs[$_function->_id] = $_function; } $where = array(); $where["date"] = "= '{$date}'"; $in = ""; if (count($secondary_specs)) { $in = " OR plagesop.spec_id " . CSQLDataSource::prepareIn(array_keys($secondary_specs)); } $where[] = "plagesop.chir_id = '{$userSel->_id}'\r\n OR plagesop.anesth_id = '{$userSel->_id}'\r\n OR plagesop.spec_id = '{$userSel->function_id}' {$in}"; $order = "debut, salle_id"; $plageop = new CPlageOp(); /** @var CPlageOp[] $list_plages */ $list_plages = $plageop->loadList($where, $order); // Chargement d'optimisation CMbObject::massLoadFwdRef($list_plages, "chir_id"); CMbObject::massLoadFwdRef($list_plages, "anesth_id"); CMbObject::massLoadFwdRef($list_plages, "spec_id"); CMbObject::massLoadFwdRef($list_plages, "salle_id"); CMbObject::massCountBackRefs($list_plages, "notes"); foreach ($list_plages as $_plage) { $op_canceled = new COperation(); $op_canceled->annulee = 1; $op_canceled->plageop_id = $_plage->_id; $nb_canceled += $op_canceled->countMatchingList(); $_plage->loadRefChir(); $_plage->loadRefAnesth();
* @version $Revision: 26995 $ */ global $m; $do = new CDoObjectAddEdit("COperation"); $do->doBind(); if (intval(CValue::post("del", null))) { CValue::setSession("operation_id"); $do->redirectDelete = "m={$m}&tab=vw_edit_planning&operation_id=0"; $do->doDelete(); } else { if ($do->_obj->plageop_id && $do->_old->plageop_id != $do->_obj->plageop_id) { $do->_obj->rank = 0; } $do->doStore(); if (CModule::getActive("forms") && CValue::post("_set_fin_op") && CValue::post("fin_op") == "current") { $ex_class_events = CExClassEvent::getForObject($do->_obj, "fin_intervention", "required"); echo CExClassEvent::getJStrigger($ex_class_events); } if ($do->_obj->plageop_id && $do->_old->plageop_id && $do->_old->plageop_id != $do->_obj->plageop_id) { $plageop = new CPlageOp(); $plageop->load($do->_old->plageop_id); $plageop->spec_id = ""; $plageop->store(); } $m = CValue::post("otherm", $m); if ($m == "dPhospi") { $do->redirectStore = "m={$m}#operation" . $do->_obj->operation_id; } $do->redirectStore = "m={$m}&operation_id=" . $do->_obj->operation_id; } $do->doRedirect();
CAppUI::setMsg("Plage non trouvée", UI_MSG_ERROR); } else { if ($msg = $obj->delete()) { CAppUI::setMsg("Plage non supprimée", UI_MSG_ERROR); CAppUI::setMsg("Plage du {$obj->date}: {$msg}", UI_MSG_ERROR); } else { CAppUI::setMsg("Plage supprimée", UI_MSG_OK); } } $repeat -= $obj->becomeNext(); } $_SESSION["dPbloc"]["id"] = null; } else { //Modification des plages if ($obj->_id != 0) { $oldObj = new CPlageOp(); $oldObj->load($obj->_id); $salle_id = $oldObj->salle_id; $chir_id = $oldObj->chir_id; $spec_id = $oldObj->spec_id; $secondary_function_id = $oldObj->secondary_function_id; while ($repeat > 0) { if ($obj->_id) { if ($msg = $obj->store()) { CAppUI::setMsg("Plage non mise à jour", UI_MSG_ERROR); CAppUI::setMsg("Plage du {$obj->date}: {$msg}", UI_MSG_ERROR); } else { CAppUI::setMsg("Plage mise à jour", UI_MSG_OK); } managePersonnel($obj); }
$whereOperations["operations.chir_id"] = CSQLDataSource::prepareIn(array_keys($praticiens)); // En fonction de la salle $salle = new CSalle(); $whereSalle = array(); $whereSalle["sallesbloc.bloc_id"] = CSQLDataSource::prepareIn(count($filter->_bloc_id) ? $filter->_bloc_id : array_keys($group->loadBlocs(PERM_READ))); if ($filter->salle_id) { $whereSalle["sallesbloc.salle_id"] = "= '{$filter->salle_id}'"; } $listSalles = $salle->loadListWithPerms(PERM_READ, $whereSalle); if ($filter->salle_id || $filter->_bloc_id) { $whereOperations["operations.salle_id"] = CSQLDataSource::prepareIn(array_keys($listSalles)); } $whereOperations["sejour.group_id"] = "= '" . $group->_id . "'"; $wherePlagesop["plagesop.salle_id"] = CSQLDataSource::prepareIn(array_keys($listSalles)); $orderPlagesop = "date, salle_id, debut"; $plageop = new CPlageOp(); /** @var CPlageOp[] $plagesop */ $plagesop = $plageop->loadList($wherePlagesop, $orderPlagesop); $ljoin = array(); $ljoin["sejour"] = "operations.sejour_id = sejour.sejour_id"; $where = array(); $where["operations.chir_id"] = CSQLDataSource::prepareIn(array_keys($praticiens)); if (!$_print_annulees) { $where["operations.annulee"] = "= '0'"; $whereOperations["operations.annulee"] = "= '0'"; } switch ($filter->_ranking) { case "ok": $where["operations.rank"] = "!= '0'"; break; case "ko":
unset($salles[$id]); continue; } } if (!count($salles)) { unset($listBlocs[$key]); continue; } } if (!$plagesel->temps_inter_op) { $plagesel->temps_inter_op = "00:00:00"; } if ($plagesel->_id) { if (count($arrKeySalle) && !in_array($plagesel->salle_id, $arrKeySalle) || $plagesel->date != $date) { $plageop_id = 0; $plagesel = new CPlageOp(); } $plagesel->loadAffectationsPersonnel(); } if (!$plagesel->_id) { $plagesel->date = $date; $plagesel->debut = CPlageOp::$hours_start . ":00:00"; $plagesel->fin = CPlageOp::$hours_start . ":00:00"; } // On charge le praticien et ses fonctions secondaires $chir = $plagesel->loadRefChir(); $chir->loadRefFunction(); $_functions = $chir->loadBackRefs("secondary_functions"); // Liste des Specialités $function = new CFunctions(); $specs = $function->loadSpecialites(PERM_READ, 1);
* Réaffectation automatique des plages opératoires * * Script à lancer entre minuit et 6h du matin * pour que les dates limites soient respectées * * @category Bloc * @package Mediboard * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version SVN: $Id: httpreq_reaffect_plagesop.php 23849 2014-07-03 14:08:17Z mytto $ * @link http://www.mediboard.org */ CCanDo::checkAdmin(); $mode_real = CValue::get("mode_real", 1); $date = CMbDT::date(); $plage = new CPlageOp(); $where = array(); $where["plagesop.spec_repl_id"] = "IS NOT NULL"; $where["plagesop.delay_repl"] = "IS NOT NULL"; $where[] = "`plagesop`.`date` < DATE_ADD('{$date}', INTERVAL `plagesop`.`delay_repl` DAY)"; $where[] = "`plagesop`.`date` >= '{$date}'"; $where["operations.operation_id"] = "IS NULL"; $order = "`plagesop`.`date`, `plagesop`.`debut`"; $limit = null; $group = "plagesop.plageop_id"; $ljoin = array(); $ljoin["operations"] = "operations.plageop_id = plagesop.plageop_id AND operations.annulee = '0'"; /** @var CPlageOp[] $plages */ $plages = $plage->loadList($where, $order, $limit, $group, $ljoin); $count = count($plages); CAppUI::stepAjax("Lancement à '{$date}' en mode '{$mode_real}': '{$count}' plages trouvées");