$filter->_specialite = CValue::getOrSession("_specialite"); $filter->_filter_type = CValue::getOrSession("_filter_type"); $filter->_ccam_libelle = CValue::getOrSession("_ccam_libelle", "1"); $filter->_coordonnees = CValue::getOrSession("_coordonnees"); $filter->_notes = CValue::getOrSession("_notes"); $filter->_by_date = CValue::getOrSession("_by_date"); $listPrat = new CMediusers(); $listPrat = $listPrat->loadPraticiens(PERM_READ); $listSpec = new CFunctions(); $listSpec = $listSpec->loadSpecialites(PERM_READ); // Récupération de la liste des services $where = array(); $where["externe"] = "= '0'"; $where["cancelled"] = "= '0'"; $service = new CService(); $services = $service->loadGroupList($where); $yesterday = CMbDT::date("-1 day", $today); $tomorrow = CMbDT::date("+1 day", $today); $j2 = CMbDT::date("+2 day", $today); $j3 = CMbDT::date("+3 day", $today); $week_deb = CMbDT::date("last sunday", $today); $week_fin = CMbDT::date("next sunday", $week_deb); $week_deb = CMbDT::date("+1 day", $week_deb); $next_week_deb = CMbDT::date("+1 day", $week_fin); $next_week_fin = CMbDT::date("next sunday", $next_week_deb); $yesterday_deb = "{$yesterday} 06:00:00"; $yesterday_fin = "{$yesterday} 21:00:00"; $today_deb = "{$today} 06:00:00"; $today_fin = "{$today} 21:00:00"; $tomorrow_deb = "{$tomorrow} 06:00:00"; $tomorrow_fin = "{$tomorrow} 21:00:00";
/** * Charge les services d'UHCD et d'urgence de l'établissement courant * * @return CService[] */ static function loadServicesUHCDRPU() { $where = array(); $clause = "uhcd = '1' OR urgence = '1'"; $where[] = $clause; $where["cancelled"] = " = '0'"; $service = new CService(); /** @var CService[] $services */ $services = $service->loadGroupList($where); foreach ($services as $_service) { $_service->loadRefsChambres(); foreach ($_service->_ref_chambres as $_chambre) { $_chambre->loadRefsLits(); } } return $services; }
$sans_anesth = CValue::getOrSession("sans_anesth", 0); // Sélection du praticien $mediuser = CMediusers::get(); $listPrat = $mediuser->loadPraticiens(PERM_EDIT); foreach ($listPrat as $_prat) { $_prat->loadRefFunction(); } $selPrat = CValue::getOrSession("selPrat", $mediuser->isPraticien() ? $mediuser->user_id : null); $selPraticien = new CMediusers(); $selPraticien->load($selPrat); $group = CGroups::loadCurrent(); if ($selPraticien->isAnesth()) { // Selection des différentes interventions de la journée par service $count_ops = array("ambu" => 0, "comp" => 0, "hors_plage" => 0); $service = new CService(); $services = $service->loadGroupList(); $interv = new COperation(); $order = "operations.chir_id, operations.time_operation"; $ljoin = array("plagesop" => "plagesop.plageop_id = operations.plageop_id", "sejour" => "sejour.sejour_id = operations.sejour_id", "affectation" => "affectation.sejour_id = sejour.sejour_id\r\n AND '{$date}' BETWEEN DATE(affectation.entree)\r\n AND DATE(affectation.sortie)", "lit" => "lit.lit_id = affectation.lit_id", "chambre" => "chambre.chambre_id = lit.chambre_id", "service" => "service.service_id = chambre.service_id"); $where_anesth = "operations.anesth_id = '{$selPraticien->_id}' OR plagesop.anesth_id = '{$selPraticien->_id}'"; if ($sans_anesth) { $where_anesth .= " OR operations.anesth_id IS NULL OR plagesop.anesth_id IS NULL"; } $whereAmbu = array("operations.date" => "= '{$date}'", "sejour.type" => "= 'ambu'", "sejour.group_id" => "= '{$group->_id}'"); $whereAmbu[] = $where_anesth; if (!$canceled) { $whereAmbu["operations.annulee"] = " = '0'"; } $whereHospi = array("operations.date" => "= '{$date}'", "sejour.type" => "= 'comp'", "sejour.group_id" => "= '{$group->_id}'"); $whereHospi[] = $where_anesth; if (!$canceled) {
/** * Affichage du graphique de la réparition des patients par service * * @param date $debut Début de la période * @param date $fin Fin de la période * @param int $prat_id Filtre sur un praticien * @param int $service_id Filtre sur un service * @param string $type_adm Filtre sur le type d'admission * @param int $func_id Filtre sur un cabinet * @param int $discipline_id Filtre sur une discipline * @param int $septique Filtre sur les patients septiques * @param string $type_data Choix du type de données * * @return array */ function graphPatParService($debut = null, $fin = null, $prat_id = 0, $service_id = 0, $type_adm = "", $func_id = 0, $discipline_id = 0, $septique = 0, $type_data = "prevue") { if (!$debut) { $debut = CMbDT::date("-1 YEAR"); } if (!$fin) { $fin = CMbDT::date(); } $group_id = CGroups::loadCurrent()->_id; $prat = new CMediusers(); $prat->load($prat_id); $discipline = new CDiscipline(); $discipline->load($discipline_id); $ticks = array(); $serie_total = array('label' => 'Total', 'data' => array(), 'markers' => array('show' => true), 'bars' => array('show' => false)); for ($i = $debut; $i <= $fin; $i = CMbDT::date("+1 MONTH", $i)) { $ticks[] = array(count($ticks), CMbDT::transform("+0 DAY", $i, "%m/%Y")); $serie_total['data'][] = array(count($serie_total['data']), 0); } $where = array(); if ($service_id) { $where["service_id"] = "= '{$service_id}'"; } $service = new CService(); $services = $service->loadGroupList($where); $sejour = new CSejour(); $listHospis = array(1 => "Hospi complètes + ambu") + $sejour->_specs["type"]->_locales; $total = 0; $series = array(); // Patients placés foreach ($services as $service) { $serie = array('data' => array(), 'label' => utf8_encode($service->nom)); $query = "SELECT COUNT(DISTINCT sejour.sejour_id) AS total, service.nom AS nom,\r\n DATE_FORMAT(affectation.entree, '%m/%Y') AS mois,\r\n DATE_FORMAT(affectation.entree, '%Y%m') AS orderitem\r\n FROM sejour\r\n LEFT JOIN users_mediboard ON sejour.praticien_id = users_mediboard.user_id\r\n LEFT JOIN affectation ON sejour.sejour_id = affectation.sejour_id\r\n LEFT JOIN service ON affectation.service_id = service.service_id\r\n WHERE\r\n sejour.annule = '0' AND\r\n sejour.group_id = '{$group_id}' AND\r\n affectation.entree < '{$fin} 23:59:59' AND\r\n affectation.sortie > '{$debut} 00:00:00' AND\r\n service.service_id = '{$service->_id}'"; if ($type_data == "reelle") { $query .= "\nAND sejour.entree_reelle BETWEEN '{$debut} 00:00:00' AND '{$fin} 23:59:59'"; } if ($prat_id) { $query .= "\nAND sejour.praticien_id = '{$prat_id}'"; } if ($discipline_id) { $query .= "\nAND users_mediboard.discipline_id = '{$discipline_id}'"; } if ($septique) { $query .= "\nAND sejour.septique = '{$septique}'"; } if ($type_adm) { if ($type_adm == 1) { $query .= "\nAND (sejour.type = 'comp' OR sejour.type = 'ambu')"; } else { $query .= "\nAND sejour.type = '{$type_adm}'"; } } $query .= "\nGROUP BY mois ORDER BY orderitem"; $result = $sejour->_spec->ds->loadlist($query); foreach ($ticks as $i => $tick) { $f = true; foreach ($result as $r) { if ($tick[1] == $r["mois"]) { $serie["data"][] = array($i, $r["total"]); $serie_total["data"][$i][1] += $r["total"]; $total += $r["total"]; $f = false; break; } } if ($f) { $serie["data"][] = array(count($serie["data"]), 0); } } $series[] = $serie; } // Patients non placés if (!$service_id) { $serie = array('data' => array(), 'label' => utf8_encode("Non placés")); $query = "SELECT COUNT(DISTINCT sejour.sejour_id) AS total, 'Non placés' AS nom,\r\n DATE_FORMAT(sejour.entree_{$type_data}, '%m/%Y') AS mois,\r\n DATE_FORMAT(sejour.entree_{$type_data}, '%Y%m') AS orderitem\r\n FROM sejour\r\n LEFT JOIN users_mediboard ON sejour.praticien_id = users_mediboard.user_id\r\n LEFT JOIN affectation ON sejour.sejour_id = affectation.sejour_id\r\n WHERE \r\n sejour.annule = '0' AND\r\n sejour.group_id = '{$group_id}' AND\r\n sejour.entree_{$type_data} < '{$fin} 23:59:59' AND\r\n sejour.sortie_{$type_data} > '{$debut} 00:00:00' AND\r\n\r\n affectation.affectation_id IS NULL"; if ($prat_id) { $query .= "\nAND sejour.praticien_id = '{$prat_id}'"; } if ($discipline_id) { $query .= "\nAND users_mediboard.discipline_id = '{$discipline_id}'"; } if ($septique) { $query .= "\nAND sejour.septique = '{$septique}'"; } if ($type_adm) { if ($type_adm == 1) { $query .= "\nAND (sejour.type = 'comp' OR sejour.type = 'ambu')"; } else { $query .= "\nAND sejour.type = '{$type_adm}'"; } } $query .= "\nGROUP BY mois ORDER BY orderitem"; $resultNP = $sejour->_spec->ds->loadlist($query); foreach ($ticks as $i => $tick) { $f = true; foreach ($resultNP as $r) { if ($tick[1] == $r["mois"]) { $serie["data"][] = array($i, $r["total"]); $serie_total["data"][$i][1] += $r["total"]; $total += $r["total"]; $f = false; break; } } if ($f) { $serie["data"][] = array(count($serie["data"]), 0); } } $series[] = $serie; } $series[] = $serie_total; $subtitle = "{$total} passages"; if ($prat_id) { $subtitle .= " - Dr {$prat->_view}"; } if ($discipline_id) { $subtitle .= " - {$discipline->_view}"; } if ($type_adm) { $subtitle .= " - " . $listHospis[$type_adm]; } if ($septique) { $subtitle .= " - Septiques"; } $options = array('title' => utf8_encode("Nombre de patients par service - {$type_data}"), 'subtitle' => utf8_encode($subtitle), 'xaxis' => array('labelsAngle' => 45, 'ticks' => $ticks), 'yaxis' => array('min' => 0, 'autoscaleMargin' => 1), 'bars' => array('show' => true, 'stacked' => true, 'barWidth' => 0.8), 'HtmlText' => false, 'legend' => array('show' => true, 'position' => 'nw'), 'grid' => array('verticalLines' => false), 'spreadsheet' => array('show' => true, 'csvFileSeparator' => ';', 'decimalSeparator' => ',', 'tabGraphLabel' => utf8_encode('Graphique'), 'tabDataLabel' => utf8_encode('Données'), 'toolbarDownload' => utf8_encode('Fichier CSV'), 'toolbarSelectAll' => utf8_encode('Sélectionner tout le tableau'))); return array('series' => $series, 'options' => $options); }
* * @package Mediboard * @subpackage Hospi * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision: 21168 $ */ CCanDo::checkRead(); // Récupération des paramètres $service_id = CValue::postOrSession("service_id"); //Chargement de tous les services $service = new CService(); $where = array(); $where["group_id"] = "= '" . CGroups::loadCurrent()->_id . "'"; $where["cancelled"] = "= '0'"; $services = $service->loadGroupList($where, "nom ASC"); $service_selectionne = new CService(); $where["service_id"] = " = '{$service_id}'"; $service_selectionne->loadObject($where); $chambre = new CChambre(); $where = array(); $where["service_id"] = " = '{$service_selectionne->_id}'"; $chambres_service = $chambre->loadGroupList($where); $ljoin = array(); $ljoin["service"] = "service.service_id = chambre.service_id"; $ljoin["emplacement"] = "emplacement.chambre_id = chambre.chambre_id"; $where = array(); $where["annule"] = "= '0'"; $where["emplacement.plan_x"] = "IS NOT NULL"; $where["emplacement.plan_y"] = "IS NOT NULL"; $where["service.service_id"] = " = '{$service_id}'";
/** * Récupération du graphique d'affichage du nombre de nuits passées * par service * * @param string $debut Date de début * @param string $fin Date de fin * @param int $prat_id Identifiant du praticien * @param int $service_id Identifiant du service * @param int $type_adm Type d'admission * @param int $discipline_id Identifiant de la discipline * @param int $septique Filtre sur les séjours septiques * @param string $type_data Type de données (réèlle ou prévue) * * @return array */ function graphJoursParService($debut = null, $fin = null, $prat_id = 0, $service_id = 0, $type_adm = 0, $func_id = 0, $discipline_id = 0, $septique = 0, $type_data = "prevue") { if (!$debut) { $debut = CMbDT::date("-1 YEAR"); } if (!$fin) { $fin = CMbDT::date(); } $prat = new CMediusers(); $prat->load($prat_id); $discipline = new CDiscipline(); $discipline->load($discipline_id); $ticks = array(); $serie_total = array('label' => 'Total', 'data' => array(), 'markers' => array('show' => true), 'bars' => array('show' => false)); for ($i = $debut; $i <= $fin; $i = CMbDT::date("+1 MONTH", $i)) { $ticks[] = array(count($ticks), CMbDT::transform("+0 DAY", $i, "%m/%Y")); $serie_total['data'][] = array(count($serie_total['data']), 0); } $where = array(); if ($service_id) { $where["service_id"] = "= '{$service_id}'"; } $service = new CService(); $services = $service->loadGroupList($where); $sejour = new CSejour(); $listHospis = array(1 => "Hospi complètes + ambu") + $sejour->_specs["type"]->_locales; $total = 0; $series = array(); // Patients placés foreach ($services as $service) { $serie = array('data' => array(), 'label' => utf8_encode($service->nom)); $curr_month = $debut; $result = array(); while ($curr_month <= $fin) { $end_month = CMbDT::date("+1 MONTH", $curr_month); $end_month = CMbDT::date("-1 DAY", $end_month); $query = "SELECT\r\n SUM(DATEDIFF(\r\n LEAST(affectation.sortie, '{$end_month} 23:59:59'),\r\n GREATEST(affectation.entree, '{$curr_month} 00:00:00')\r\n )) AS total,\r\n DATE_FORMAT('{$curr_month}', '%m/%Y') AS mois,\r\n DATE_FORMAT('{$curr_month}', '%Y%m') AS orderitem\r\n FROM affectation\r\n LEFT JOIN sejour ON sejour.sejour_id = affectation.sejour_id\r\n LEFT JOIN lit ON affectation.lit_id = lit.lit_id\r\n LEFT JOIN chambre ON lit.chambre_id = chambre.chambre_id\r\n LEFT JOIN service ON chambre.service_id = service.service_id\r\n LEFT JOIN users_mediboard ON sejour.praticien_id = users_mediboard.user_id\r\n WHERE sejour.annule = '0'\r\n AND affectation.sortie >= '{$curr_month} 00:00:00'\r\n AND affectation.entree <= '{$end_month} 23:59:59'\r\n AND service.service_id = '{$service->_id}'"; if ($prat_id) { $query .= "\nAND sejour.praticien_id = '{$prat_id}'"; } if ($discipline_id) { $query .= "\nAND users_mediboard.discipline_id = '{$discipline_id}'"; } if ($septique) { $query .= "\nAND sejour.septique = '{$septique}'"; } if ($type_adm) { if ($type_adm == 1) { $query .= "\nAND (sejour.type = 'comp' OR sejour.type = 'ambu')"; } else { $query .= "\nAND sejour.type = '{$type_adm}'"; } } $query .= "\nGROUP BY mois ORDER BY orderitem"; $result_month = $sejour->_spec->ds->loadlist($query); foreach ($result_month as $curr_result) { $key = $curr_result["orderitem"] . $service->_id; if (!isset($result[$key])) { $result[$key] = $curr_result; } else { $result[$key]["total"] += $curr_result["total"]; } } $curr_month = CMbDT::date("+1 MONTH", $curr_month); } foreach ($ticks as $i => $tick) { $f = true; foreach ($result as $r) { if ($tick[1] == $r["mois"]) { $serie["data"][] = array($i, $r["total"]); $serie_total["data"][$i][1] += $r["total"]; $total += $r["total"]; $f = false; break; } } if ($f) { $serie["data"][] = array(count($serie["data"]), 0); } } $series[] = $serie; } // Patients non placés if (!$service_id) { $serie = array('data' => array(), 'label' => utf8_encode("Non placés")); $series[] = $serie; } $series[] = $serie_total; $subtitle = "{$total} nuits"; if ($prat_id) { $subtitle .= " - Dr {$prat->_view}"; } if ($discipline_id) { $subtitle .= " - {$discipline->_view}"; } if ($type_adm) { $subtitle .= " - " . $listHospis[$type_adm]; } if ($septique) { $subtitle .= " - Septiques"; } $options = array('title' => utf8_encode("Nombre de nuits par service"), 'subtitle' => utf8_encode($subtitle), 'xaxis' => array('labelsAngle' => 45, 'ticks' => $ticks), 'yaxis' => array('min' => 0, 'autoscaleMargin' => 1), 'bars' => array('show' => true, 'stacked' => true, 'barWidth' => 0.8), 'HtmlText' => false, 'legend' => array('show' => true, 'position' => 'nw'), 'grid' => array('verticalLines' => false), 'spreadsheet' => array('show' => true, 'csvFileSeparator' => ';', 'decimalSeparator' => ',', 'tabGraphLabel' => utf8_encode('Graphique'), 'tabDataLabel' => utf8_encode('Données'), 'toolbarDownload' => utf8_encode('Fichier CSV'), 'toolbarSelectAll' => utf8_encode('Sélectionner tout le tableau'))); return array('series' => $series, 'options' => $options); }