/** * liste les interventions hors plage entre 2 date données * * @param date $start date de début * @param date|null $end date de fin (si null = date de début) * @param array $chir_ids chirs targeted * @param array $salle_ids salles to check * * @return COperation[] */ static function getForDates($start, $end = null, $chir_ids = array(), $salle_ids = array()) { $d_start = $start; $d_end = $end ? $end : $start; $ljoin = array(); $ljoin["sejour"] = "sejour.sejour_id = operations.sejour_id"; $where = array(); if (count($chir_ids)) { $where["chir_id"] = CSQLDataSource::prepareIn($chir_ids); } if (count($salle_ids)) { $where[] = "operations.salle_id IS NULL OR operations.salle_id " . CSQLDataSource::prepareIn($salle_ids); } $where["operations.plageop_id"] = "IS NULL"; $where["operations.date"] = "BETWEEN '{$d_start}' AND '{$d_end}'"; $where["operations.annulee"] = "= '0'"; $where["sejour.group_id"] = "= '" . CGroups::loadCurrent()->_id . "'"; $order = "operations.date, operations.chir_id"; $op = new COperation(); /** @var COperation[] $listHorsPlage */ $listHorsPlage = $op->loadList($where, $order, null, null, $ljoin); return $listHorsPlage; }
$where = array(); $where["date"] = " = '" . CMbDT::date($date_depart) . "'"; $where["annulee"] = " = '0'"; $ljoin = array(); $ljoin["sallesbloc"] = "sallesbloc.salle_id = operations.salle_id"; if ($bloc_id) { $where["sallesbloc.bloc_id"] = "= '{$bloc_id}'"; } else { $bloc = new CBlocOperatoire(); $where_bloc = array("group_id" => "= '" . CGroups::loadCurrent()->_id . "'"); $blocs = $bloc->loadListWithPerms(PERM_READ, $where_bloc, "nom"); $where["sallesbloc.bloc_id"] = CSQLDataSource::prepareIn(array_keys($blocs)); } $operation = new COperation(); /** @var COperation[] $operations */ $operations = $operation->loadList($where, "time_operation ASC", null, null, $ljoin); $sejours = CMbObject::massLoadFwdRef($operations, "sejour_id"); CMbObject::massLoadFwdRef($sejours, "patient_id"); CMbObject::massLoadFwdRef($operations, "salle_id"); CMbObject::massLoadFwdRef($operations, "plageop_id"); foreach ($operations as $_operation) { $_operation->loadRefPlageOp(); $_operation->updateSalle(); $_operation->updateHeureUS(); $sejour = $_operation->loadRefSejour(); $affectation = $sejour->loadRefCurrAffectation($date_depart); $affectation->loadView(); $sejour->loadRefPatient(); } // Tri à posteriori switch ($order_col) {
$ljoin["plagesop"] = "operations.plageop_id = plagesop.plageop_id"; $where = array(); $in_salles = CSQLDataSource::prepareIn(array_keys($salles)); $where[] = "plagesop.salle_id {$in_salles} OR operations.salle_id {$in_salles}"; $where["materiel"] = "!= ''"; $where[] = " operations.date BETWEEN '{$date_min}' AND '{$date_max}'"; if ($praticien_id) { $where["operations.chir_id"] = " = '{$praticien_id}'"; } elseif ($function_id) { $mediuser = new CMediusers(); $users = $mediuser->loadProfessionnelDeSante(PERM_READ, $function_id); $where["operations.chir_id"] = CSQLDataSource::prepareIn(array_keys($users)); } $order = "operations.date, rank"; $operation = new COperation(); $ops = $operation->loadList($where, $order, null, "operation_id", $ljoin); $operations = array(); $commande = new CCommandeMaterielOp(); foreach ($commande->_specs["etat"]->_list as $spec) { $operations[$spec] = array(); } foreach ($ops as $_op) { /** @var COperation $_op */ $_op->loadRefPatient(); $_op->loadRefChir()->loadRefFunction(); $_op->loadRefPlageOp(); $_op->loadExtCodesCCAM(); $_op->loadRefCommande(); if (!$_op->_ref_commande_mat->_id && !$_op->annulee) { $operations["a_commander"][$_op->_id] = $_op; } elseif ($_op->_ref_commande_mat->_id) {
$where[] = "operations.chir_id " . $in_prats . " OR operations.chir_2_id " . $in_prats . " OR operations.chir_3_id " . $in_prats . " OR operations.chir_4_id " . $in_prats; $where[] = "operations.anesth_id IS NULL OR operations.anesth_id {$in_prats}"; } else { $where_chir = "operations.chir_id = '{$user->_id}' OR operations.chir_2_id = '{$user->_id}'\n OR operations.chir_3_id = '{$user->_id}' OR operations.chir_4_id = '{$user->_id}'"; if ($user->isAnesth()) { $where[] = "{$where_chir} OR\n operations.anesth_id = '{$user->_id}' OR\n (operations.anesth_id IS NULL && plagesop.anesth_id = '{$user->_id}')"; } else { $where[] = $where_chir; } } /** @var COperation[] $interventions */ $operation = new COperation(); if (!$interv_with_no_codes) { $where[] = "LENGTH(codes_ccam) > 0"; } $interventions = $operation->loadList($where, null, null, null, $ljoin); $totals["interventions"] = count($interventions); $where = array(); if (!$all_prats) { //$where["executant_id"] = "= '$user->_id'"; $where["code_activite"] = $user->_is_anesth ? "= '4'" : "!= '4'"; } CStoredObject::massCountBackRefs($interventions, "actes_ccam", $where); // Préparation des interventions CDatedCodeCCAM::$cache_layers = Cache::INNER_OUTER; foreach ($interventions as $key => $_interv) { $_interv->loadExtCodesCCAM(); } foreach ($interventions as $key => $_interv) { $codes_ccam = $_interv->_ext_codes_ccam; // Nombre d'acte cotés par le praticien et réinitialisation du count pour le cache
$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(); $plage->loadRefsNotes(); $plage->_ref_chir->loadRefsFwd(); $plage->multicountOperations(); $nbIntervNonPlacees += $plage->_count_operations - $plage->_count_operations_placees; $plage->loadAffectationsPersonnel(); $plage->fin = min($plage->fin, $max); $plage->debut = max($plage->debut, $min); $plage->updateFormFields();
} } $totalOp += count($_plage->_ref_operations); } /** * Comptage des Interventions hors plages */ $operation = new COperation(); $where = array(); $ljoin["sejour"] = "sejour.sejour_id = operations.sejour_id"; $where["operations.date"] = "= '{$date}'"; $where["operations.plageop_id"] = "IS NULL"; $where["operations.annulee"] = "= '0'"; $where["sejour.group_id"] = "= '" . CGroups::loadCurrent()->_id . "'"; /** @var COperation[] $horsplages */ $horsplages = $operation->loadList($where, null, null, null, $ljoin); $totalOp += count($horsplages); foreach ($horsplages as $_operation) { $counts["urgences"]["total"]++; if ($_operation->facture) { $counts["urgences"]["facturees"]++; } } /** * Comptage des séjours */ $group = CGroups::loadCurrent(); $next = CMbDT::date("+1 day", $date); $sejour = new CSejour(); $where = array(); $where["entree"] = "< '{$next}'";
//Instanciation du planning $planning = new CPlanningWeek($debut, $debut, $fin, $nbDays, false, $print ? "1000" : "auto"); $planning->title = $prat->_view; $planning->guid = $prat->_guid; $planning->hour_min = "07"; $planning->hour_max = "20"; $planning->pauses = array("07", "12", "19"); $whereHP["plageop_id"] = " IS NULL"; for ($i = 0; $i < $nbDays; $i++) { $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); }
$prestation_id = CAppUI::pref("prestation_id_hospi"); if (CAppUI::conf("dPhospi prestations systeme_prestations", $group) == "standard" || $prestation_id == "all") { $prestation_id = ""; } $prestation = new CPrestationJournaliere(); $prestation->load($prestation_id); $format_print = CAppUI::conf("dPbloc printing format_print", $group); $ordre_passage_temp = array(); $ordre_passage = array(); // Operations de chaque plage foreach ($plagesop as $plage) { $plage->loadRefsFwd(1); $where["operations.plageop_id"] = "= '{$plage->_id}'"; $op = new COperation(); /** @var COperation[] $listOp */ $listOp = $op->loadList($where, $order, null, null, $ljoin); $chirs = CStoredObject::massLoadFwdRef($listOp, "chir_id"); $sejours = CStoredObject::massLoadFwdRef($listOp, "sejour_id"); CStoredObject::massLoadFwdRef($sejours, "patient_id"); foreach ($listOp as $key => $operation) { $operation->loadRefPlageOp(); if ($operation->_datetime_best < $filter->_datetime_min || $operation->_datetime_best > $filter->_datetime_max) { unset($listOp[$key]); continue; } $operation->loadRefsConsultAnesth(); if ($no_consult_anesth && $operation->_ref_consult_anesth->_id) { unset($listOp[$operation->_id]); } $operation->loadRefPraticien(); $operation->loadExtCodesCCAM();
$joins = array(); $where["plageop_id"] = "= '{$_plage->_id}'"; $where["annulee"] = "= '0'"; // Intervention ordonnancé switch ($filter->_ranking) { case "ok": $where["rank"] = "!= '0'"; break; case "ko": $where["rank"] = "= '0'"; } if ($filter->_codes_ccam) { $where["codes_ccam"] = "LIKE '%{$filter->_codes_ccam}%'"; } $order = "operations.rank"; $listOperations = $tempOp->loadList($where, $order, null, null, $ljoin); // Urgences $where["plageop_id"] = "IS NULL"; $where["salle_id"] = "= '{$_plage->salle_id}'"; $where["chir_id"] = "= '{$_plage->chir_id}'"; $where["date"] = "= '{$_plage->date}'"; $where["operation_id"] = $_plage->_spec->ds->prepareNotIn($listUrgencesTraitees); $listUrgences = $tempOp->loadList($where, $order, null, null, $ljoin); $listUrgencesTraitees = array_merge($listUrgencesTraitees, array_keys($listUrgences)); // On compile les interventions $_plage->_ref_operations = array_merge($listOperations, $listUrgences); } else { // Cas des urgences restantes $ljoin["sejour"] = "sejour.sejour_id = operations.sejour_id"; $where["sejour.group_id"] = "= '{$group->_id}'"; $where["plageop_id"] = "IS NULL";
/** * Load the COperation to send from the linked CSalle objects * * @param CSalle[] $linked_objects The linked objects * * @return COperation[] */ protected static function loadOperationsFromLinkedObjects($linked_objects) { $salles = array(); foreach ($linked_objects as $_linked_object) { $salles[] = $_linked_object->object_id; } $operation = new COperation(); $where = array('salle_id' => CMySQLDataSource::prepareIn($salles), 'date' => " = '" . CMbDT::date() . "'", 'plageop_id' => ' IS NULL'); /* Loading the unplanned operations */ $unplanned_operations = $operation->loadList($where); $ljoin = array("plagesop" => "plagesop.plageop_id = operations.plageop_id"); $where = array("plagesop.salle_id" => CMySQLDataSource::prepareIn($salles), "plagesop.date" => " = '" . CMbDT::date() . "'", "operations.salle_id" => CMySQLDataSource::prepareIn($salles)); /* Loading the planned operations */ $operations = $operation->loadList($where, null, null, null, $ljoin); $operations = array_merge($operations, $unplanned_operations); CMbObject::massLoadFwdRef($operations, 'plageop_id'); CMbObject::massLoadFwdRef($operations, 'chir_id'); CMbObject::massLoadFwdRef($operations, 'sejour_id'); return $operations; }
} $operation = new COperation(); // Liste des interventions non validées $ljoin = array(); $ljoin["plagesop"] = "operations.plageop_id = plagesop.plageop_id"; $where = array(); $where["plagesop.date"] = "BETWEEN '{$date}' AND '{$fin}'"; if ($bloc->_id) { $salles = $bloc->loadRefsSalles(); $where["plagesop.salle_id"] = CSQLDataSource::prepareIn(array_keys($salles)); } $where["operations.annulee"] = "= '0'"; $where["operations.rank"] = "= '0'"; $order = "plagesop.date, plagesop.chir_id"; /** @var COperation[] $listNonValidees */ $listNonValidees = $operation->loadList($where, $order, null, null, $ljoin); foreach ($listNonValidees as $_operation) { $_operation->loadRefPlageOp(); $_operation->loadExtCodesCCAM(); $_operation->loadRefPraticien()->loadRefFunction(); $_operation->loadRefPatient(); } $listHorsPlage = CIntervHorsPlage::getForDates($date, $fin, null, array_keys($bloc->_ref_salles)); foreach ($listHorsPlage as $_operation) { $_operation->loadRefPlageOp(); $_operation->loadExtCodesCCAM(); $_operation->loadRefPraticien()->loadRefFunction(); $_operation->loadRefPatient(); } // Création du template $smarty = new CSmartyDP();
$bloc->type = "obst"; $bloc->group_id = $group->_id; /** @var CBlocOperatoire[] $blocs */ $blocs = $bloc->loadMatchingList(); $salles = array(); foreach ($blocs as $_bloc) { $salles = $_bloc->loadRefsSalles(); foreach ($salles as $_salle) { $salles[$_salle->_id] = $_salle->_id; } } // anesth $anesth = new CMediusers(); $anesths = $anesth->loadListFromType(array("Anesthésiste"), PERM_READ); /** @var COperation[] $ops */ $ops = $op->loadList($where, "date DESC, time_operation", null, null, $ljoin); CMbObject::massLoadFwdRef($ops, "sejour_id"); CMbObject::massLoadFwdRef($ops, "anesth_id"); $chirs = CMbObject::massLoadFwdRef($ops, "chir_id"); CMbObject::massLoadFwdRef($chirs, "function_id"); foreach ($ops as $_op) { $_op->loadRefChir()->loadRefFunction(); $_op->loadRefAnesth(); $_op->loadRefSalle(); $_op->loadRefPlageOp(); $sejour = $_op->loadRefSejour(); $sejour->loadRefCurrAffectation(); $grossesse = $sejour->loadRefGrossesse(); $grossesse->loadRefsNaissances(); $grossesse->loadRefParturiente(); $_op->updateDatetimes();
} if ($salle_id) { $where["operations.salle_id"] = $ds->prepare("=?", $salle_id); } if ($bloc_id) { $ljoin["sallesbloc"] = "sallesbloc.salle_id = operations.salle_id"; $where["sallesbloc.bloc_id"] = $ds->prepare("=?", $bloc_id); } if ($hors_plage) { $where["operations.plageop_id"] = "IS NULL"; } if ($codes_ccam) { $where["operations.codes_ccam"] = $ds->prepare("LIKE %", "%{$codes_ccam}%"); } /** @var COperation[] $interventions */ $interventions = $interv->loadList($where, null, null, "operation_id", $ljoin); // Chargements de masse $sejours = CMbObject::massLoadFwdRef($interventions, "sejour_id"); CMbObject::massLoadFwdRef($sejours, "patient_id"); CMbObject::massLoadFwdRef($sejours, "praticien_id"); CMbObject::massLoadFwdRef($interventions, "chir_id"); $columns = array("IPP", "Nom", "Nom naissance", "Prénom", "Date naissance", "Sexe", "Date intervention", "Libellé intervention", "Chirurgien nom", "Chirurgien prénom", "NDA", "Praticien nom", "Praticien prénom", "Date entrée", "Date sortie"); $csv = new CCSVFile(); $csv->writeLine($columns); foreach ($interventions as $_intervention) { $_sejour = $_intervention->loadRefSejour(); $_patient = $_sejour->loadRefPatient(); $_praticien = $_sejour->loadRefPraticien(); $_chir = $_intervention->loadRefChir(); $_patient->loadIPP(); $_sejour->loadNDA();
* dPboard * * @category Board * @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 */ global $prat; $date_interv = CValue::getOrSession("date_interv", CMbDT::date()); // Chargement des plages du mois $plage = new CPlageOp(); $where = array("date" => "= '" . $date_interv . "'", "chir_id" => "= '" . $prat->_id . "'"); $order = "date, debut"; $listPlages = $plage->loadList($where, $order); $interv = new COperation(); $where = array(); $where[] = "(plageop_id " . CSQLDataSource::prepareIn(array_keys($listPlages)) . " OR (operations.date = '{$date_interv}' AND operations.chir_id = '" . $prat->_id . "'))"; /** @var COperation[] $listIntervs */ $listIntervs = $interv->loadList($where); foreach ($listIntervs as &$_interv) { $_interv->loadRefsFwd(); } // Variables de templates $smarty = new CSmartyDP(); $smarty->assign("date_interv", $date_interv); $smarty->assign("listIntervs", $listIntervs); $smarty->assign("prec", CMbDT::date("-1 DAYS", $date_interv)); $smarty->assign("suiv", CMbDT::date("+1 DAYS", $date_interv)); $smarty->display("vw_trace_cotes.tpl");
/** * Mine or remine the first available operations * * @param int $limit * @param string $phase * * @return array Success/failure counts report */ function mineSome($limit = 100, $phase = "mine") { $report = array("success" => 0, "failure" => 0); if (!$limit) { return $report; } $operation = new COperation(); /** @var COperation[] $operations */ $operations = array(); if ($phase == "remine") { $date = CMbDT::date(self::$remine_delay); $where["date"] = "< '{$date}'"; $where["remined"] = "= '0'"; $mined = $this->loadList($where, null, $limit); $operation_ids = CMbArray::pluck($mined, "operation_id"); $operations = $operation->loadAll($operation_ids); } if ($phase == "postmine") { $date = CMbDT::date(self::$postmine_delay); $where["date"] = "< '{$date}'"; $where["postmined"] = "= '0'"; $mined = $this->loadList($where, null, $limit); $operation_ids = CMbArray::pluck($mined, "operation_id"); $operations = $operation->loadAll($operation_ids); } if ($phase == "mine") { $date = CMbDT::date(self::$mine_delay); $table = $this->_spec->table; $ljoin[$table] = "{$table}.operation_id = operations.operation_id"; $where[] = "operations.date < '{$date}'"; $where["{$table}.operation_id"] = "IS NULL"; $operations = $operation->loadList($where, null, $limit, null, $ljoin); } $plages = CStoredObject::massLoadFwdRef($operations, "plageop_id"); $salles = CStoredObject::massLoadFwdRef($plages, "salle_id"); CStoredObject::massLoadFwdRef($salles, "bloc_id"); foreach ($operations as $_operation) { $_operation->loadRefPlageOp(); $this->mine($_operation); if ($msg = $this->store()) { trigger_error($msg, UI_MSG_ERROR); $report["failure"]++; continue; } $report["success"]++; } return $report; }
* @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ */ CCanDo::checkRead(); $operation_id = CValue::getOrSession("operation_id"); $date = CValue::getOrSession("date", CMbDT::date()); $hour = CMbDT::time(); $totaltime = "00:00:00"; // Selection des plages opératoires de la journée $plages = new CPlageOp(); $where = array(); $where["date"] = "= '{$date}'"; $plages = $plages->loadList($where); // Récupération des détails des RSPO. $interv = new COperation(); $where = array(); $where[] = "`plageop_id` " . CSQLDataSource::prepareIn(array_keys($plages)) . " OR (`plageop_id` IS NULL AND `date` = '{$date}')"; $leftjoin["blood_salvage"] = "operations.operation_id = blood_salvage.operation_id"; $where["blood_salvage.operation_id"] = "IS NOT NULL"; $order = "entree_reveil"; /** @var COperation[] $listReveil */ $listReveil = $interv->loadList($where, $order, null, null, $leftjoin); foreach ($listReveil as $key => $value) { $listReveil[$key]->loadRefs(); } $smarty = new CSmartyDP(); $smarty->assign("listReveil", $listReveil); $smarty->assign("date", $date); $smarty->assign("hour", $hour); $smarty->assign("operation_id", $operation_id); $smarty->display("inc_liste_patients_bs.tpl");
foreach ($consultations as $_consult) { /* @var CConsultation $_consult*/ $_consult->loadRefPlageConsult()->loadRefChir(); $color = "#cfc"; $libelle = $_consult->_view . " - " . $_consult->_ref_plageconsult->_ref_chir->_view; $event = new CPlanningEvent($_consult->_guid, $_consult->_datetime, CMbDT::minutesRelative($_consult->_datetime, $_consult->_date_fin), $libelle, $color, true); $event->onmousover = true; $planning->addEvent($event); } $ljoin = array(); $ljoin['plagesop'] = "plagesop.plageop_id = operations.plageop_id"; $where = array(); $where[] = "(plagesop.date BETWEEN '{$debut}' AND '{$fin}') OR (operations.date BETWEEN '{$debut}' AND '{$fin}')"; $where["operations.sejour_id"] = " = '{$sejour_id}'"; $operation = new COperation(); $operations = $operation->loadList($where, null, null, "operation_id", $ljoin); foreach ($operations as $_operation) { /* @var COperation $_operation*/ $_operation->loadRefChir(); $_operation->loadRefPlageOp(); $color = "#fcc"; $class = null; if ($_operation->_acte_execution == $_operation->_datetime) { $_operation->_acte_execution = CMbDT::addDateTime($_operation->temp_operation, $_operation->_datetime); } $libelle = "Intervention par le Dr " . $_operation->_ref_chir->_view . " - {$_operation->libelle}"; $event = new CPlanningEvent($_operation->_guid, $_operation->_datetime, CMbDT::minutesRelative($_operation->_datetime, $_operation->_acte_execution), $libelle, $color, true); $event->onmousover = true; $planning->addEvent($event); } $dates = array($debut, $fin);
$view = CValue::get("view", 1); $date = CMbDT::date(); $request = "SELECT `operations`.*\r\n FROM `operations`\r\n LEFT JOIN `plagesop` ON `operations`.`plageop_id` = `plagesop`.`plageop_id`\r\n WHERE `operations`.`ASA` = '1'\r\n AND (`plagesop`.`date` >= '" . $date . "'\r\n OR `operations`.`date` >= '" . $date . "')\r\n AND NOT EXISTS (\r\n SELECT * FROM `consultation_anesth`\r\n WHERE `consultation_anesth`.`operation_id` = `operations`.`operation_id`\r\n );"; $resultats = $ds->loadList($request); if ($view == false) { $request = "UPDATE `operations`\r\n LEFT JOIN `plagesop` ON `operations`.`plageop_id` = `plagesop`.`plageop_id`\r\n SET `operations`.`ASA` = NULL\r\n WHERE `operations`.`ASA` = '1'\r\n AND (`plagesop`.`date` >= '" . $date . "'\r\n OR `operations`.`date` >= '" . $date . "')\r\n AND NOT EXISTS (\r\n SELECT * FROM `consultation_anesth`\r\n WHERE `consultation_anesth`.`operation_id` = `operations`.`operation_id`\r\n );"; $ds->query($request); $result = $ds->affectedRows(); CAppUI::stepAjax(count($resultats) . " intervention(s) modifiée(s)", UI_MSG_OK); } else { $where = array(); $where["operation_id"] = CSQLDataSource::prepareIn(CMbArray::pluck($resultats, "operation_id")); /* @var COperation[] $operations*/ $operation = new COperation(); $nb_operations = $operation->countList($where); $operations = $operation->loadList($where, null, "100"); $sejours = CMbObject::massLoadFwdRef($operations, "sejour_id"); CMbObject::massLoadFwdRef($sejours, "patient_id"); CMbObject::massLoadFwdRef($operations, "plageop_id"); CMbObject::massLoadFwdRef($operations, "chir_id"); foreach ($operations as $op) { $op->loadRefPraticien(); $op->loadRelPatient(); $op->loadRefPlageOp(); } // Creation du template $smarty = new CSmartyDP(); $smarty->assign("operations", $operations); $smarty->assign("nb_operations", $nb_operations); $smarty->display("check_score_asa.tpl"); }
/** * $Id$ * * @package Mediboard * @subpackage PlanningOp * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ */ CCanDo::checkAdmin(); $operation = new COperation(); // Nombre d'interventions... $counts["total"] = $operation->countList(); // Dans une plage... $where["operations.plageop_id"] = "IS NOT NULL"; $counts["plaged"] = $operation->countList($where); // Sans date! $where["operations.date"] = "IS NULL"; $counts["missing"] = $operation->countList($where); // Avec une date erronée! $ljoin["plagesop"] = "plagesop.plageop_id = operations.plageop_id"; $where["operations.date"] = "IS NOT NULL"; $where[] = "plagesop.date != operations.date"; $counts["wrong"] = $operation->countList($where, null, $ljoin); foreach ($operation->loadList($where, null, null, null, $ljoin) as $_operation) { mbTrace($_operation->_guid, $_operation->plageop_id); } // Création du template $smarty = new CSmartyDP(); $smarty->assign("counts", $counts); $smarty->display("check_date_intervention.tpl");
} } } } // Interventions hors plages non traitées $op = new COperation(); $ljoin = array(); $ljoin["sejour"] = "operations.sejour_id = sejour.sejour_id"; $where = array(); $where["operations.date"] = "= '{$date_suivi}'"; $where["operations.salle_id"] = "IS NULL"; $where["operations.plageop_id"] = "IS NULL"; $where["operations.chir_id"] = CSQLDataSource::prepareIn(array_keys($listChirs)); $where["sejour.group_id"] = "= '" . $group->_id . "'"; /** @var COperation[] $non_traitees */ $non_traitees = $op->loadList($where, null, null, null, $ljoin); foreach ($non_traitees as $_operation) { $_operation->loadRefChir(); $_operation->loadRefPatient(); $_operation->loadExtCodesCCAM(); $_operation->loadRefPlageOp(); } // Création du template $smarty = new CSmartyDP(); $smarty->assign("vueReduite", true); $smarty->assign("listAnesths", $listAnesths); $smarty->assign("listBlocs", $listBlocs); $smarty->assign("bloc", $bloc); $smarty->assign("date_suivi", $date_suivi); $smarty->assign("operation_id", 0); $smarty->assign("non_traitees", $non_traitees);
// $order = "operations.entree_reveil"; $order_col = CValue::getOrSession("order_col_{$type}", "entree_reveil"); break; default: $where["operations.sortie_reveil_reel"] = "IS NOT NULL"; // $order = "operations.sortie_reveil_possible DESC"; $order_col = CValue::getOrSession("order_col_{$type}", "sortie_reveil_possible"); $order_way = CValue::getOrSession("order_way_{$type}", "DESC"); break; } if ($order_col == "_patient") { $order_col = "entree_salle"; } // Chargement des interventions $operation = new COperation(); $listOperations = $operation->loadList($where, "{$order_col} {$order_way_final}", null, null, $ljoin); // Optimisations de chargement $chirs = CMbObject::massLoadFwdRef($listOperations, "chir_id"); CMbObject::massLoadFwdRef($chirs, "function_id"); CMbObject::massLoadFwdRef($listOperations, "plageop_id"); if ($use_poste) { CMbObject::massLoadFwdRef($listOperations, "poste_sspi_id"); CMbObject::massLoadFwdRef($listOperations, "poste_preop_id"); } $anesths = CMbObject::massLoadFwdRef($listOperations, "sortie_locker_id"); CMbObject::massLoadFwdRef($anesths, "function_id"); if (in_array($type, array("ops", "reveil")) && CModule::getActive("bloodSalvage")) { CMbObject::massCountBackRefs($listOperations, "blood_salvages"); } $sejours = CMbObject::massLoadFwdRef($listOperations, "sejour_id"); CMbObject::massLoadFwdRef($sejours, "patient_id");
$where["duree_uscpo"] = "> 0"; $where["annulee"] = "!= '1'"; $operation = new COperation(); $max_uscpo = $operation->_specs["duree_uscpo"]->max; // Minimal date will narrow scope and boost index execution greatly $date_min = CMbDT::date("-{$max_uscpo} DAY", $date); $where[] = "operations.date BETWEEN '{$date_min}' AND '{$date}'"; $where[] = "DATE_ADD(operations.date, INTERVAL duree_uscpo DAY) > '{$date}'"; $ljoin["sejour"] = "sejour.sejour_id = operations.sejour_id"; $where["sejour.group_id"] = "= '{$group_id}'"; if ($service_id) { $where["sejour.service_id"] = " = '{$service_id}'"; } $where[] = "operations.passage_uscpo = '1' or operations.passage_uscpo IS NULL"; // Prévues $operations_prevues = $operation->loadList($where, null, null, null, $ljoin, $index); // Placées $ljoin["affectation"] = "affectation.sejour_id = operations.sejour_id"; $where[] = "DATE_ADD(operations.date, INTERVAL duree_uscpo DAY) <= affectation.sortie"; $operations_placees = $operation->loadList($where, null, null, null, $ljoin, $index); /** @var COperation[] $operations */ $operations = array_merge($operations_placees, $operations_prevues); CMbObject::massLoadFwdRef($operations, "plageop_id"); CMbObject::massLoadFwdRef($operations, "chir_id"); foreach ($operations as $_operation) { $_operation->loadRefPatient(); $_operation->loadRefPlageOp(); $_operation->loadRefChir()->loadRefFunction(); } $smarty = new CSmartyDP(); $smarty->assign("operations_prevues", $operations_prevues);
$boardItem = CValue::get("boardItem", 0); $nb_canceled = 0; $current_group = CGroups::loadCurrent(); // Urgences du jour $list_urgences = array(); $operation = new COperation(); if ($userSel->_id) { $where = array(); $where["date"] = "= '{$date}'"; $where["plageop_id"] = "IS NULL"; $where[] = "chir_id = '{$userSel->_id}' OR anesth_id = '{$userSel->_id}'"; if (!$canceled) { $where["annulee"] = "= '0'"; } /** @var COperation[] $list_urgences */ $list_urgences = $operation->loadList($where, "annulee, date"); $where["annulee"] = "= '1'"; $nb_canceled += $operation->countList($where); $sejours = CMbObject::massLoadFwdRef($list_urgences, "sejour_id"); CMbObject::massLoadFwdRef($sejours, "patient_id"); CMbObject::massCountBackRefs($list_urgences, 'actes_ccam'); foreach ($list_urgences as $_urg) { $_urg->canDo(); $_urg->loadRefsFwd(); $_urg->loadRefCommande(); $_sejour = $_urg->_ref_sejour; $_urg->countDocItems(); /* Comptage du nombre d'activités CCAM */ $_urg->_count['codes_ccam'] = 0; foreach (CMbArray::pluck($_urg->_ext_codes_ccam, "activites") as $_code) { $_urg->_count['codes_ccam'] += count($_code);
/** * 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(); } }
$whereHospi[] = $where_anesth; if (!$canceled) { $whereHospi["operations.annulee"] = " = '0'"; } $whereUrg = array("plagesop.plageop_id" => "IS NULL", "operations.date" => "= '{$date}'", "sejour.group_id" => "= '{$group->_id}'"); $whereUrg[] = $where_anesth; if (!$canceled) { $whereUrg["operations.annulee"] = " = '0'"; } /** @var COperation[] $allInterv */ $allInterv = array(); foreach ($services as $_service) { $whereAmbu["service.service_id"] = "= '{$_service->_id}'"; $whereHospi["service.service_id"] = "= '{$_service->_id}'"; $whereUrg["service.service_id"] = "= '{$_service->_id}'"; $listInterv["ambu"][$_service->_id] = $interv->loadList($whereAmbu, $order, null, null, $ljoin); $listInterv["comp"][$_service->_id] = $interv->loadList($whereHospi, $order, null, null, $ljoin); $listInterv["hors_plage"][$_service->_id] = $interv->loadList($whereUrg, $order, null, null, $ljoin); $allInterv = array_merge($allInterv, $listInterv["ambu"][$_service->_id]); $allInterv = array_merge($allInterv, $listInterv["comp"][$_service->_id]); $allInterv = array_merge($allInterv, $listInterv["hors_plage"][$_service->_id]); $count_ops["ambu"] += count($listInterv["ambu"][$_service->_id]); $count_ops["comp"] += count($listInterv["comp"][$_service->_id]); $count_ops["hors_plage"] += count($listInterv["hors_plage"][$_service->_id]); } $whereAmbu["service.service_id"] = "IS NULL"; $whereHospi["service.service_id"] = "IS NULL"; $whereUrg["service.service_id"] = "IS NULL"; $listInterv["ambu"]["non_place"] = $interv->loadList($whereAmbu, $order, null, null, $ljoin); $listInterv["comp"]["non_place"] = $interv->loadList($whereHospi, $order, null, null, $ljoin); $listInterv["hors_plage"]["non_place"] = $interv->loadList($whereUrg, $order, null, null, $ljoin);
/** * Chargement des interventions * * @param bool $annulee Prise en compte des interventions annulées * @param string $order Paramètre ORDER SQL * @param bool $sorted Utilisation du paramètre ORDER SQL passé en paramètre * @param null $validated Uniquement les validées * @param array $where Tableau de paramètres WHERE SQL * * @return COperation[] */ function loadRefsOperations($annulee = true, $order = "rank, time_operation, rank_voulu, horaire_voulu", $sorted = false, $validated = null, $where = array()) { $where += array("plageop_id" => "= '{$this->plageop_id}'"); if (!$annulee) { $where["annulee"] = "= '0'"; } /** @var COperation[] $operations */ $operations = array(); $op = new COperation(); if (!$sorted) { $operations = $op->loadList($where, $order); } else { $order = "rank, rank_voulu, horaire_voulu"; if ($validated === null || $validated === true) { $where["rank"] = "> 0"; $operations = CMbArray::mergeKeys($operations, $op->loadList($where, $order)); } if ($validated === null || $validated === false) { // Sans rank $where["rank"] = "= 0"; $where["rank_voulu"] = "> 0"; $operations = CMbArray::mergeKeys($operations, $op->loadList($where, $order)); // Sans rank voulu $where["rank_voulu"] = "= 0"; $where["horaire_voulu"] = "IS NOT NULL"; $operations = CMbArray::mergeKeys($operations, $op->loadList($where, $order)); $where["horaire_voulu"] = "IS NULL"; $operations = CMbArray::mergeKeys($operations, $op->loadList($where, $order)); } } foreach ($operations as $_operation) { $_operation->_ref_plageop = $this; if ($_operation->temp_operation) { $this->_cumulative_minutes = $this->_cumulative_minutes + CMbDT::minutesRelative("00:00:00", $_operation->temp_operation); } } return $this->_ref_operations = $operations; }
/** * 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(); } } }
$_operation->_pat_next = $next !== false ? $next->entree_salle : null; $_operation->_ref_plageop = $_plage; $operations[$_operation->_id] = $_operation; } } } else { // Récupération des interventions $where = array(); $where[] = "date BETWEEN '{$deblist}' AND '{$finlist}'"; $where[] = "salle_id " . CSQLDataSource::prepareIn(array_keys($salles)) . " OR salle_id IS NULL"; if ($type != "all") { $where["plageop_id"] = "IS NULL"; } $order = "date, salle_id, chir_id"; $operation = new COperation(); $operations = $operation->loadList($where, $order); foreach ($operations as $_operation) { // Calcul du rang $_operation->_rank_reel = $_operation->entree_salle ? $nb_interv : ""; $nb_interv++; $_operation->_pat_next = null; } } // Chargement exhaustif CStoredObject::massLoadFwdRef($operations, "anesth_id"); CStoredObject::massLoadFwdRef($operations, "chir_id"); $sejours = CStoredObject::massLoadFwdRef($operations, "sejour_id"); CStoredObject::massLoadFwdRef($sejours, "patient_id"); foreach ($operations as $_operation) { $_operation->updateDatetimes(); $_operation->loadRefAnesth();
* @link http://www.mediboard.org */ CCanDo::checkRead(); $date = CValue::get("date"); $bloc_id = CValue::get("bloc_id"); $bloc = new CBlocOperatoire(); $bloc->load($bloc_id); $in_salles = CSQLDataSource::prepareIn($bloc->loadBackIds("salles")); $ljoin["plagesop"] = "operations.plageop_id = plagesop.plageop_id"; $where[] = "operations.salle_id {$in_salles} OR plagesop.salle_id {$in_salles}"; $where[] = "operations.date = '{$date}'"; $where["labo"] = "= 1"; $order = "entree_salle, time_operation"; $operation = new COperation(); /** @var COperation[] $operations */ $operations = $operation->loadList($where, $order, null, null, $ljoin); CMbObject::massLoadFwdRef($operations, "plageop_id"); $chirs = CMbObject::massLoadFwdRef($operations, "chir_id"); CMbObject::massLoadFwdRef($chirs, "function_id"); $sejours = CMbObject::massLoadFwdRef($operations, "sejour_id"); CMbObject::massLoadFwdRef($sejours, "patient_id"); foreach ($operations as $_operation) { $_operation->loadRefPatient(); $_operation->loadRefPlageOp(); $_operation->updateSalle(); $_operation->loadRefChir()->loadRefFunction(); $_operation->loadExtCodesCCAM(); } // Création du template $smarty = new CSmartyDP(); $smarty->assign("date", $date);
CCanDo::checkRead(); $date = CValue::getOrSession("date", CMbDT::date()); $page = CValue::get("pageUrg", 0); $operation = new COperation(); $where = array(); $ljoin["sejour"] = "sejour.sejour_id = operations.sejour_id"; $where["operations.date"] = "= '{$date}'"; $where["operations.plageop_id"] = "IS NULL"; $where["operations.annulee"] = "= '0'"; $where["sejour.group_id"] = "= '" . CGroups::loadCurrent()->_id . "'"; $order = "operations.chir_id"; $step = 30; $limit = "{$page},{$step}"; /** @var COperation[] $horsplages */ $count = $operation->countList($where, null, $ljoin); $horsplages = $operation->loadList($where, $order, $limit, null, $ljoin); /** @var CSejour[] $sejours */ $sejours = COperation::massLoadFwdRef($horsplages, "sejour_id"); /** @var CPatient[] $patients */ $patients = CSejour::massLoadFwdRef($sejours, "patient_id"); CSejour::massLoadNDA($sejours); CPatient::massLoadIPP($patients); CSejour::massCountDocItems($sejours); COperation::massCountDocItems($horsplages); $chirurgiens = COperation::massLoadFwdRef($horsplages, "chir_id"); CMediusers::massLoadFwdRef($chirurgiens, "function_id"); foreach ($horsplages as $_operation) { $_operation->loadRefChir()->loadRefFunction(); $_operation->loadExtCodesCCAM(); $_operation->loadRefsDocItems(); $_operation->_ref_sejour = $sejours[$_operation->sejour_id];