/** * Récupération des statistiques du nombre d'interventions par jour * selon plusieurs filtres * * @param string $date Date de début * @param int $prat_id Identifiant du praticien * @param int $salle_id Identifiant de la sall * @param int $bloc_id Identifiant du bloc * @param int $discipline_id Identifiant de la discipline * @param string $codes_ccam Code CCAM * @param string $type_hospi Type d'hospitalisation * @param bool $hors_plage Prise en compte des hors plage * * @return array */ function graphActiviteZoom($date, $prat_id = 0, $salle_id = 0, $bloc_id = 0, $func_id = 0, $discipline_id = 0, $codes_ccam = '', $type_hospi = "", $hors_plage = true) { if (!$date) { $date = CMbDT::transform("+0 DAY", CMbDT::date(), "%m/%Y"); } $prat = new CMediusers(); $prat->load($prat_id); $salle = new CSalle(); $salle->load($salle_id); $discipline = new CDiscipline(); $discipline->load($discipline_id); // Gestion de la date $debut = substr($date, 3, 7) . "-" . substr($date, 0, 2) . "-01"; $fin = CMbDT::date("+1 MONTH", $debut); $fin = CMbDT::date("-1 DAY", $fin); $step = "+1 DAY"; // Tableaux des jours $ticks = array(); $ticks2 = array(); $serie_total = array('label' => 'Total', 'data' => array(), 'markers' => array('show' => true), 'bars' => array('show' => false)); for ($i = $debut; $i <= $fin; $i = CMbDT::date($step, $i)) { $ticks[] = array(count($ticks), CMbDT::format($i, "%a %d")); $ticks2[] = array(count($ticks), CMbDT::format($i, "%d")); $serie_total['data'][] = array(count($serie_total['data']), 0); } $salles = CSalle::getSallesStats($salle_id, $bloc_id); $series = array(); $total = 0; foreach ($salles as $salle) { $serie = array('data' => array(), 'label' => utf8_encode($salle->nom)); $query = "SELECT COUNT(operations.operation_id) AS total,\r\n DATE_FORMAT(operations.date, '%d') AS jour,\r\n sallesbloc.nom AS nom\r\n FROM operations\r\n INNER JOIN sejour ON operations.sejour_id = sejour.sejour_id\r\n INNER JOIN sallesbloc ON operations.salle_id = sallesbloc.salle_id\r\n INNER JOIN plagesop ON operations.plageop_id = plagesop.plageop_id\r\n INNER JOIN users_mediboard ON operations.chir_id = users_mediboard.user_id\r\n WHERE operations.date BETWEEN '{$debut}' AND '{$fin}'\r\n AND operations.plageop_id IS NOT NULL\r\n AND operations.annulee = '0'\r\n AND sallesbloc.salle_id = '{$salle->_id}'"; if ($prat_id && !$prat->isFromType(array("Anesthésiste"))) { $query .= "\nAND operations.chir_id = '{$prat_id}'"; } if ($prat_id && $prat->isFromType(array("Anesthésiste"))) { $query .= "\nAND (operations.anesth_id = '{$prat_id}' OR \r\n (plagesop.anesth_id = '{$prat_id}' AND (operations.anesth_id = '0' OR operations.anesth_id IS NULL)))"; } if ($discipline_id) { $query .= "\nAND users_mediboard.discipline_id = '{$discipline_id}'"; } if ($codes_ccam) { $query .= "\nAND operations.codes_ccam LIKE '%{$codes_ccam}%'"; } if ($type_hospi) { $query .= "\nAND sejour.type = '{$type_hospi}'"; } $query .= "\nGROUP BY jour ORDER BY jour"; $result = $salle->_spec->ds->loadlist($query); $result_hors_plage = array(); if ($hors_plage) { $query_hors_plage = "SELECT COUNT(operations.operation_id) AS total,\r\n DATE_FORMAT(operations.date, '%d') AS jour,\r\n sallesbloc.nom AS nom\r\n FROM operations\r\n INNER JOIN sejour ON operations.sejour_id = sejour.sejour_id\r\n INNER JOIN sallesbloc ON operations.salle_id = sallesbloc.salle_id\r\n INNER JOIN users_mediboard ON operations.chir_id = users_mediboard.user_id\r\n WHERE operations.date BETWEEN '{$debut}' AND '{$fin}'\r\n AND operations.plageop_id IS NULL\r\n AND operations.annulee = '0'\r\n AND sallesbloc.salle_id = '{$salle->_id}'"; if ($prat_id && !$prat->isFromType(array("Anesthésiste"))) { $query_hors_plage .= "\nAND operations.chir_id = '{$prat_id}'"; } if ($prat_id && $prat->isFromType(array("Anesthésiste"))) { $query_hors_plage .= "\nAND operations.anesth_id = '{$prat_id}'"; } if ($discipline_id) { $query_hors_plage .= "\nAND users_mediboard.discipline_id = '{$discipline_id}'"; } if ($codes_ccam) { $query_hors_plage .= "\nAND operations.codes_ccam LIKE '%{$codes_ccam}%'"; } if ($type_hospi) { $query_hors_plage .= "\nAND sejour.type = '{$type_hospi}'"; } $query_hors_plage .= "\nGROUP BY jour ORDER BY jour"; $result_hors_plage = $salle->_spec->ds->loadlist($query_hors_plage); } foreach ($ticks2 as $i => $tick) { $f = true; foreach ($result as $r) { if ($tick[1] == $r["jour"]) { if ($hors_plage) { foreach ($result_hors_plage as &$_r_h) { if ($tick[1] == $_r_h["jour"]) { $r["total"] += $_r_h["total"]; unset($_r_h); break; } } } $serie["data"][] = array($i, $r["total"]); $serie_total["data"][$i][1] += $r["total"]; $total += $r["total"]; $f = false; } } if ($f) { $serie["data"][] = array(count($serie["data"]), 0); } } $series[] = $serie; } $series[] = $serie_total; // Set up the title for the graph if ($prat_id && $prat->isFromType(array("Anesthésiste"))) { $title = "Nombre d'anesthésie par salle - " . CMbDT::format($debut, "%m/%Y"); $subtitle = "{$total} anesthésies"; } else { $title = "Nombre d'interventions par salle - " . CMbDT::format($debut, "%m/%Y"); $subtitle = "{$total} interventions"; } if ($prat_id) { $subtitle .= " - Dr {$prat->_view}"; } if ($discipline_id) { $subtitle .= " - {$discipline->_view}"; } if ($codes_ccam) { $subtitle .= " - CCAM : {$codes_ccam}"; } if ($type_hospi) { $subtitle .= " - " . CAppUI::tr("CSejour.type.{$type_hospi}"); } $options = CFlotrGraph::merge("bars", array('title' => utf8_encode($title), 'subtitle' => utf8_encode($subtitle), 'xaxis' => array('ticks' => $ticks), 'bars' => array('stacked' => true, 'barWidth' => 0.8))); return array('series' => $series, 'options' => $options); }
<?php /** * Edit discipline * * @category Mediusers * @package Mediboard * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version SVN: $Id:$ * @link http://www.mediboard.org */ CCanDo::checkRead(); $discipline_id = CValue::getOrSession("discipline_id"); // Récupération des groups $groups = CGroups::loadGroups(PERM_EDIT); // Récupération de la fonction selectionnée $discipline = new CDiscipline(); $discipline->load($discipline_id); $discipline->loadGroupRefsBack(); // Création du template $smarty = new CSmartyDP(); $smarty->assign("discipline", $discipline); $smarty->assign("groups", $groups); $smarty->display("inc_edit_discipline.tpl");
} } $mediuser->function_id = $function->_id; // Spécialité CCAM if ($spec_cpam_code = $results[$i]["spec_cpam_code"]) { $spec_cpam = new CSpecCPAM(); $spec_cpam->load(intval($spec_cpam_code)); if ($spec_cpam->_id) { $mediuser->spec_cpam_id = $spec_cpam->_id; } else { $unfound["spec_cpam_code"][$spec_cpam_code] = true; } } // Discipline if ($discipline_name = $results[$i]["discipline_name"]) { $discipline = new CDiscipline(); $discipline->text = strtoupper($discipline_name); $discipline->loadMatchingObject(); if ($discipline->_id) { $mediuser->discipline_id = $discipline->_id; } else { $unfound["discipline_name"][$discipline_name] = true; } } // Dry run to check references if ($dryrun) { continue; } $mediuser->unescapeValues(); $msg = $mediuser->store(); if ($msg) {
/** * Récupération du graphique du nombre de patient par jour et par salle * au bloc opératoire * * @param string $debut Date de début * @param string $fin Date de fin * @param int $prat_id Identifiant du praticien * @param int $salle_id Identifiant de la salle * @param int $bloc_id Identifiant du bloc * @param int $discipline_id Identifiant de la discipline * @param string $codeCCAM Code CCAM * @param bool $hors_plage Prise en compte des hors plage * * @return array */ function graphPatJourSalle($debut = null, $fin = null, $prat_id = 0, $salle_id = 0, $bloc_id = 0, $func_id = 0, $discipline_id = null, $codeCCAM = '', $hors_plage = true) { if (!$debut) { $debut = CMbDT::date("-1 YEAR"); } if (!$fin) { $fin = CMbDT::date(); } $prat = new CMediusers(); $prat->load($prat_id); $salle = new CSalle(); $salle->load($salle_id); $discipline = new CDiscipline(); $discipline->load($discipline_id); $ticks = array(); for ($i = $debut; $i <= $fin; $i = CMbDT::date("+1 MONTH", $i)) { $ticks[] = array(count($ticks), CMbDT::transform("+0 DAY", $i, "%m/%Y")); } // Gestion du hors plage $where_hors_plage = !$hors_plage ? "AND operations.plageop_id IS NOT NULL" : ""; //$salles = CSalle::getSallesStats($salle_id, $bloc_id); $series = array(); $serie = array('data' => array()); $query = "SELECT COUNT(operations.operation_id) AS total,\r\n COUNT(DISTINCT(operations.date)) AS nb_days,\r\n COUNT(DISTINCT(sallesbloc.salle_id)) AS nb_salles,\r\n DATE_FORMAT(operations.date, '%m/%Y') AS mois,\r\n DATE_FORMAT(operations.date, '%Y-%m-01') AS orderitem\r\n FROM operations\r\n LEFT JOIN sejour ON operations.sejour_id = sejour.sejour_id\r\n LEFT JOIN sallesbloc ON operations.salle_id = sallesbloc.salle_id\r\n LEFT JOIN plagesop ON operations.plageop_id = plagesop.plageop_id\r\n LEFT JOIN users_mediboard ON operations.chir_id = users_mediboard.user_id\r\n WHERE operations.annulee = '0'\r\n AND operations.date BETWEEN '{$debut}' AND '{$fin}'\r\n {$where_hors_plage}\r\n AND sejour.group_id = '" . CGroups::loadCurrent()->_id . "'\r\n AND sallesbloc.stats = '1'"; if ($prat_id) { $query .= "\nAND operations.chir_id = '{$prat_id}'"; } if ($discipline_id) { $query .= "\nAND users_mediboard.discipline_id = '{$discipline_id}'"; } if ($codeCCAM) { $query .= "\nAND operations.codes_ccam LIKE '%{$codeCCAM}%'"; } if ($salle_id) { $query .= "\nAND sallesbloc.salle_id = '{$salle_id}'"; } elseif ($bloc_id) { $query .= "\nAND sallesbloc.bloc_id = '{$bloc_id}'"; } $query .= "\nGROUP BY mois ORDER BY orderitem"; $result = $prat->_spec->ds->loadlist($query); foreach ($ticks as $i => $tick) { $f = true; foreach ($result as $r) { if ($tick[1] == $r["mois"]) { $res = $r["total"] / ($r["nb_days"] * $r["nb_salles"]); //$nbjours = CMbDT::workDaysInMonth($r["orderitem"]); //$serie['data'][] = array($i, $r["total"]/($nbjours*count($salles))); $serie['data'][] = array($i, $res); //$serie['data'][] = array($i, $r["total"]/($r["nb_days"]*count($salles))); $f = false; } } if ($f) { $serie["data"][] = array(count($serie["data"]), 0); } } $series[] = $serie; // Set up the title for the graph $title = "Patients / jour / salle active dans le mois"; $subtitle = "Uniquement les jours d'activité"; if ($prat_id) { $subtitle .= " - Dr {$prat->_view}"; } if ($discipline_id) { $subtitle .= " - {$discipline->_view}"; } if ($salle_id) { $subtitle .= " - {$salle->nom}"; } if ($codeCCAM) { $subtitle .= " - CCAM : {$codeCCAM}"; } $options = array('title' => utf8_encode($title), 'subtitle' => utf8_encode($subtitle), 'xaxis' => array('labelsAngle' => 45, 'ticks' => $ticks), 'yaxis' => array('autoscaleMargin' => 1, 'min' => 0), 'lines' => array('show' => true, 'filled' => true, 'fillColor' => '#999'), 'markers' => array('show' => true), 'points' => array('show' => true), 'HtmlText' => false, 'legend' => array('show' => true, 'position' => 'nw'), 'mouse' => array('track' => true, 'relative' => true, 'position' => 'ne'), '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); }
/** * Récuparation du graphique du nombre d'interventions annulées le jour même * * @param string $date_min Date de début * @param string $date_max Date de fin * @param int $prat_id Filtre du praticien * @param int $salle_id Filtre de la salle * @param int $bloc_id Filtre du bloc * @param int $func_id Filtre sur un cabinet * @param int $discipline_id Filtre sur une discipline * @param string $code_ccam Code CCAM * @param string $type_sejour Type de séjour * @param bool $hors_plage Prise en charge des hors plage * * @return array */ function graphWorkflowOperation($date_min = null, $date_max = null, $prat_id = null, $salle_id = null, $bloc_id = null, $func_id = null, $discipline_id = null, $code_ccam = null, $type_sejour = null, $hors_plage = false) { $miner = new COperationWorkflow(); $miner->warnUsage(); if (!$date_min) { $date_min = CMbDT::date("-1 YEAR"); } if (!$date_max) { $date_max = CMbDT::date(); } $date_min = CMbDT::format($date_min, "%Y-%m-01"); $date_max = CMbDT::transform("+1 MONTH", $date_max, "%Y-%m-01"); // Series declarations $labels = array("op_count" => utf8_encode("Nombre d'interventions"), "creation" => utf8_encode("Planification intervention"), "consult_chir" => utf8_encode("Consultation chirurgicale"), "consult_anesth" => utf8_encode("Consultation anesthésiste"), "visite_anesth" => utf8_encode("Visite anesthésiste"), "creation_consult_chir" => utf8_encode("RDV de consultation chirurgicale"), "creation_consult_anesth" => utf8_encode("RDV de consultation anesthésiste")); $salles = CSalle::getSallesStats($salle_id, $bloc_id); $query = new CRequest(); $query->addColumn("DATE_FORMAT(date_operation, '%Y-%m')", "mois"); $query->addColumn("COUNT(operations.operation_id)", "op_count"); // Prévention des données négatives aberrantes $tolerance_in_days = 0; $columns = array("creation", "consult_chir", "consult_anesth", "visite_anesth", "creation_consult_chir", "creation_consult_anesth"); foreach ($columns as $_column) { $field = "date_{$_column}"; $diff = "DATEDIFF(ow.date_operation, ow.{$field})"; $query->addColumn("AVG (IF({$diff} > {$tolerance_in_days}, {$diff}, NULL))", $_column); $query->addColumn("COUNT(IF({$diff} > {$tolerance_in_days}, {$diff}, NULL))", "count_{$_column}"); } $query->addTable("operations"); $query->addLJoin("operation_workflow AS ow ON ow.operation_id = operations.operation_id"); $query->addWhereClause("date_operation", "BETWEEN '{$date_min}' AND '{$date_max}'"); $query->addWhereClause("salle_id", CSQLDataSource::prepareIn(array_keys($salles))); $query->addGroup("mois"); $query->addOrder("mois"); $subtitle = ""; // Filtre sur hors plage if (!$hors_plage) { $query->addWhereClause("plageop_id", "IS NOT NULL"); $subtitle .= " - sans hors plage"; } // Filtre sur le salle (pas besoin de clause supplémentaire) if ($salle_id) { $salle = reset($salles); $subtitle .= " - {$salle->_view}"; } // Filtre sur le praticien if ($prat_id) { $query->addWhereClause("operations.chir_id", "= '{$prat_id}'"); $prat = new CMediusers(); $prat->load($prat_id); $subtitle .= " - Dr {$prat->_view}"; } // Filtre sur le cabinet if ($func_id) { $query->addLJoinClause("users_mediboard", "operations.chir_id = users_mediboard.user_id"); $query->addWhereClause("users_mediboard.function_id", "= '{$func_id}'"); $func = new CFunctions(); $func->load($func_id); $subtitle .= " - {$func->_view}"; } // Filtre sur la discipline if ($discipline_id) { $discipline = new CDiscipline(); $discipline->load($discipline_id); $query->addLJoinClause("users_mediboard", "operations.chir_id = users_mediboard.user_id"); $query->addWhereClause("users_mediboard.discipline_id", "= '{$discipline_id}'"); $subtitle .= " - {$discipline->_view}"; } // Filtre sur les codes CCAM if ($code_ccam) { $query->addWhereClause("operations.codes_ccam", "LIKE '%{$code_ccam}%'"); $subtitle .= " - CCAM: {$code_ccam}"; } // Filtre sur le type d'hospitalisation if ($type_sejour) { $query->addLJoinClause("sejour", "sejour.sejour_id = operations.sejour_id"); $query->addWhereClause("sejour.type", "= '{$type_sejour}'"); $subtitle .= " - " . CAppUI::tr("CSejour.type.{$type_sejour}"); } // Query result $ds = CSQLDataSource::get("std"); $all_values = $ds->loadHashAssoc($query->makeSelect()); // Build horizontal ticks $months = array(); $ticks = array(); for ($_date = $date_min; $_date < $date_max; $_date = CMbDT::date("+1 MONTH", $_date)) { $count_ticks = count($ticks); $ticks[] = array($count_ticks, CMbDT::format($_date, "%m/%Y")); $months[CMbDT::format($_date, "%Y-%m")] = $count_ticks; } // Series building $series = array(); foreach ($labels as $_label_name => $_label_title) { $series[$_label_name] = array("label" => $_label_title, "data" => array(), "yaxis" => 2); } $series["op_count"]["markers"]["show"] = true; $series["op_count"]["yaxis"] = 1; $series["op_count"]["lines"]["show"] = false; $series["op_count"]["points"]["show"] = false; $series["op_count"]["bars"]["show"] = true; $series["op_count"]["bars"]["fillColor"] = "#ccc"; $series["op_count"]["color"] = "#888"; $total = 0; $counts = array(); foreach ($months as $_month => $_tick) { $values = isset($all_values[$_month]) ? $all_values[$_month] : array_fill_keys(array_keys($labels), null); unset($values["mois"]); $_counts = array(); foreach ($values as $_name => $_value) { $parts = explode("_", $_name, 2); if ($parts[0] == "count") { $_counts[$labels[$parts[1]]] = $_value; continue; } $series[$_name]["data"][] = array($_tick, $_value); } $total += $values["op_count"]; $counts[] = $_counts; } // Set up the title for the graph $title = "Anticipation de la programmation des interventions"; $subtitle = "{$total} interventions" . $subtitle; $options = array('title' => utf8_encode($title), 'subtitle' => utf8_encode($subtitle), 'xaxis' => array('labelsAngle' => 45, 'ticks' => $ticks), 'yaxis' => array('autoscaleMargin' => 1, "title" => utf8_encode("Quantité d'interventions"), "titleAngle" => 90), 'y2axis' => array('autoscaleMargin' => 1, "title" => utf8_encode("Anticipation moyenne en jours vs la date d'intervention"), "titleAngle" => 90), "points" => array("show" => true, "radius" => 2, "lineWidth" => 1), "lines" => array("show" => true, "lineWidth" => 1), 'bars' => array('show' => false, 'stacked' => false, 'barWidth' => 0.8), 'HtmlText' => false, 'legend' => array('show' => true, 'position' => 'nw'), 'grid' => array('verticalLines' => false), 'mouse' => array("track" => true, "position" => "ne", "relative" => true, "sensibility" => 2, "trackDecimals" => 3, "trackFormatter" => utf8_encode("(\r\n function(obj) {\r\n var label = obj.series.label;\r\n var total = obj.nearest.allSeries[0].data[obj.index][1];\r\n var date = graph.options.xaxis.ticks[obj.index][1];\r\n\r\n // Barre des nombres d'interventions\r\n if (obj.series.bars.show) {\r\n var format = '%s <br />%s en %s';\r\n return printf(format, label, total, date);\r\n }\r\n\r\n // Courbes d'anticipation\r\n var count = graph.options.counts[obj.index][label];\r\n var value = obj.series.data[obj.index][1];\r\n var percent = Math.round(100*count/total) + '%';\r\n var format = '%s <br />%d jours en %s<br />%s des interventions concernées (%s/%s)';\r\n return printf(format, label, value, date, percent, count, total);\r\n }\r\n )")), 'counts' => $counts, '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' => array_values($series), 'options' => $options); }
/** * Récupération des statistiques du nombre d'interventions par mois * selon plusieurs filtres * * @param string $debut Date de début * @param string $fin Date de fin * @param int $prat_id Identifiant du praticien * @param int $salle_id Identifiant de la sall * @param int $bloc_id Identifiant du bloc * @param int $discipline_id Identifiant de la discipline * @param string $codes_ccam Code CCAM * @param string $type_hospi Type d'hospitalisation * @param bool $hors_plage Prise en compte des hors plage * * @return array */ function graphActivite($debut = null, $fin = null, $prat_id = 0, $salle_id = 0, $bloc_id = 0, $func_id = 0, $discipline_id = 0, $codes_ccam = "", $type_hospi = "", $hors_plage = true) { 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); $salle = new CSalle(); $salle->load($salle_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); } $salles = CSalle::getSallesStats($salle_id, $bloc_id); $ds = $salle->_spec->ds; // Gestion du hors plage $where_hors_plage = !$hors_plage ? "AND operations.plageop_id IS NOT NULL" : ""; $total = 0; $series = array(); foreach ($salles as $salle) { $serie = array('label' => utf8_encode($bloc_id ? $salle->nom : $salle->_view), 'data' => array()); $query = "SELECT COUNT(operations.operation_id) AS total,\r\n DATE_FORMAT(operations.date, '%m/%Y') AS mois,\r\n DATE_FORMAT(operations.date, '%Y%m') AS orderitem,\r\n sallesbloc.nom AS nom\r\n FROM operations\r\n LEFT JOIN sejour ON operations.sejour_id = sejour.sejour_id\r\n LEFT JOIN sallesbloc ON operations.salle_id = sallesbloc.salle_id\r\n LEFT JOIN plagesop ON operations.plageop_id = plagesop.plageop_id\r\n LEFT JOIN users_mediboard ON operations.chir_id = users_mediboard.user_id\r\n WHERE operations.annulee = '0'\r\n AND operations.date BETWEEN '{$debut}' AND '{$fin}'\r\n {$where_hors_plage}\r\n AND sejour.group_id = '" . CGroups::loadCurrent()->_id . "'"; if ($type_hospi) { $query .= "\nAND sejour.type = '{$type_hospi}'"; } if ($prat_id && !$prat->isFromType(array("Anesthésiste"))) { $query .= "\nAND operations.chir_id = '{$prat_id}'"; } if ($prat_id && $prat->isFromType(array("Anesthésiste"))) { $query .= "\nAND (operations.anesth_id = '{$prat_id}' OR\r\n (plagesop.anesth_id = '{$prat_id}' AND (operations.anesth_id = '0' OR operations.anesth_id IS NULL)))"; } if ($discipline_id) { $query .= "\nAND users_mediboard.discipline_id = '{$discipline_id}'"; } if ($codes_ccam) { $query .= "\nAND operations.codes_ccam LIKE '%{$codes_ccam}%'"; } $query .= "\nAND sallesbloc.salle_id = '{$salle->_id}'"; $query .= "\nGROUP BY mois ORDER BY orderitem"; $result = $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; } $series[] = $serie_total; // Set up the title for the graph if ($prat_id && $prat->isFromType(array("Anesthésiste"))) { $title = "Nombre d'anesthésie par salle"; $subtitle = "{$total} anesthésies"; } else { $title = "Nombre d'interventions par salle"; $subtitle = "{$total} interventions"; } if ($prat_id) { $subtitle .= " - Dr {$prat->_view}"; } if ($discipline_id) { $subtitle .= " - {$discipline->_view}"; } if ($codes_ccam) { $subtitle .= " - CCAM : {$codes_ccam}"; } if ($type_hospi) { $subtitle .= " - " . CAppUI::tr("CSejour.type.{$type_hospi}"); } $options = array('title' => utf8_encode($title), 'subtitle' => utf8_encode($subtitle), 'xaxis' => array('labelsAngle' => 45, 'ticks' => $ticks), 'yaxis' => array('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); }
/** * View disciplines * * @category Mediusers * @package Mediboard * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version SVN: $Id: vw_idx_functions.php 19463 2013-06-07 10:36:29Z lryo $ * @link http://www.mediboard.org */ CCanDo::checkRead(); $page = intval(CValue::get('page', 0)); $filter = CValue::getOrSession("filter", ""); $step = 25; $order = "text ASC"; $discipline = new CDiscipline(); if ($filter) { $disciplines = $discipline->seek($filter, null, "{$page}, {$step}", true, null, $order); $total_disciplines = $discipline->_totalSeek; } else { $disciplines = $discipline->loadList(null, $order, "{$page}, {$step}"); $total_disciplines = $discipline->countList(); } foreach ($disciplines as $_discipline) { $_discipline->loadGroupRefsBack(); } $function_id = CValue::getOrSession("function_id"); // Création du template $smarty = new CSmartyDP(); $smarty->assign("discipline", $discipline); $smarty->assign("disciplines", $disciplines);
/** * Récupération de la discipline médico-tarifaire * * @param DOMNode $node PV1 Node * @param CSejour $newVenue Admit * * @return void */ function getHospitalService(DOMNode $node, CSejour $newVenue) { $sender = $this->_ref_sender; $PV1_10 = $this->queryTextNode("PV1.10", $node); if (!$PV1_10) { return null; } // Hospital Service switch ($sender->_configs["handle_PV1_10"]) { // idex du service case 'service': $newVenue->service_id = CIdSante400::getMatch("CService", $sender->_tag_service, $PV1_10)->object_id; break; // finess // finess case 'finess': return null; // Discipline médico-tarifaire // Discipline médico-tarifaire default: $discipline = new CDiscipline(); $discipline->load($PV1_10); $newVenue->discipline_id = $discipline->_id; break; } }
/** * Check room * * @return void */ function checkChambre() { static $pathos = null; if (!$pathos) { $pathos = new CDiscipline(); } assert($this->_ref_lits !== null); $this->_nb_lits_dispo = count($this->_ref_lits); /** @var CAffectation[] $listAff */ $listAff = array(); $this->_chambre_seule = 0; $this->_chambre_double = 0; $this->_conflits_pathologies = 0; $this->_ecart_age = 0; $this->_genres_melanges = false; $this->_conflits_chirurgiens = 0; foreach ($this->_ref_lits as $lit) { assert($lit->_ref_affectations !== null); // overbooking $lit->checkOverBooking(); $this->_overbooking += $lit->_overbooking; // Lits dispo if (count($lit->_ref_affectations)) { $this->_nb_lits_dispo--; } // Liste des affectations foreach ($lit->_ref_affectations as $aff) { $listAff[] = $aff; } } $this->_nb_affectations = count($listAff); $systeme_presta = CAppUI::conf("dPhospi prestations systeme_prestations", CGroups::loadCurrent()); foreach ($listAff as $affectation1) { if (!$affectation1->sejour_id) { continue; } $sejour1 = $affectation1->_ref_sejour; $patient1 = $sejour1->_ref_patient; $chirurgien1 = $sejour1->_ref_praticien; if ($systeme_presta == "standard") { if (count($this->_ref_lits) == 1 && $sejour1->chambre_seule == 0) { $this->_chambre_double++; } if (count($this->_ref_lits) > 1 && $sejour1->chambre_seule == 1) { $this->_chambre_seule++; } } foreach ($listAff as $affectation2) { if (!$affectation2->sejour_id) { continue; } if ($affectation1->_id == $affectation2->_id) { continue; } if ($affectation1->lit_id == $affectation2->lit_id) { continue; } if (!$affectation1->collide($affectation2)) { continue; } $sejour2 = $affectation2->_ref_sejour; $patient2 = $sejour2->_ref_patient; $chirurgien2 = $sejour2->_ref_praticien; // Conflits de pathologies if (!$pathos->isCompat($sejour1->pathologie, $sejour2->pathologie, $sejour1->septique, $sejour2->septique)) { $this->_conflits_pathologies++; } // Ecart d'âge $ecart = max($patient1->_annees, $patient2->_annees) - min($patient1->_annees, $patient2->_annees); $this->_ecart_age = max($ecart, $this->_ecart_age); // Genres mélangés if ($patient1->sexe != $patient2->sexe && ($patient1->sexe == "m" || $patient2->sexe == "m")) { $this->_genres_melanges = true; } // Conflit de chirurgiens if ($chirurgien1->user_id != $chirurgien2->user_id && $chirurgien1->function_id == $chirurgien2->function_id) { $this->_conflits_chirurgiens++; } } } $this->_conflits_pathologies /= 2; $this->_conflits_chirurgiens /= 2; }
/** * Récuparation du graphique de répartition des patients en salle de reveil * par tranche horaire * * @param string $debut Date de début * @param string $fin Date de fin * @param int $prat_id Identifiant du praticien * @param int $bloc_id Identifiant du bloc * @param int $discipline_id Identifiant de la discipline * @param string $codeCCAM Code CCAM * * @return array */ function graphPatParHeureReveil($debut = null, $fin = null, $prat_id = 0, $bloc_id = 0, $func_id = 0, $discipline_id = null, $codeCCAM = '') { // This stats uses temporary table, impossible on slave // @todo Get rid of temporary table CView::disableSlave(); $ds = CSQLDataSource::get("std"); if (!$debut) { $debut = CMbDT::date("-1 YEAR"); } if (!$fin) { $fin = CMbDT::date(); } $totalWorkDays = 0; for ($i = $debut; $i <= $fin; $i = CMbDT::date("+1 MONTH", $i)) { $totalWorkDays += CMbDT::workDaysInMonth(CMbDT::transform("+0 DAY", $i, "%Y-%m-01")); } $prat = new CMediusers(); $prat->load($prat_id); $discipline = new CDiscipline(); $discipline->load($discipline_id); $ticks = array(); for ($i = 7; $i <= 21; $i++) { $ticks[] = array(count($ticks), CMbDT::transform("+0 DAY", "{$i}:00:00", "%Hh%M")); } $bloc = new CBlocOperatoire(); if ($bloc_id) { $bloc->load($bloc_id); } $series = array(); // Nombre de patients par heure foreach ($ticks as $i => $tick) { $query = "DROP TEMPORARY TABLE IF EXISTS pat_par_heure"; $ds->exec($query); $query = "CREATE TEMPORARY TABLE pat_par_heure\n SELECT COUNT(operations.operation_id) AS total_by_day,\n '" . $tick[1] . "' AS heure,\n operations.date AS date\n FROM operations\n INNER JOIN sallesbloc ON operations.salle_id = sallesbloc.salle_id\n LEFT JOIN users_mediboard ON operations.chir_id = users_mediboard.user_id\n WHERE sallesbloc.stats = '1'\n AND operations.date BETWEEN '{$debut}' AND '{$fin}'\n AND '" . $tick[1] . ":00' BETWEEN operations.entree_reveil AND operations.sortie_reveil_reel\n AND operations.annulee = '0'"; if ($prat_id) { $query .= "\nAND operations.chir_id = '{$prat_id}'"; } if ($discipline_id) { $query .= "\nAND users_mediboard.discipline_id = '{$discipline_id}'"; } if ($codeCCAM) { $query .= "\nAND operations.codes_ccam LIKE '%{$codeCCAM}%'"; } if ($bloc_id) { $query .= "\nAND sallesbloc.bloc_id = '{$bloc_id}'"; } $query .= "\nGROUP BY operations.date"; $ds->exec($query); $query = "SELECT SUM(total_by_day) AS total, MAX(total_by_day) AS max,heure\n FROM pat_par_heure\n GROUP BY heure"; $result = $ds->loadlist($query); if (count($result)) { $serie_moyenne["data"][] = array($i, $result[0]["total"] / $totalWorkDays); $serie_max["data"][] = array($i, $result[0]["max"]); } else { $serie_moyenne["data"][] = array($i, 0); $serie_max["data"][] = array($i, 0); } } // Nombre de patients non renseignés $query = "SELECT COUNT(operations.operation_id) AS total,\n 'err' AS heure\n FROM operations\n INNER JOIN sallesbloc ON operations.salle_id = sallesbloc.salle_id\n LEFT JOIN users_mediboard ON operations.chir_id = users_mediboard.user_id\n WHERE sallesbloc.stats = '1'\n AND operations.date BETWEEN '{$debut}' AND '{$fin}'\n AND (operations.entree_reveil IS NULL OR operations.sortie_reveil_reel IS NULL)\n AND operations.annulee = '0'"; if ($prat_id) { $query .= "\nAND operations.chir_id = '{$prat_id}'"; } if ($discipline_id) { $query .= "\nAND users_mediboard.discipline_id = '{$discipline_id}'"; } if ($codeCCAM) { $query .= "\nAND operations.codes_ccam LIKE '%{$codeCCAM}%'"; } if ($bloc_id) { $query .= "\nAND sallesbloc.bloc_id = '{$bloc_id}'"; } $query .= "\nGROUP BY heure"; $result = $ds->loadlist($query); if (count($result)) { $serie_moyenne["data"][] = array(count($ticks), $result[0]["total"] / $totalWorkDays); } else { $serie_moyenne["data"][] = array(count($ticks), 0); } //$serie_max["data"][] = array(count($ticks), 0); $ticks[] = array(count($ticks), "Erreurs"); $serie_moyenne["label"] = "moyenne"; $serie_max["label"] = "max"; $series[] = $serie_moyenne; $series[] = $serie_max; // Set up the title for the graph $title = "Patients moyens et max / heure du jour"; $subtitle = "Moyenne sur tous les jours ouvrables"; if ($prat_id) { $subtitle .= " - Dr {$prat->_view}"; } if ($discipline_id) { $subtitle .= " - {$discipline->_view}"; } if ($bloc_id) { $subtitle .= " - {$bloc->_view}"; } if ($codeCCAM) { $subtitle .= " - CCAM : {$codeCCAM}"; } $options = array('title' => utf8_encode($title), 'subtitle' => utf8_encode($subtitle), 'xaxis' => array('labelsAngle' => 45, 'ticks' => $ticks), 'yaxis' => array('autoscaleMargin' => 1, 'min' => 0), 'lines' => array('show' => true, 'filled' => true, 'fillColor' => '#999'), 'markers' => array('show' => true), 'points' => array('show' => true), 'HtmlText' => false, 'legend' => array('show' => true, 'position' => 'nw'), 'mouse' => array('track' => true, 'relative' => true, 'position' => 'ne'), '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); }
/** * Récupération du graphique de l'occupation de salle de bloc * * @param string $debut Date de début * @param string $fin Date de fin * @param int $prat_id Identifiant du praticien * @param int $salle_id Identifiant de la salle * @param int $bloc_id Identifiant du bloc * @param int $discipline_id Identifiant de la discipline * @param string $codeCCAM Code CCAM * @param string $type_hospi Type d'hospitalisation * @param bool $hors_plage Pris en compte du hors plage * @param string $type_duree Type de durée (jours / mois) * * @return array */ function graphOccupationSalle($debut = null, $fin = null, $prat_id = 0, $salle_id = 0, $bloc_id = 0, $func_id = 0, $discipline_id = null, $codeCCAM = "", $type_hospi = "", $hors_plage = true, $type_duree = "MONTH") { $ds = CSQLDataSource::get("std"); if ($type_duree == "MONTH") { $type_duree_fr = "mois"; $date_format = "%m/%Y"; $order_key = "%Y%m"; } else { $type_duree_fr = "jour"; $date_format = "%d/%m/%Y"; $order_key = "%Y%m%d"; } if (!$debut) { $debut = CMbDT::date("-1 YEAR"); } if (!$fin) { $fin = CMbDT::date(); } $prat = new CMediusers(); $prat->load($prat_id); $salle = new CSalle(); $salle->load($salle_id); $bloc = new CBlocOperatoire(); $bloc->load($bloc_id); $discipline = new CDiscipline(); $discipline->load($discipline_id); $ticks = array(); for ($i = $debut; $i <= $fin; $i = CMbDT::date("+1 {$type_duree}", $i)) { $ticks[] = array(count($ticks), CMbDT::transform("+0 DAY", $i, $date_format)); } $salles = CSalle::getSallesStats($salle_id, $bloc_id); $user = new CMediusers(); // Chargement des praticiens $where = array(); $where["users_mediboard.actif"] = "= '1'"; if ($discipline->_id) { $where["users_mediboard.discipline_id"] = "= '{$discipline->_id}'"; } // Filter on user type $utypes_flip = array_flip(CUser::$types); $user_types = array("Chirurgien", "Anesthésiste", "Médecin", "Dentiste"); foreach ($user_types as &$_type) { $_type = $utypes_flip[$_type]; } $where["users.user_type"] = CSQLDataSource::prepareIn($user_types); $ljoin = array("users" => "users.user_id = users_mediboard.user_id"); $order = "users_mediboard.function_id, users_mediboard.discipline_id, users.user_last_name, users.user_first_name"; $listPrats = $user->loadList($where, $order, null, null, $ljoin); $seriesMoy = array(); $seriesTot = array(); $totalMoy = 0; $totalTot = 0; // Gestion du hors plage $where_hors_plage = !$hors_plage ? "AND operations.plageop_id IS NOT NULL" : ""; // First serie : Interv $serieMoy = $serieTot = array('data' => array(), 'label' => utf8_encode("Intervention")); $query = "SELECT COUNT(*) AS nbInterv,\r\n SUM(TIME_TO_SEC(operations.fin_op)-TIME_TO_SEC(operations.debut_op)) AS duree_total,\r\n DATE_FORMAT(operations.date, '{$date_format}') AS {$type_duree_fr},\r\n DATE_FORMAT(operations.date, '{$order_key}') AS orderitem\r\n FROM operations\r\n LEFT JOIN sejour ON operations.sejour_id = sejour.sejour_id\r\n LEFT JOIN plagesop ON operations.plageop_id = plagesop.plageop_id\r\n LEFT JOIN users_mediboard ON operations.chir_id = users_mediboard.user_id\r\n LEFT JOIN users ON operations.chir_id = users.user_id\r\n WHERE operations.annulee = '0'\r\n AND operations.date BETWEEN '{$debut}' AND '{$fin}'\r\n {$where_hors_plage}\r\n AND operations.debut_op IS NOT NULL\r\n AND operations.fin_op IS NOT NULL\r\n AND operations.debut_op < operations.fin_op\r\n AND sejour.group_id = '" . CGroups::loadCurrent()->_id . "'\r\n AND operations.salle_id " . CSQLDataSource::prepareIn(array_keys($salles)) . "\r\n AND users.user_id " . CSQLDataSource::prepareIn(array_keys($listPrats), $prat_id); if ($type_hospi) { $query .= "\nAND sejour.type = '{$type_hospi}'"; } if ($discipline_id) { $query .= "\nAND users_mediboard.discipline_id = '{$discipline_id}'"; } if ($codeCCAM) { $query .= "\nAND operations.codes_ccam LIKE '%{$codeCCAM}%'"; } $query .= "\nGROUP BY {$type_duree_fr} ORDER BY orderitem"; $result = $ds->loadList($query); foreach ($ticks as $i => $tick) { $f = true; foreach ($result as $j => $r) { if ($tick[1] == $r["{$type_duree_fr}"]) { $nb_interv = $r["nbInterv"]; $serieMoy['data'][] = array($i, $r["duree_total"] / (60 * $nb_interv)); $totalMoy += $r["duree_total"] / (60 * $nb_interv); $serieTot['data'][] = array($i, $r["duree_total"] / (60 * 60)); $totalTot += $r["duree_total"] / (60 * 60); $f = false; } } if ($f) { $serieMoy["data"][] = array(count($serieMoy["data"]), 0); $serieTot["data"][] = array(count($serieTot["data"]), 0); } } $seriesMoy[] = $serieMoy; $seriesTot[] = $serieTot; // Second serie : Occupation $serieMoy = $serieTot = array('data' => array(), 'label' => utf8_encode("Occupation de salle")); $query = "SELECT COUNT(*) AS nbInterv,\r\n SUM(TIME_TO_SEC(operations.sortie_salle)-TIME_TO_SEC(operations.entree_salle)) AS duree_total,\r\n DATE_FORMAT(operations.date, '{$date_format}') AS {$type_duree_fr},\r\n DATE_FORMAT(operations.date, '{$order_key}') AS orderitem\r\n FROM operations\r\n LEFT JOIN sejour ON operations.sejour_id = sejour.sejour_id\r\n LEFT JOIN plagesop ON operations.plageop_id = plagesop.plageop_id\r\n LEFT JOIN users_mediboard ON operations.chir_id = users_mediboard.user_id\r\n LEFT JOIN users ON operations.chir_id = users.user_id\r\n WHERE operations.annulee = '0'\r\n AND operations.date BETWEEN '{$debut}' AND '{$fin}'\r\n {$where_hors_plage}\r\n AND operations.entree_salle IS NOT NULL\r\n AND operations.sortie_salle IS NOT NULL\r\n AND operations.entree_salle < operations.sortie_salle\r\n AND sejour.group_id = '" . CGroups::loadCurrent()->_id . "'\r\n AND operations.salle_id " . CSQLDataSource::prepareIn(array_keys($salles)) . "\r\n AND users.user_id " . CSQLDataSource::prepareIn(array_keys($listPrats), $prat_id); if ($type_hospi) { $query .= "\nAND sejour.type = '{$type_hospi}'"; } if ($discipline_id) { $query .= "\nAND users_mediboard.discipline_id = '{$discipline_id}'"; } if ($codeCCAM) { $query .= "\nAND operations.codes_ccam LIKE '%{$codeCCAM}%'"; } $query .= "\nGROUP BY {$type_duree_fr} ORDER BY orderitem"; $result = $ds->loadList($query); foreach ($ticks as $i => $tick) { $f = true; foreach ($result as $j => $r) { if ($tick[1] == $r["{$type_duree_fr}"]) { $nb_interv = $r["nbInterv"]; $serieMoy['data'][] = array($i, $r["duree_total"] / (60 * $nb_interv)); $totalMoy += $r["duree_total"] / (60 * $nb_interv); $serieTot['data'][] = array($i, $r["duree_total"] / (60 * 60)); $totalTot += $r["duree_total"] / (60 * 60); $f = false; } } if ($f) { $serieMoy["data"][] = array(count($serieMoy["data"]), 0); $serieTot["data"][] = array(count($serieTot["data"]), 0); } } $seriesMoy[] = $serieMoy; $seriesTot[] = $serieTot; // Third serie : SSPI $serieMoy = $serieTot = array('data' => array(), 'label' => utf8_encode("Salle de reveil")); $query = "SELECT COUNT(*) AS nbInterv,\r\n SUM(TIME_TO_SEC(operations.sortie_reveil_possible)-TIME_TO_SEC(operations.entree_reveil)) AS duree_total,\r\n DATE_FORMAT(operations.date, '{$date_format}') AS {$type_duree_fr},\r\n DATE_FORMAT(operations.date, '{$order_key}') AS orderitem\r\n FROM operations\r\n LEFT JOIN sejour ON operations.sejour_id = sejour.sejour_id\r\n LEFT JOIN plagesop ON operations.plageop_id = plagesop.plageop_id\r\n LEFT JOIN users_mediboard ON operations.chir_id = users_mediboard.user_id\r\n LEFT JOIN users ON operations.chir_id = users.user_id\r\n WHERE operations.annulee = '0'\r\n AND operations.date BETWEEN '{$debut}' AND '{$fin}'\r\n {$where_hors_plage}\r\n AND operations.entree_reveil IS NOT NULL\r\n AND operations.sortie_reveil_possible IS NOT NULL\r\n AND operations.entree_reveil < operations.sortie_reveil_possible\r\n AND sejour.group_id = '" . CGroups::loadCurrent()->_id . "'\r\n AND operations.salle_id " . CSQLDataSource::prepareIn(array_keys($salles)) . "\r\n AND users.user_id " . CSQLDataSource::prepareIn(array_keys($listPrats), $prat_id); if ($type_hospi) { $query .= "\nAND sejour.type = '{$type_hospi}'"; } if ($discipline_id) { $query .= "\nAND users_mediboard.discipline_id = '{$discipline_id}'"; } if ($codeCCAM) { $query .= "\nAND operations.codes_ccam LIKE '%{$codeCCAM}%'"; } $query .= "\nGROUP BY {$type_duree_fr} ORDER BY orderitem"; $result = $ds->loadList($query); foreach ($ticks as $i => $tick) { $f = true; foreach ($result as $j => $r) { if ($tick[1] == $r[$type_duree_fr]) { $nb_interv = $r["nbInterv"]; $serieMoy['data'][] = array($i, $r["duree_total"] / (60 * $nb_interv)); $totalMoy += $r["duree_total"] / (60 * $nb_interv); $serieTot['data'][] = array($i, $r["duree_total"] / (60 * 60)); $totalTot += $r["duree_total"] / (60 * 60); $f = false; } } if ($f) { $serieMoy["data"][] = array(count($serieMoy["data"]), 0); $serieTot["data"][] = array(count($serieTot["data"]), 0); } } $seriesMoy[] = $serieMoy; $seriesTot[] = $serieTot; // Set up the title for the graph $subtitle = ""; if ($prat_id) { $subtitle .= " - Dr {$prat->_view}"; } if ($discipline_id) { $subtitle .= " - {$discipline->_view}"; } if ($salle_id) { $subtitle .= " - {$salle->nom}"; } if ($bloc_id) { $subtitle .= " - {$bloc->nom}"; } if ($codeCCAM) { $subtitle .= " - CCAM : {$codeCCAM}"; } if ($type_hospi) { $subtitle .= " - " . CAppUI::tr("CSejour.type.{$type_hospi}"); } $optionsMoy = CFlotrGraph::merge("lines", array('title' => utf8_encode("Durées moyennes d'occupation du bloc (en minutes)"), 'subtitle' => utf8_encode("par intervention {$subtitle}"), 'xaxis' => array('ticks' => $ticks), 'grid' => array('verticalLines' => true))); if ($totalMoy == 0) { $optionsMoy['yaxis']['max'] = 1; } $optionsTot = CFlotrGraph::merge("lines", array('title' => utf8_encode("Durées totales d'occupation du bloc (en heures)"), 'subtitle' => utf8_encode("total estimé {$subtitle}"), 'xaxis' => array('ticks' => $ticks), 'grid' => array('verticalLines' => true))); if ($totalTot == 0) { $optionsTot['yaxis']['max'] = 1; } if ($type_duree == "MONTH") { return array("moyenne" => array('series' => $seriesMoy, 'options' => $optionsMoy), "total" => array('series' => $seriesTot, 'options' => $optionsTot)); } else { return array('series' => $seriesTot, 'options' => $optionsTot); } }
/** * Récupération du graphique d'occupation des ressources au bloc opératoire * (personnel, vacations attribuées, ouverture de salle) * * @param string $debut Date de début * @param string $fin Date de fin * @param int $prat_id Identifiant du praticien * @param int $salle_id Identifiant de la salle * @param int $bloc_id Identifiant du bloc * @param null $discipline_id Identifiant de la discipline * @param string $codeCCAM Code CCAM * @param string $type_hospi Type d'hospitalisation * @param bool $hors_plage Pris en compte des hors plage * @param string $type_duree Type de durée analysée (jours / mois) * * @return array */ function graphTempsSalle($debut = null, $fin = null, $prat_id = 0, $salle_id = 0, $bloc_id = 0, $func_id = 0, $discipline_id = null, $codeCCAM = "", $type_hospi = "", $hors_plage = true, $type_duree = "MONTH") { $ds = CSQLDataSource::get("std"); if ($type_duree == "MONTH") { $type_duree_fr = "mois"; $date_format = "%m/%Y"; $order_key = "%Y%m"; } else { $type_duree_fr = "jour"; $date_format = "%d/%m/%Y"; $order_key = "%Y%m%d"; } if (!$debut) { $debut = CMbDT::date("-1 YEAR"); } if (!$fin) { $fin = CMbDT::date(); } $prat = new CMediusers(); $prat->load($prat_id); $salle = new CSalle(); $salle->load($salle_id); $bloc = new CBlocOperatoire(); $bloc->load($bloc_id); $discipline = new CDiscipline(); $discipline->load($discipline_id); $ticks = array(); for ($i = $debut; $i <= $fin; $i = CMbDT::date("+1 {$type_duree}", $i)) { $ticks[] = array(count($ticks), CMbDT::transform("+0 DAY", $i, $date_format)); } $salles = CSalle::getSallesStats($salle_id, $bloc_id); $seriesTot = array(); $totalTot = 0; // First serie : occupation du personnel $serieTot = array('data' => array(), 'label' => utf8_encode("Occupation du personnel")); $query = "SELECT SUM(TIME_TO_SEC(affectation_personnel.fin) - TIME_TO_SEC(affectation_personnel.debut)) as total,\n DATE_FORMAT(plagesop.date, '{$date_format}') AS {$type_duree_fr},\n DATE_FORMAT(plagesop.date, '{$order_key}') AS orderitem\n FROM plagesop\n LEFT JOIN operations ON plagesop.plageop_id = operations.plageop_id\n LEFT JOIN users_mediboard ON plagesop.chir_id = users_mediboard.user_id\n LEFT JOIN affectation_personnel ON operations.operation_id = affectation_personnel.object_id "; if ($type_hospi) { $query .= "LEFT JOIN sejour ON sejour.sejour_id = operations.sejour_id "; } $query .= "WHERE affectation_personnel.debut < affectation_personnel.fin\n AND affectation_personnel.debut IS NOT NULL\n AND affectation_personnel.fin IS NOT NULL\n AND affectation_personnel.object_class = 'COperation'\n AND plagesop.salle_id " . CSQLDataSource::prepareIn(array_keys($salles)); if ($codeCCAM) { $query .= "\nAND operations.codes_ccam LIKE '%{$codeCCAM}%'"; } if ($type_hospi) { $query .= "\nAND sejour.type = '{$type_hospi}'"; } if ($prat_id) { $query .= "\nAND plagesop.chir_id = '{$prat_id}'"; } if ($discipline_id) { $query .= "\nAND users_mediboard.discipline_id = '{$discipline_id}'"; } $query .= "\nAND plagesop.date BETWEEN '{$debut}' AND '{$fin}'\n GROUP BY operations.plageop_id HAVING total > 0 ORDER BY orderitem"; $result = $ds->loadlist($query); $result_hors_plage = array(); if ($hors_plage) { $query_hors_plage = "SELECT SUM(TIME_TO_SEC(affectation_personnel.fin) - TIME_TO_SEC(affectation_personnel.debut)) as total,\n DATE_FORMAT(operations.date, '{$date_format}') AS {$type_duree_fr},\n DATE_FORMAT(operations.date, '{$order_key}') AS orderitem\n FROM operations\n LEFT JOIN users_mediboard ON operations.chir_id = users_mediboard.user_id\n LEFT JOIN affectation_personnel ON operations.operation_id = affectation_personnel.object_id "; if ($type_hospi) { $query_hors_plage .= "LEFT JOIN sejour ON sejour.sejour_id = operations.sejour_id "; } $query_hors_plage .= "WHERE affectation_personnel.debut < affectation_personnel.fin\n AND operations.date IS NOT NULL\n AND operations.plageop_id IS NULL\n AND affectation_personnel.debut IS NOT NULL\n AND affectation_personnel.fin IS NOT NULL\n AND affectation_personnel.object_class = 'COperation'\n AND operations.salle_id " . CSQLDataSource::prepareIn(array_keys($salles)); if ($type_hospi) { $query_hors_plage .= "\nAND sejour.type = '{$type_hospi}'"; } if ($prat_id) { $query_hors_plage .= "\nAND operations.chir_id = '{$prat_id}'"; } if ($discipline_id) { $query_hors_plage .= "\nAND users_mediboard.discipline_id = '{$discipline_id}'"; } if ($codeCCAM) { $query_hors_plage .= "\nAND operations.codes_ccam LIKE '%{$codeCCAM}%'"; } $query_hors_plage .= "\nAND operations.date BETWEEN '{$debut}' AND '{$fin}'\n GROUP BY {$type_duree_fr} HAVING total > 0 ORDER BY orderitem"; $result_hors_plage = $ds->loadlist($query_hors_plage); } $calcul_temp = array(); foreach ($result as $r) { if (!isset($calcul_temp[$r[$type_duree_fr]])) { $calcul_temp[$r[$type_duree_fr]] = 0; } $calcul_temp[$r[$type_duree_fr]] += $r['total']; } foreach ($ticks as $i => $tick) { $f = true; foreach ($calcul_temp as $key => $r) { if ($tick[1] == $key) { if ($hors_plage) { foreach ($result_hors_plage as &$_r_h) { if ($tick[1] == $_r_h[$type_duree_fr]) { $r += $_r_h["total"]; unset($_r_h); break; } } } $serieTot['data'][] = array($i, $r / (60 * 60)); $totalTot += $r / (60 * 60); $f = false; } } if ($f) { $serieTot["data"][] = array(count($serieTot["data"]), 0); } } $seriesTot[] = $serieTot; // Second serie : Ouverture de salle $serieTot = array('data' => array(), 'label' => utf8_encode("Ouverture de salle")); $query = "SELECT MAX(TIME_TO_SEC(operations.sortie_salle)) - MIN(TIME_TO_SEC(operations.entree_salle)) as total,\n DATE_FORMAT(plagesop.date, '{$date_format}') AS {$type_duree_fr},\n DATE_FORMAT(plagesop.date, '{$order_key}') AS orderitem\n FROM plagesop\n LEFT JOIN operations ON plagesop.plageop_id = operations.plageop_id\n LEFT JOIN users_mediboard ON plagesop.chir_id = users_mediboard.user_id "; if ($type_hospi) { $query .= "LEFT JOIN sejour ON sejour.sejour_id = operations.sejour_id "; } $query .= "WHERE operations.entree_salle < operations.sortie_salle\n AND plagesop.salle_id " . CSQLDataSource::prepareIn(array_keys($salles)); if ($codeCCAM) { $query .= "\nAND operations.codes_ccam LIKE '%{$codeCCAM}%'"; } if ($type_hospi) { $query .= "\nAND sejour.type = '{$type_hospi}'"; } if ($prat_id) { $query .= "\nAND plagesop.chir_id = '{$prat_id}'"; } if ($discipline_id) { $query .= "\nAND users_mediboard.discipline_id = '{$discipline_id}'"; } $query .= "\nAND plagesop.date BETWEEN '{$debut}' AND '{$fin}'\n GROUP BY operations.plageop_id ORDER BY orderitem"; $result = $ds->loadlist($query); $calcul_temp = array(); foreach ($result as $r) { if (!isset($calcul_temp[$r[$type_duree_fr]])) { $calcul_temp[$r[$type_duree_fr]] = 0; } $calcul_temp[$r[$type_duree_fr]] += $r['total']; } foreach ($ticks as $i => $tick) { $f = true; foreach ($calcul_temp as $key => $r) { if ($tick[1] == $key) { $serieTot['data'][] = array($i, $r / (60 * 60)); $totalTot += $r / (60 * 60); $f = false; } } if ($f) { $serieTot["data"][] = array(count($serieTot["data"]), 0); } } $seriesTot[] = $serieTot; // Third serie : reservé $serieTot = array('data' => array(), 'label' => utf8_encode("Vacations attribuées")); $query = "SELECT SUM(TIME_TO_SEC(plagesop.fin) - TIME_TO_SEC(plagesop.debut)) AS total,\n DATE_FORMAT(plagesop.date, '{$date_format}') AS {$type_duree_fr},\n DATE_FORMAT(plagesop.date, '{$order_key}') AS orderitem\n FROM plagesop\n LEFT JOIN users_mediboard ON plagesop.chir_id = users_mediboard.user_id "; if ($type_hospi || $codeCCAM) { $query .= "LEFT JOIN operations ON operations.plageop_id = plagesop.plageop_id\n LEFT JOIN sejour ON sejour.sejour_id = operations.sejour_id "; } $query .= "WHERE plagesop.salle_id " . CSQLDataSource::prepareIn(array_keys($salles)); if ($codeCCAM) { $query .= "\nAND operations.codes_ccam LIKE '%{$codeCCAM}%'"; } if ($type_hospi) { $query .= "\nAND sejour.type = '{$type_hospi}'"; } if ($prat_id) { $query .= "\nAND plagesop.chir_id = '{$prat_id}'"; } if ($discipline_id) { $query .= "\nAND users_mediboard.discipline_id = '{$discipline_id}'"; } $query .= "\nAND plagesop.date BETWEEN '{$debut}' AND '{$fin}'\n GROUP BY {$type_duree_fr} ORDER BY orderitem"; $result = $ds->loadList($query); foreach ($ticks as $i => $tick) { $f = true; foreach ($result as $r) { if ($tick[1] == $r[$type_duree_fr]) { $serieTot['data'][] = array($i, $r["total"] / (60 * 60)); $totalTot += $r["total"] / (60 * 60); $f = false; } } if ($f) { $serieTot["data"][] = array(count($serieTot["data"]), 0); } } $seriesTot[] = $serieTot; // Set up the title for the graph $subtitle = ""; if ($prat_id) { $subtitle .= " - Dr {$prat->_view}"; } if ($discipline_id) { $subtitle .= " - {$discipline->_view}"; } if ($salle_id) { $subtitle .= " - {$salle->nom}"; } if ($bloc_id) { $subtitle .= " - {$bloc->nom}"; } if ($codeCCAM) { $subtitle .= " - CCAM : {$codeCCAM}"; } if ($type_hospi) { $subtitle .= " - " . CAppUI::tr("CSejour.type.{$type_hospi}"); } $optionsTot = CFlotrGraph::merge("lines", array('title' => utf8_encode("Utilisation des ressources"), 'subtitle' => utf8_encode("total estimé {$subtitle}"), 'xaxis' => array('ticks' => $ticks), 'grid' => array('verticalLines' => true))); if ($totalTot == 0) { $optionsTot['yaxis']['max'] = 1; } return array('series' => $seriesTot, 'options' => $optionsTot); }
$discipline_id = CValue::get("discipline_id"); $bloc_id = CValue::get("bloc_id"); $salle_id = CValue::get("salle_id"); $hors_plage = CValue::get("hors_plage"); CView::enforceSlave(); if (!$debut) { $debut = CMbDT::date("-1 YEAR"); } if (!$fin) { $fin = CMbDT::date(); } $salle = new CSalle(); $salle->load($salle_id); $bloc = new CBlocOperatoire(); $bloc->load($bloc_id); $discipline = new CDiscipline(); $discipline->load($discipline_id); $salles = CSalle::getSallesStats($salle_id, $bloc_id); // Chargement des praticiens $user = new CMediusers(); $where = array(); $where["users_mediboard.actif"] = "= '1'"; if ($discipline->_id) { $where["users_mediboard.discipline_id"] = "= '{$discipline->_id}'"; } // Filter on user type $utypes_flip = array_flip(CUser::$types); $user_types = array("Chirurgien", "Anesthésiste", "Médecin", "Dentiste"); foreach ($user_types as &$_type) { $_type = $utypes_flip[$_type]; }
/** * 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); }
/** * Récupération du graphique du nombre d'interventions par praticien * * @param string $debut Date de début * @param string $fin Date de fin * @param int $prat_id Identifiant du praticien * @param int $salle_id Identifiant de la salle * @param int $bloc_id Identifiant du bloc * @param int $func_id Identifiant du cabinet * @param int $discipline_id Identifiant de la discipline * @param string $codeCCAM Code CCAM * @param string $type_hospi Type d'hospitalisation * @param bool $hors_plage Prise en compte des hors plage * * @return array */ function graphPraticienDiscipline($debut = null, $fin = null, $prat_id = 0, $salle_id = 0, $bloc_id = 0, $func_id = 0, $discipline_id = 0, $codeCCAM = "", $type_hospi = "", $hors_plage = true) { if (!$debut) { $debut = CMbDT::date("-1 YEAR"); } if (!$fin) { $fin = CMbDT::date(); } $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); } $user = new CMediusers(); $ljoin = array("users" => "users.user_id = users_mediboard.user_id", "functions_mediboard" => "functions_mediboard.function_id = users_mediboard.function_id"); $where = array("functions_mediboard.group_id" => "= '" . CGroups::loadCurrent()->_id . "'"); if ($discipline_id) { $where["users_mediboard.discipline_id"] = " = '{$discipline_id}'"; } if ($prat_id) { $where["users_mediboard.user_id"] = " = '{$prat_id}'"; } $user_types = array("Chirurgien", "Anesthésiste", "Médecin"); $utypes_flip = array_flip(CUser::$types); if (is_array($user_types)) { foreach ($user_types as $key => $value) { $user_types[$key] = $utypes_flip[$value]; } $where["users.user_type"] = CSQLDataSource::prepareIn($user_types); } $order = "`users`.`user_last_name`, `users`.`user_first_name`"; $users = $user->loadList($where, $order, null, null, $ljoin); // Gestion du hors plage $where_hors_plage = !$hors_plage ? "AND operations.plageop_id IS NOT NULL" : ""; $total = 0; $series = array(); foreach ($users as $user) { $serie = array('data' => array(), 'label' => utf8_encode($user->_view)); $query = "SELECT COUNT(operations.operation_id) AS total,\r\n DATE_FORMAT(operations.date, '%m/%Y') AS mois,\r\n DATE_FORMAT(operations.date, '%Y%m') AS orderitem,\r\n users_mediboard.user_id\r\n FROM operations\r\n INNER JOIN sallesbloc ON operations.salle_id = sallesbloc.salle_id\r\n LEFT JOIN sejour ON operations.sejour_id = sejour.sejour_id\r\n LEFT JOIN users_mediboard ON operations.chir_id = users_mediboard.user_id\r\n LEFT JOIN users ON users_mediboard.user_id = users.user_id\r\n WHERE operations.annulee = '0'\r\n AND operations.date BETWEEN '{$debut}' AND '{$fin}'\r\n {$where_hors_plage}\r\n AND sejour.group_id = '" . CGroups::loadCurrent()->_id . "'\r\n AND users_mediboard.user_id = '{$user->_id}'"; if ($type_hospi) { $query .= "\nAND sejour.type = '{$type_hospi}'"; } if ($discipline_id) { $query .= "\nAND users_mediboard.discipline_id = '{$discipline_id}'"; } if ($codeCCAM) { $query .= "\nAND operations.codes_ccam LIKE '%{$codeCCAM}%'"; } if ($salle_id) { $query .= "\nAND sallesbloc.salle_id = '{$salle_id}'"; } elseif ($bloc_id) { $query .= "\nAND sallesbloc.bloc_id = '{$bloc_id}'"; } $query .= "\nGROUP BY mois ORDER BY orderitem"; $result = $user->_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; } } if ($f) { $serie["data"][] = array(count($serie["data"]), 0); } } $series[] = $serie; } $series[] = $serie_total; $title = "Nombre d'interventions par praticien"; $subtitle = "{$total} opérations"; if ($discipline_id) { $subtitle .= " - {$discipline->_view}"; } if ($codeCCAM) { $subtitle .= " - CCAM : {$codeCCAM}"; } if ($type_hospi) { $subtitle .= " - " . CAppUI::tr("CSejour.type.{$type_hospi}"); } $options = array('title' => utf8_encode($title), 'subtitle' => utf8_encode($subtitle), 'xaxis' => array('labelsAngle' => 45, 'ticks' => $ticks), 'yaxis' => array('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); }
} $object->loadNamedFile("identite.jpg"); $object->loadNamedFile("signature.jpg"); // Savoir s'il est relié au LDAP if (isset($object->_ref_user)) { $object->_ref_user->isLDAPLinked(); } // Chargement des banques $banques = array(); if (class_exists("CBanque")) { $order = "nom ASC"; $banque = new CBanque(); $banques = $banque->loadList(null, $order); } // Récupération des disciplines $discipline = new CDiscipline(); $disciplines = $discipline->loadList(); // Récupération des spécialités CPAM $spec_cpam = new CSpecCPAM(); $spec_cpam = $spec_cpam->loadList(null, 'spec_cpam_id ASC'); // Récupération des profils $profile = new CUser(); $profile->template = 1; /** @var CUser[] $profiles */ $profiles = $profile->loadMatchingList(); // Creation du tableau de profil en fonction du type $tabProfil = array(); foreach ($profiles as $profil) { $tabProfil[$profil->user_type][] = $profil->_id; } $tag = false;
/** * Récupération du graphique du nombre de patients hospitalisés * par type d'hospitalisation * * @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 le caractère septique * @param string $type_data Type de données (prévues / réelles) * * @return array */ function graphPatParTypeHospi($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); } $sejour = new CSejour(); $listHospis = array(); foreach ($sejour->_specs["type"]->_locales as $key => $type) { if (($key == "comp" || $key == "ambu") && $type_adm == 1 || $type_adm == $key || $type_adm == null) { $listHospis[$key] = utf8_encode($type); } } $total = 0; $series = array(); foreach ($listHospis as $key => $type) { $serie = array('label' => $type, 'data' => array()); $query = "SELECT COUNT(DISTINCT sejour.sejour_id) AS total, sejour.type,\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 LEFT JOIN service ON affectation.service_id = service.service_id\r\n WHERE\r\n sejour.entree_{$type_data} BETWEEN '{$debut} 00:00:00' AND '{$fin} 23:59:59' AND\r\n sejour.group_id = '" . CGroups::loadCurrent()->_id . "' AND\r\n sejour.type = '{$key}' AND\r\n sejour.annule = '0'"; if ($service_id) { $query .= "\nAND 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}'"; } $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; } } if ($f) { $serie["data"][] = array(count($serie["data"]), 0); } } $series[] = $serie; } $series[] = $serie_total; $subtitle = "{$total} patients"; if ($prat_id) { $subtitle .= " - Dr {$prat->_view}"; } if ($discipline_id) { $subtitle .= " - {$discipline->_view}"; } if ($septique) { $subtitle .= " - Septiques"; } $options = array('title' => utf8_encode("Nombre d'admissions par type d'hospitalisation - {$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); }
/** * Récupération du graphique du nombre moyen de patient * en SSPI selon le jour de la semaine * * @param string $debut Date de début * @param string $fin Date de fin * @param int $prat_id Identifiant du praticien * @param int $bloc_id Identifiant du bloc * @param null $discipline_id Identifiant de la discipline * @param string $codeCCAM Code CCAM * * @return array */ function graphPatRepartJour($debut = null, $fin = null, $prat_id = 0, $bloc_id = 0, $func_id = 0, $discipline_id = null, $codeCCAM = '') { 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(array("0", "Dimanche"), array("1", "Lundi"), array("2", "Mardi"), array("3", "Mercredi"), array("4", "Jeudi"), array("5", "Vendredi"), array("6", "Samedi")); $bloc = new CBlocOperatoire(); if ($bloc_id) { $bloc->load($bloc_id); } $series = array(); $serie = array("data" => array()); // Nombre de patients par jour de la semaine $query = "SELECT COUNT(operations.operation_id) AS total,\n COUNT(DISTINCT(operations.date)) AS nb_days,\n DATE_FORMAT(operations.date, '%W') AS jour,\n\t DATE_FORMAT(operations.date, '%w') AS orderitem\n FROM operations\n INNER JOIN sallesbloc ON operations.salle_id = sallesbloc.salle_id\n LEFT JOIN users_mediboard ON operations.chir_id = users_mediboard.user_id\n WHERE sallesbloc.stats = '1'\n AND operations.date BETWEEN '{$debut}' AND '{$fin}'\n AND operations.annulee = '0'"; if ($prat_id) { $query .= "\nAND operations.chir_id = '{$prat_id}'"; } if ($discipline_id) { $query .= "\nAND users_mediboard.discipline_id = '{$discipline_id}'"; } if ($codeCCAM) { $query .= "\nAND operations.codes_ccam LIKE '%{$codeCCAM}%'"; } if ($bloc_id) { $query .= "\nAND sallesbloc.bloc_id = '{$bloc_id}'"; } $query .= "\nGROUP BY jour ORDER BY orderitem"; $result = $prat->_spec->ds->loadlist($query); foreach ($ticks as $i => $tick) { $f = true; foreach ($result as $r) { if ($i == $r["orderitem"]) { $serie["data"][] = array($tick[0], $r["total"] / $r["nb_days"]); $f = false; } } if ($f) { $serie["data"][] = array(count($serie["data"]), 0); } } $serie["label"] = "moyenne"; $series[] = $serie; // Set up the title for the graph $title = "Patients moyens / jour de la semaine"; $subtitle = "Uniquement les jours d'activité"; if ($prat_id) { $subtitle .= " - Dr {$prat->_view}"; } if ($discipline_id) { $subtitle .= " - {$discipline->_view}"; } if ($bloc_id) { $subtitle .= " - {$bloc->_view}"; } if ($codeCCAM) { $subtitle .= " - CCAM : {$codeCCAM}"; } $options = array('title' => utf8_encode($title), 'subtitle' => utf8_encode($subtitle), 'xaxis' => array('labelsAngle' => 45, 'ticks' => $ticks), 'yaxis' => array('autoscaleMargin' => 1, 'min' => 0), 'lines' => array('show' => true, 'filled' => true, 'fillColor' => '#999'), 'markers' => array('show' => true), 'points' => array('show' => true), 'HtmlText' => false, 'legend' => array('show' => true, 'position' => 'nw'), 'mouse' => array('track' => true, 'relative' => true, 'position' => 'ne'), '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); }
/** * 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); }