/** * 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(); } } }
$_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(); $_plage->loadRefSpec(); $_plage->loadRefSalle();
$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 */ $horsPlages = $operation->loadList($where, $order); // Détermination des bornes du semainier $min = CPlageOp::$hours_start . ":" . reset(CPlageOp::$minutes) . ":00"; $max = CPlageOp::$hours_stop . ":" . end(CPlageOp::$minutes) . ":00"; // Détermination des bornes de chaque plage foreach ($listPlages[$keyDate] as $plage) { /** @var CPlageOp $plage */ $plage->loadRefsFwd();
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) { CAppUI::js("\$('clean_plage_auto').checked = false"); CAppUI::stepAjax("CPlageOp-msg-No CPlageOp to be removed.", UI_MSG_OK); CApp::rip(); } $deleted_plages = 0; foreach ($plages_op as $_plage_op) { if ($msg = $_plage_op->delete()) { CAppUI::setMsg($msg, UI_MSG_WARNING); } else { CAppUI::setMsg('CPlageOp-msg-delete', UI_MSG_OK); $deleted_plages++; } } CAppUI::setMsg('CPlageOp-msg-%d CPlageOp to be removed.', UI_MSG_OK, $count - $deleted_plages);
// Chargement des plages pour le chir ou sa spécialité par bloc $where = array(); $selectPlages = "(plagesop.chir_id = %1 OR plagesop.spec_id = %2 OR plagesop.spec_id " . CSQLDataSource::prepareIn($secondary_functions) . ")"; $where[] = $ds->prepare($selectPlages, $mediChir->user_id, $mediChir->function_id); $month_min = CMbDT::transform("+ 0 month", $date, "%Y-%m-00"); $month_max = CMbDT::transform("+ 1 month", $date, "%Y-%m-00"); $where["date"] = "BETWEEN '{$month_min}' AND '{$month_max}'"; 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); } }
$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; $range->type = "plageconsult";
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"]++; } } $totalOp += count($_plage->_ref_operations); } /** * Comptage des Interventions hors plages */
} foreach ($plagesPerDayConsult as $key => $plageConsult) { $plageConsult->countPatients(); $plageConsult->loadFillRate(); if ($details) { $plageConsult->loadRefsConsultations(); } } $plagesConsult[$date] = $plagesPerDayConsult; } if (in_array("interv", $export)) { $where = array(); $where[] = "chir_id = '{$prat_id}' OR anesth_id = '{$prat_id}'"; $where["date"] = "= '{$date}'"; $where["salle_id"] = CSQLDataSource::prepareIn(array_keys($listSalles)); $plagesPerDayOp = $plageOp->loadList($where); $salles = CMbObject::massLoadFwdRef($plagesPerDayOp, "salle_id"); CMbObject::massLoadFwdRef($salles, "bloc_id"); CMbObject::massLoadBackRefs($plagesPerDayOp, "operations"); foreach ($plagesPerDayOp as $key => $plage) { $plage->loadRefSalle(); $plage->_ref_salle->loadRefBloc(); $plage->_ref_salle->_ref_bloc->loadRefGroup(); if ($details) { $plage->loadRefsOperations(); } $plage->multicountOperations(); $plagesOp[$plage->salle_id][$date] = $plagesPerDayOp[$key]; } } }
$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 * - temps des interventions * - nombre de panseuses * - nombre d'aides op */ $curr_plage->loadRefChir(); $curr_plage->loadRefAnesth(); $curr_plage->loadRefSpec(); $curr_plage->loadRefSalle();
$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(); } } } if ($msg = $_plage->delete()) { $failures[$_plage->_id] = $msg; $_plage->loadRefSalle(); continue; } $success_count++;
$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": $where["operations.rank"] = "= '0'"; }
/** * 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(); } }
$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); /** @var CPlageOp[] $plagesop */ $plagesop = $plage->loadList($where, $order); $plagesop["urgences"] = new CPlageOp(); $prats = CMbObject::massLoadFwdRef($plagesop, "chir_id"); CMbObject::massLoadFwdRef($prats, "function_id"); // Operations de chaque plage $listUrgencesTraitees = array(); foreach ($plagesop as $_plage) { $where = array(); $ljoin = array(); $tempOp = new COperation(); // Interventions avec ou sans actes if ($filter->_cotation) { $ljoin["acte_ccam"] = "operations.operation_id = acte_ccam.object_id AND acte_ccam.object_class = 'COperation'"; switch ($filter->_cotation) { case "ok": $where["acte_id"] = "IS NOT NULL";
$urgence->_is_urgence = true; } } // Chargement des plages disponibles pour cette intervention $urgence->_ref_chir->loadBackRefs("secondary_functions"); $secondary_functions = array(); foreach ($urgence->_ref_chir->_back["secondary_functions"] as $curr_sec_func) { $secondary_functions[$curr_sec_func->function_id] = $curr_sec_func; } $where = array(); $selectPlages = "(plagesop.chir_id = %1 OR plagesop.spec_id = %2\n OR plagesop.spec_id " . CSQLDataSource::prepareIn(array_keys($secondary_functions)) . ")"; $where[] = $ds->prepare($selectPlages, $urgence->chir_id, $urgence->_ref_chir->function_id); $where["date"] = "= '{$date}'"; $where["salle_id"] = CSQLDataSource::prepareIn(array_keys($listSalles)); $order = "salle_id, debut"; $urgence->_alternate_plages = $plage->loadList($where, $order); foreach ($urgence->_alternate_plages as $curr_plage) { $curr_plage->loadRefsFwd(); } } $anesth = new CMediusers(); $anesths = $anesth->loadAnesthesistes(PERM_READ); $date_last_checklist = array(); foreach ($listSalles as $salle) { if ($salle->cheklist_man) { $checklist = new CDailyCheckList(); $checklist->object_class = $salle->_class; $checklist->object_id = $salle->_id; $checklist->loadMatchingObject("date DESC"); if ($checklist->_id) { $log = new CUserLog();
$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"); foreach ($plages as $_plage) { if ($mode_real) { // Suppression des interventions annulées de cette plage pour les mettre en hors plannifié foreach ($_plage->loadRefsOperations() as $_operation) { $_operation->plageop_id = ""; $_operation->store(); } // Réaffectation de la plage $_plage->spec_id = $_plage->spec_repl_id; $_plage->chir_id = ""; if ($msg = $_plage->store()) { CAppUI::stepAjax($msg, UI_MSG_ERROR); } else {
} } // Chargement des plages disponibles pour cette intervention $operation->_ref_chir->loadBackRefs("secondary_functions"); $secondary_functions = array(); foreach ($operation->_ref_chir->_back["secondary_functions"] as $curr_sec_func) { $secondary_functions[$curr_sec_func->function_id] = $curr_sec_func; } $where = array(); $selectPlages = "(plagesop.chir_id = %1 OR plagesop.spec_id = %2\n OR plagesop.spec_id " . CSQLDataSource::prepareIn(array_keys($secondary_functions)) . ")"; $where[] = $ds->prepare($selectPlages, $operation->chir_id, $operation->_ref_chir->function_id); $where["date"] = "= '{$date}'"; $where["salle_id"] = CSQLDataSource::prepareIn(array_keys($listSalles)); $order = "salle_id, debut"; $plage = new CPlageOp(); $operation->_alternate_plages = $plage->loadList($where, $order); foreach ($operation->_alternate_plages as $curr_plage) { $curr_plage->loadRefsFwd(); } } // Liste des types d'anesthésie $listAnesthType = new CTypeAnesth(); $listAnesthType = $listAnesthType->loadGroupList(); $smarty = new CSmartyDP(); $smarty->assign("op", $operation); $smarty->assign("anesths", $anesths); $smarty->assign("listSalles", $listSalles); $smarty->assign("listBlocs", $listBlocs); $smarty->assign("to_remove", $toRemove); $smarty->assign("listAnesthType", $listAnesthType); $smarty->display("../../dPsalleOp/templates/inc_line_hors_plage.tpl");