$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); } $_sejour->loadRefsFwd();
$day = $date_min; $dates = array(); $series = array(); $serie = array('data' => array(), 'label' => utf8_encode("Nombre de nuits prévues")); $today = CMbDT::date(); while ($day <= $date_max) { $display = CMbDT::dateToLocale($day); // On préfixe d'une étoile si c'est le jour courant if ($day == $today) { $display = "* " . $display; } $dates[] = array(count($dates), $display); $day_min = CMbDT::date("-{$max_uscpo} DAY", $day); $where[10] = "operations.date BETWEEN '{$day_min}' AND '{$day}'"; $where[11] = "DATE_ADD(operations.date, INTERVAL duree_uscpo DAY) > '{$day}'"; $count = $operation->countList($where, null, $ljoin); $day = CMbDT::date("+1 day", $day); $serie['data'][] = array(count($serie['data']) - 0.2, $count); } $series[] = $serie; $day = $date_min; $serie = array('data' => array(), 'label' => utf8_encode("Nombre de nuits placées")); $ljoin["affectation"] = "affectation.sejour_id = operations.sejour_id"; while ($day <= $date_max) { $day_min = CMbDT::date("-{$max_uscpo} DAY", $day); $where[10] = "operations.date BETWEEN '{$day_min}' AND '{$day}'"; $where[11] = "DATE_ADD(operations.date, INTERVAL duree_uscpo DAY) > '{$day}'"; $where[12] = "DATE_ADD(operations.date, INTERVAL duree_uscpo DAY) <= affectation.sortie"; $day = CMbDT::date("+1 day", $day); $count = $operation->countList($where, null, $ljoin); $serie['data'][] = array(count($serie['data']) + 0.2, intval($count));
$event = new CPlanningEvent($_conge->_guid . $_date, $_date, 1430, $libelle, "#ddd", true, "hatching", null, false); $event->below = 1; $planning->addEvent($event); } } } //Operation hors plage $operation = new COperation(); $where = array(); for ($i = 0; $i < 7; $i++) { $date = CMbDT::date("+{$i} day", $debut); $where["date"] = "= '{$date}'"; $where["annulee"] = " = '0'"; $where["plageop_id"] = " IS NULL"; $where[] = "chir_id = '{$chirSel}' OR anesth_id = '{$chirSel}'"; $nb_hors_plages = $operation->countList($where); if ($nb_hors_plages) { $onclick = "viewList('{$date}', null, 'CPlageOp')"; $planning->addDayLabel($date, "{$nb_hors_plages} intervention(s) hors-plage", null, "#ffd700", $onclick); } } /** * Ajout d'un évènement à un planning * * @param CPlanningWeek &$planning planning concerné * @param CPlageHoraire $_plage plage à afficher * @param string $date date de l'évènement * @param string $libelle libellé de l'évènement * @param string $color couleur de l'évènement * @param string $type type de l'évènement * @param string|null $class css class to apply
if ($libelle_intervention) { $where_libelle = "`libelle` LIKE '%{$libelle_intervention}%'"; $where_intervention[] = $where_libelle; } if ($ccam_intervention) { $where_ccam = "`codes_ccam` LIKE '%{$ccam_intervention}%'"; $where_intervention[] = $where_ccam; } if ($where_intervention) { $where_intervention = implode(" OR ", $where_intervention); } } $order_intervention = "rques"; $total_intervs = null; if ($where_intervention) { $total_intervs = $intervention->countList($where_intervention); $interventions = $intervention->loadlist($where_intervention, $order_intervention, "{$page_interv}, 30"); } foreach ($interventions as &$intervention) { $intervention->loadRefSejour(); $intervention->_ref_sejour->loadRefPatient(); } // Création du template $smarty = new CSmartyDP(); $smarty->assign("dossierMedical", $dossierMedical); $smarty->assign("canCabinet", $canCabinet); $smarty->assign("canPlanningOp", $canPlanningOp); $smarty->assign("sejours", $sejours); $smarty->assign("page_sejour", $page_sejour); $smarty->assign("total_sejours", $total_sejours); $smarty->assign("interventions", $interventions);
} $listPlages = array(); $operation = new COperation(); $nbIntervHorsPlage = 0; $listPlage = new CPlageOp(); $nbIntervNonPlacees = 0; // Nombre d'interventions hors plage pour la semaine $ljoin = array(); $ljoin["sejour"] = "sejour.sejour_id = operations.sejour_id"; $where = array(); $where["date"] = "BETWEEN '{$debut}' AND '{$fin}'"; $where["plageop_id"] = "IS NULL"; $where["annulee"] = "= '0'"; $where[] = "salle_id IS NULL OR salle_id " . CSQLDataSource::prepareIn(array_keys($listSalles)); $where["sejour.group_id"] = "= '" . CGroups::loadCurrent()->_id . "'"; $nbIntervHorsPlage = $operation->countList($where, null, $ljoin); foreach ($listDays as $keyDate => $valDate) { // Récupération des plages par jour $where = array(); $where["date"] = "= '{$keyDate}'"; $where["salle_id"] = CSQLDataSource::prepareIn(array_keys($listSalles)); $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["plageop_id"] = "IS NULL"; $where["salle_id"] = CSQLDataSource::prepareIn(array_keys($listSalles)); $order = "time_operation"; $horsPlages = $operation->loadList($where, $order);
<?php /** * $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();
$ds = CSQLDataSource::get("std"); $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");
/** * count list of Op not linked to a plage * * @param date $start date de début * @param date|null $end date de fin * @param array $chir_ids chir targeted * * @return int number of HP found */ static function countForDates($start, $end = null, $chir_ids = array()) { $d_start = $start; $d_end = $end ? $end : $start; $op = new COperation(); $ljoin = array(); $ljoin["sejour"] = "sejour.sejour_id = operations.sejour_id"; $where = array(); if (count($chir_ids)) { $where["chir_id"] = CSQLDataSource::prepareIn($chir_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 . "'"; /** @var COperation[] $listHorsPlage */ return $op->countList($where, null, $ljoin); }
// Chargment du numéro de dossier $_sejour->loadNDA(); $whereOperations = array("annulee" => "= '0'"); // Chargement de l'affectation $_sejour->loadRefsAffectations(); $affectation =& $_sejour->_ref_first_affectation; if ($affectation->_id) { $affectation->loadRefLit(1); $affectation->_ref_lit->loadCompleteView(); } // Pour l'envoi de mail, afficher une enveloppe pour les interventions modifiées par le chirurgien if ($envoi_mail) { $where = array("sejour.sejour_id" => "= '{$_sejour->_id}'", "user_log.user_id" => "= operations.chir_id"); $ljoin = array("sejour" => "sejour.sejour_id = operations.sejour_id", "user_log" => "user_log.object_id = operations.operation_id AND user_log.object_class = 'COperation'"); // @todo déclaration de la variable à réaliser $_sejour->_envoi_mail = $operation->countList($where, null, $ljoin); } } // Si la fonction selectionnée n'est pas dans la liste des fonction, on la rajoute if ($filterFunction && !array_key_exists($filterFunction, $functions)) { $_function = new CFunctions(); $_function->load($filterFunction); $functions[$filterFunction] = $_function; } $m = $save_m; // Création du template $smarty = new CSmartyDP(); $smarty->assign("current_m", $current_m); $smarty->assign("hier", $hier); $smarty->assign("demain", $demain); $smarty->assign("date_min", $date_min);
/** * Count operations that have not been mined yet * * @return int */ function countUnmined() { $date = CMbDT::date(self::$mine_delay); $operation = new COperation(); $table = $this->_spec->table; $ljoin[$table] = "{$table}.operation_id = operations.operation_id"; $where["{$table}.operation_id"] = "IS NULL"; $where[] = "operations.date < '{$date}'"; return $this->_count_unmined = $operation->countList($where, null, $ljoin); }
$listSalles = new CSalle(); $listSalles = $listSalles->loadGroupList(); $plage = new CPlageOp(); $where = array(); $where["date"] = "= '{$date}'"; $where["salle_id"] = CSQLDataSource::prepareIn(array_keys($listSalles)); $order = "debut"; $step = 30; $limit = "{$page},{$step}"; /** @var CPlageOp[] $plages */ $plages = $plage->loadList($where, $order); $operation = new COperation(); $where = array(); $where["plageop_id"] = CSQLDataSource::prepareIn(array_keys($plages)); $where["annulee"] = "= '0'"; $count = $operation->countList($where); $operations = $operation->loadList($where, null, $limit); /** @var CSejour[] $sejours */ $sejours = COperation::massLoadFwdRef($operations, "sejour_id"); /** @var CPatient[] $patients */ $patients = CSejour::massLoadFwdRef($sejours, "patient_id"); CSejour::massLoadNDA($sejours); CPatient::massLoadIPP($patients); CSejour::massCountDocItems($sejours); COperation::massCountDocItems($operations); $chirurgiens = COperation::massLoadFwdRef($operations, "chir_id"); CMediusers::massLoadFwdRef($chirurgiens, "function_id"); /** @var COperation[] $operations */ foreach ($operations as $_operation) { // Détails de l'opérations $_operation->loadRefChir()->loadRefFunction();