Exemplo n.º 1
0
 /**
  * @see parent::updateFormFields()
  */
 function updateFormFields()
 {
     parent::updateFormFields();
     $this->_view = "Allaitement du " . CMbDT::transform($this->date_debut, null, CAppUI::conf("date")) . " à " . CMbDT::transform($this->date_debut, null, CAppUI::conf("time"));
     if ($this->date_fin) {
         $this->_view .= " au " . CMbDT::transform($this->date_fin, null, CAppUI::conf("date")) . " à " . CMbDT::transform($this->date_fin, null, CAppUI::conf("time"));
     }
 }
/**
 * Récupération des statistiques du nombre de consultations 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
 *
 * @return array
 */
function graphConsultations($debut = null, $fin = null, $prat_id = 0)
{
    if (!$debut) {
        $debut = CMbDT::date("-1 YEAR");
    }
    if (!$fin) {
        $fin = CMbDT::date();
    }
    $rectif = CMbDT::transform("+0 DAY", $debut, "%d") - 1;
    $debutact = CMbDT::date("-{$rectif} DAYS", $debut);
    $rectif = CMbDT::transform("+0 DAY", $fin, "%d") - 1;
    $finact = CMbDT::date("-{$rectif} DAYS", $fin);
    $finact = CMbDT::date("+ 1 MONTH", $finact);
    $finact = CMbDT::date("-1 DAY", $finact);
    $pratSel = new CMediusers();
    $pratSel->load($prat_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);
    }
    $ds = CSQLDataSource::get("std");
    $total = 0;
    $series = array();
    $query = "SELECT COUNT(consultation.consultation_id) AS total,\r\n    DATE_FORMAT(plageconsult.date, '%m/%Y') AS mois,\r\n    DATE_FORMAT(plageconsult.date, '%Y%m') AS orderitem\r\n    FROM consultation\r\n    INNER JOIN plageconsult\r\n    ON consultation.plageconsult_id = plageconsult.plageconsult_id\r\n    INNER JOIN users_mediboard\r\n    ON plageconsult.chir_id = users_mediboard.user_id\r\n    WHERE plageconsult.date BETWEEN '{$debutact}' AND '{$finact}'\r\n    AND consultation.annule = '0'";
    if ($prat_id) {
        $query .= "\nAND plageconsult.chir_id = '{$prat_id}'";
    }
    $query .= "\nGROUP BY mois ORDER BY orderitem";
    $serie = array('data' => array());
    $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;
    // Set up the title for the graph
    $title = "Nombre de consultations";
    $subtitle = "- {$total} consultations -";
    if ($prat_id) {
        $subtitle .= " Dr {$pratSel->_view} -";
    }
    $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);
}
Exemplo n.º 3
0
 /**
  * constructor
  *
  * @param string $date        current date in the planning
  * @param null   $date_min    min date of the planning
  * @param null   $date_max    max
  * @param bool   $selectable  is the planning selectable
  * @param string $height      [optional] height of the planning, default : auto
  * @param bool   $large       [optional] is the planning a large one
  * @param bool   $adapt_range [optional] can the planning adapt the range
  */
 function __construct($date, $date_min = null, $date_max = null, $selectable = false, $height = "auto", $large = false, $adapt_range = false)
 {
     parent::__construct($date);
     $this->today = CMbDT::date();
     $this->type = "month";
     $this->selectable = $selectable;
     $this->height = $height ? $height : "auto";
     $this->large = $large;
     $this->adapt_range = $adapt_range;
     $this->no_dates = true;
     if (is_int($date) || is_int($date_min) || is_int($date_max)) {
         $this->no_dates = true;
         $this->date_min = $this->date_min_active = $this->_date_min_planning = $date_min;
         $this->date_max = $this->date_max_active = $this->_date_max_planning = $date_max;
         $this->nb_days = CMbDT::transform(null, $this->date_max, "%d") - CMbDT::transform(null, $this->date_min, "%d");
         for ($i = 0; $i < $this->nb_days; $i++) {
             $this->days[$i] = array();
             $this->load_data[$i] = array();
         }
     } else {
         $this->date_min = $this->date_min_active = $this->_date_min_planning = CMbDT::date("first day of this month", $date);
         $this->date_max = $this->date_max_active = $this->_date_max_planning = CMbDT::date("last day of this month", $this->date_min);
         // add the last days of previous month
         $min_day_number = CMbDT::format($this->date_min, "%w");
         $this->first_day_of_first_week = $first_day = CMbDT::date("this week", $min_day_number == 0 ? CMbDT::date("-1 DAY", $this->date_min) : $this->date_min);
         while ($first_day != $this->date_min) {
             $this->days[$first_day] = array();
             $first_day = CMbDT::date("+1 DAY", $first_day);
         }
         $this->nb_days = CMbDT::transform(null, $this->date_max, "%d");
         for ($i = 0; $i < $this->nb_days; $i++) {
             $_day = CMbDT::date("+{$i} day", $this->date_min);
             $this->days[$_day] = array();
             $this->load_data[$_day] = array();
         }
         //fill the rest of the last week
         $max_day_number = CMbDT::format($this->date_max, "%w");
         if ($max_day_number != 0) {
             $last_day_of_week = CMbDT::date("this week +6 days", $this->date_max);
             $last_day_of_month = $this->date_max;
             while ($last_day_of_month <= $last_day_of_week) {
                 $this->days[$last_day_of_month] = array();
                 $last_day_of_month = CMbDT::date("+1 DAY", $last_day_of_month);
             }
         }
         $this->classes_for_days = $this->days;
     }
     $this->previous_month = CMbDT::date("-1 DAY", $this->date_min);
     $this->next_month = CMbDT::date("+1 DAY", $this->date_max);
     $this->_date_min_planning = reset(array_keys($this->days));
     $this->_date_max_planning = end(array_keys($this->days));
     $this->_hours = array();
 }
Exemplo n.º 4
0
 /**
  * constructor
  *
  * @param string $date date chosen
  */
 public function __construct($date = null)
 {
     if (!$date) {
         $date = CMbDT::date();
     }
     $this->date = $date;
     $this->number = (int) CMbDT::transform("", $date, "%j");
     $dateTmp = explode("-", $date);
     $this->name = CMbDate::$days_name[(int) $dateTmp[1]][(int) ($dateTmp[2] - 1)];
     $this->_nbDaysYear = CMbDT::format($date, "L") ? 366 : 365;
     $this->days_left = $this->_nbDaysYear - $this->number;
     //jour férie ?
     $holidays = CMbDate::getHolidays($this->date);
     if (array_key_exists($this->date, $holidays)) {
         $this->ferie = $holidays[$this->date];
     }
 }
 function updateFormFields()
 {
     parent::updateFormFields();
     $this->_hour_deb = CMbDT::transform($this->debut, null, "%H");
     $this->_hour_fin = CMbDT::transform($this->fin, null, "%H");
     // State rules
     if ($this->paye == 1) {
         $this->_state = self::PAYED;
     } elseif ($this->date < CMbDT::date()) {
         $this->_state = self::OUT;
     } elseif ($this->prat_id) {
         if (CMbDT::date("+ 15 DAYS") > $this->date) {
             $this->_state = self::BLOCKED;
         } else {
             $this->_state = self::BUSY;
         }
     } elseif (CMbDT::date("+ 1 MONTH") < $this->date) {
         $this->_state = self::FREEB;
     } else {
         $this->_state = self::FREE;
     }
 }
Exemplo n.º 6
0
    $date_max = CMbDT::dateTime("-1 second", $date_max);
}
for ($i = 0; $i < $nb_ticks; $i++) {
    $offset = $i * $nb_unite;
    $datetime = CMbDT::dateTime("+ {$offset} {$unite}", $date_min);
    $datetimes[] = $datetime;
    if ($granularite == "4weeks") {
        if (CMbDT::date($current) == CMbDT::date($temp_datetime) && CMbDT::time($current) >= CMbDT::time($temp_datetime) && CMbDT::time($current) > CMbDT::time($datetime)) {
            $current = $temp_datetime;
        }
        $week_a = CMbDT::transform($temp_datetime, null, "%V");
        $week_b = CMbDT::transform($datetime, null, "%V");
        // les semaines
        $days[$datetime] = $week_b;
        // On stocke le changement de mois s'il advient
        if (CMbDT::transform($datetime, null, "%m") != CMbDT::transform($temp_datetime, null, "%m")) {
            // Entre deux semaines
            if ($i % 7 == 0) {
                $change_month[$week_a] = array("right" => $temp_datetime);
                $change_month[$week_b] = array("left" => $datetime);
            } else {
                $change_month[$week_b] = array("left" => $temp_datetime, "right" => $datetime);
            }
        }
    } else {
        if ($granularite == "week" && CMbDT::date($current) == CMbDT::date($temp_datetime) && CMbDT::time($datetime) >= CMbDT::time($temp_datetime) && CMbDT::time($current) <= CMbDT::time($datetime)) {
            $current = $temp_datetime;
        }
        // le datetime, pour avoir soit le jour soit l'heure
        $days[] = CMbDT::date($datetime);
    }
 /**
  * Build constantes grid
  *
  * @param self  $constante       The CConstantesMedicales object containing the latest values
  * @param array $dates           An array containing the date of the
  * @param bool  $full            Display the full list of constantes
  * @param bool  $only_with_value Only display not null values
  *
  * @return array
  */
 static function buildGridLatest($constante, $dates, $full = true, $only_with_value = false)
 {
     $dates = CMbArray::flip($dates);
     if (array_key_exists('', $dates)) {
         unset($dates['']);
     }
     $grid = array();
     $selection = array_keys(CConstantesMedicales::$list_constantes);
     $cumuls_day = array();
     $reset_hours = array();
     $cumul_names = array();
     if (!$full) {
         $conf_constantes = array_filter(CConstantesMedicales::getRanksFor());
         $selection = array_keys($conf_constantes);
         foreach (CConstantesMedicales::$list_constantes as $_name => $_params) {
             if ($constante->{$_name} != '' && !empty($_params["cumul_in"])) {
                 $selection = array_merge($selection, $_params["cumul_in"]);
                 $cumul_names = array_merge($selection, $_params["cumul_in"]);
             }
         }
         $selection = array_unique($selection);
     }
     if ($only_with_value) {
         $selection = array();
     }
     $names = $selection;
     foreach ($dates as $_date => $_constants) {
         if (!isset($grid["{$_date}"])) {
             $grid["{$_date}"] = array('comment' => '', "values" => array());
         }
         foreach ($_constants as $_name) {
             $_params = CConstantesMedicales::$list_constantes[$_name];
             if (in_array($_name, $selection) || in_array($_name, $cumul_names) || $constante->{$_name} != '') {
                 $value = null;
                 if (isset($_params["cumul_for"]) || isset($_params["formula"])) {
                     // cumul
                     if (!isset($reset_hours[$_name])) {
                         $reset_hours[$_name] = self::getResetHour($_name);
                     }
                     $reset_hour = $reset_hours[$_name];
                     $day_24h = CMbDT::transform("-{$reset_hour} hours", $_date, '%y-%m-%d');
                     if (!isset($cumuls_day[$_name][$day_24h])) {
                         $cumuls_day[$_name][$day_24h] = array("id" => $constante->_id, "datetime" => $_date, "value" => null, "span" => 0, "pair" => @count($cumuls_day[$_name]) % 2 ? "odd" : "even", "day" => CMbDT::transform($day_24h, null, "%a"));
                     }
                     if (isset($_params["cumul_for"])) {
                         // cumul simple sur le meme champ
                         $cumul_for = $_params["cumul_for"];
                         if ($constante->{$cumul_for} !== null) {
                             $cumuls_day[$_name][$day_24h]["value"] += $constante->{$cumul_for};
                         }
                     } else {
                         // cumul de plusieurs champs (avec formule)
                         $formula = $_params["formula"];
                         foreach ($formula as $_field => $_sign) {
                             $_value = $constante->{$_field};
                             if ($constante->{$_field} !== null) {
                                 if ($_sign === "+") {
                                     $cumuls_day[$_name][$day_24h]["value"] += $_value;
                                 } else {
                                     $cumuls_day[$_name][$day_24h]["value"] -= $_value;
                                 }
                             }
                         }
                     }
                     $cumuls_day[$_name][$day_24h]["span"]++;
                     $value = "__empty__";
                 } else {
                     // valeur normale
                     $spec = self::$list_constantes[$_name];
                     $value = $constante->{$_name};
                     if (isset($spec["formfields"])) {
                         $arr = array();
                         foreach ($spec["formfields"] as $ff) {
                             if ($constante->{$ff} != "") {
                                 $arr[] = $constante->{$ff};
                             }
                         }
                         $value = implode(" / ", $arr);
                     }
                 }
                 $grid["{$_date}"]["values"][$_name] = $value;
                 if (!in_array($_name, $names)) {
                     $names[] = $_name;
                 }
             }
         }
     }
     foreach ($cumuls_day as $_name => &$_days) {
         $_params = CConstantesMedicales::$list_constantes[$_name];
         foreach ($_days as &$_values) {
             $_color = CConstantesMedicales::getColor($_values["value"], $_params, null);
             $_values["color"] = $_color;
             $grid[$_values["datetime"] . " " . $_values["id"]]["values"][$_name] = $_values;
         }
     }
     $names = self::sortConstNames($names);
     return array($names, "names" => $names, $grid, "grid" => $grid);
 }
Exemplo n.º 8
0
        } else {
            $tab_start[$j] = date("w", mktime(0, 0, 0, $i, 1, $year));
        }
        $j++;
        $tab_start[$j] = date("t", mktime(0, 0, 0, $i, 1, $year));
        $j++;
    }
} else {
    list($a, $m, $j) = explode("-", $filter->date_debut);
    $debut_periode = "{$a}-{$m}-01";
    $fin_periode = CMbDT::transform('+1 month', $debut_periode, '%Y-%m-%d');
    $fin_periode = CMbDT::transform('-1 day', $fin_periode, '%Y-%m-%d');
}
$tableau_periode = array();
for ($i = 0; $i < CMbDT::daysRelative($debut_periode, $fin_periode) + 1; $i++) {
    $tableau_periode[$i] = CMbDT::transform('+' . $i . 'day', $debut_periode, '%Y-%m-%d');
}
$where = array();
$where[] = "((date_debut >= '{$debut_periode}' AND date_debut <= '{$fin_periode}'" . ")OR (date_fin >= '{$debut_periode}' AND date_fin <= '{$fin_periode}')" . "OR (date_debut <='{$debut_periode}' AND date_fin >= '{$fin_periode}'))";
$where["user_id"] = CSQLDataSource::prepareIn(array_keys($mediusers), $filter->user_id);
$plageconge = new CPlageConge();
$plagesconge = array();
$orderby = "user_id";
/** @var CPlageConge[] $plagesconge */
$plagesconge = $plageconge->loadList($where, $orderby);
$tabUser_plage = array();
$tabUser_plage_indices = array();
foreach ($plagesconge as $_plage) {
    $_plage->loadRefUser();
    $_plage->_ref_user->loadRefFunction();
    $_plage->_deb = CMbDT::daysRelative($debut_periode, $_plage->date_debut);
 /**
  * Mapping mouvements
  *
  * @param DOMNode      $node        Node
  * @param CSejour      $newVenue    Venue
  * @param CAffectation $affectation Affectation
  *
  * @return string
  */
 function mappingMovement(DOMNode $node, CSejour $newVenue, CAffectation $affectation)
 {
     $xpath = new CHPrimXPath($node->ownerDocument);
     $sender = $this->_ref_echange_hprim->_ref_sender;
     // Recherche d'une affectation existante
     $id = $newVenue->_guid . "-" . $xpath->queryTextNode("hprim:identifiant/hprim:emetteur", $node);
     $tag = $sender->_tag_hprimxml;
     $idex = CIdSante400::getMatch("CAffectation", $tag, $id);
     if ($idex->_id) {
         $affectation->load($idex->object_id);
         if ($affectation->sejour_id != $newVenue->_id) {
             return CAppUI::tr("hprimxml-error-E301");
         }
     }
     $affectation->sejour_id = $newVenue->_id;
     // Praticien responsable
     $medecinResponsable = $xpath->queryUniqueNode("hprim:medecinResponsable", $node);
     $affectation->praticien_id = $this->getMedecin($medecinResponsable);
     // Emplacement
     $this->getEmplacement($node, $newVenue, $affectation);
     // Début de l'affectation
     $debut = $xpath->queryUniqueNode("hprim:debut", $node);
     $date = $xpath->queryTextNode("hprim:date", $debut);
     $heure = CMbDT::transform($xpath->queryTextNode("hprim:heure", $debut), null, "%H:%M:%S");
     $affectation->entree = "{$date} {$heure}";
     // Fin de l'affectation
     $fin = $xpath->queryUniqueNode("hprim:fin", $node);
     if ($fin) {
         $date = $xpath->queryTextNode("hprim:date", $fin);
         $heure = CMbDT::transform($xpath->queryTextNode("hprim:heure", $fin), null, "%H:%M:%S");
         $affectation->sortie = "{$date} {$heure}";
     }
     if (!$affectation->_id) {
         $affectation = $newVenue->forceAffectation($affectation, true);
         if (is_string($affectation)) {
             return $affectation;
         }
     } else {
         if ($msg = $affectation->store()) {
             return $msg;
         }
     }
     if (!$idex->_id) {
         $idex->object_id = $affectation->_id;
         if ($msg = $idex->store()) {
             return $msg;
         }
     }
     return null;
 }
Exemplo n.º 10
0
}
$where = array();
$where["entree"] = "<= '" . $sortie_sejour . "'";
$where["sortie"] = ">= '" . $sortie_sejour . "'";
$where["function_id"] = "IS NOT NULL";
$affectatione = new CAffectation();
/** @var CAffectation[] $blocages_lit */
$blocages_lit = $affectatione->loadList($where);
$where["function_id"] = "IS NULL";
foreach ($blocages_lit as $key => $blocage) {
    $blocage->loadRefLit()->loadRefChambre()->loadRefService();
    $where["lit_id"] = "= '{$blocage->lit_id}'";
    if (!$sejour->_id && $affectatione->loadObject($where)) {
        $affectatione->loadRefSejour();
        $affectatione->_ref_sejour->loadRefPatient();
        $jusqua = CMbDT::transform($affectatione->sortie, null, "%Hh%Mmin %d-%m-%Y") . " (" . $affectatione->_ref_sejour->_ref_patient->_view;
        $blocage->_ref_lit->_view .= " indisponible jusqu'à " . $jusqua . ")";
    }
}
$exchange_source = CExchangeSource::get("mediuser-" . CAppUI::$user->_id, "smtp");
$_functions = array();
if ($chir->_id) {
    $_functions = $chir->loadBackRefs("secondary_functions");
}
$op->loadRefChir2();
$op->loadRefChir3();
$op->loadRefChir4();
if (!$op->_id) {
    $op->_time_op = $op->temp_operation = "00:00:00";
    if ($hour_urgence && $min_urgence) {
        $time = "{$hour_urgence}:{$min_urgence}:00";
Exemplo n.º 11
0
             $format = $_format;
         }
     }
 }
 preg_match($format_regexp, $line, $date_reg);
 $date_reg = $date_reg[0];
 $date = DateTime::createFromFormat($format, $date_reg);
 $date = $date->format("Y-m-d H:i:s");
 preg_match("/[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+/", $line, $ip);
 // If a domain name, next line
 if (!isset($ip[0])) {
     continue;
 }
 $ip = $ip[0];
 $day = CMbDT::transform(CMbDT::dateTime($date), null, "%Y-%m-%d");
 $hour = CMbDT::transform(CMbDT::dateTime($date), null, "%H");
 if (!isset($count_by_day[$day])) {
     $count_by_day[$day] = 0;
 }
 if (!isset($count_by_hour[$hour])) {
     $count_by_hour[$hour] = 0;
 }
 if (!isset($count_by_ip[$ip])) {
     $count_by_ip[$ip] = 0;
 }
 if (!isset($count_by_hour_ip[$hour])) {
     $count_by_hour_ip[$hour] = array();
 }
 if (!isset($count_by_hour_ip[$hour][$ip])) {
     $count_by_hour_ip[$hour][$ip] = 0;
 }
Exemplo n.º 12
0
<?php

/**
 * $Id$
 *
 * @package    Mediboard
 * @subpackage Stock
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
CCanDo::checkRead();
$invoiced = CValue::get('invoiced');
$date_min = CMbDT::transform("-1 MONTH", null, "%Y-%m-01");
$date_max = CMbDT::date("+1 MONTH -1 DAY", $date_min);
// Smarty template
$smarty = new CSmartyDP();
$smarty->assign("date_min", $date_min);
$smarty->assign("date_max", $date_max);
$smarty->assign("invoiced", $invoiced);
$smarty->display("inc_orders_filter.tpl");
Exemplo n.º 13
0
 * $Id: vw_compta.php 28340 2015-05-20 10:14:30Z aurelie17 $
 *
 * @package    Mediboard
 * @subpackage Cabinet
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision: 28340 $
 */
CCanDo::checkEdit();
// Gestion des bouton radio des dates
$now = CMbDT::date();
$yesterday = CMbDT::date("-1 DAY", $now);
$week_deb = CMbDT::date("last sunday", $now);
$week_fin = CMbDT::date("next sunday", $week_deb);
$week_deb = CMbDT::date("+1 day", $week_deb);
$rectif = CMbDT::transform("+0 DAY", $now, "%d") - 1;
$month_deb = CMbDT::date("-{$rectif} DAYS", $now);
$month_fin = CMbDT::date("+1 month", $month_deb);
$three_month_deb = CMbDT::date("-3 month", $month_fin);
$month_fin = CMbDT::date("-1 day", $month_fin);
$filter = new CConsultation();
$filter->_date_min = CMbDT::date();
$filter->_date_max = CMbDT::date("+ 0 day");
$filter->_etat_paiement = CValue::getOrSession("_etat_paiement", 0);
$filter->_type_affichage = CValue::getOrSession("_type_affichage", 0);
$filter_reglement = new CReglement();
$filter_reglement->mode = CValue::getOrSession("mode", 0);
// L'utilisateur est-il praticien ?
$mediuser = CMediusers::get();
$mediuser->loadRefFunction();
$is_praticien = $mediuser->isPraticien();
Exemplo n.º 14
0
/**
 * 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);
}
Exemplo n.º 15
0
 /**
  * Check the modifiers of the given act
  *
  * @param CObject   &$modifiers The modifiers to check
  * @param CActeCCAM &$act       The dateTime of the execution of the act
  * @param CCodable  $codable    The codable
  *
  * @return void
  */
 public static function precodeModifiers(&$modifiers, &$act, $codable)
 {
     $date = CMbDT::date(null, $act->execution);
     $time = CMbDT::time(null, $act->execution);
     $act->loadRefExecutant();
     $act->_ref_executant->loadRefDiscipline();
     $discipline = $act->_ref_executant->_ref_discipline;
     $patient = $codable->loadRefPatient();
     $patient->evalAge();
     $checked = 0;
     $spe_gyneco = $spe_gyneco = array('GYNECOLOGIE MEDICALE, OBSTETRIQUE', 'GYNECOLOGIE-OBSTETRIQUE', 'MEDECINE DE LA REPRODUCTION ET GYNECOLOGIE MEDICAL');
     $spe_gen_pediatre = array("MEDECINE GENERALE", "PEDIATRIE");
     $count_exclusive_modifiers = self::countExclusiveModifiers($act);
     $store_act = 0;
     $modifiers_to_add = "";
     $achieved = CMbDate::achievedDurations($patient->naissance, CMbDT::date(null, $act->execution));
     $patient_age = $achieved["year"];
     foreach ($modifiers as $_modifier) {
         switch ($_modifier->code) {
             case 'A':
                 $checked = $patient_age < 4 || $patient_age >= 80;
                 $_modifier->_state = $checked ? 'prechecked' : 'not_recommended';
                 break;
             case 'E':
                 $checked = $patient->_annees < 5;
                 $_modifier->_state = $checked ? 'prechecked' : 'not_recommended';
                 break;
             case 'F':
                 $checked = ($count_exclusive_modifiers == 1 && $_modifier->_checked || $count_exclusive_modifiers == 0) && (CMbDT::transform('', $act->execution, '%w') == 0 || CMbDate::isHoliday($date)) && ($time > '08:00:00' && $time < '20:00:00');
                 if ($checked) {
                     $_modifier->_state = 'prechecked';
                 } elseif ($count_exclusive_modifiers == 1 && $_modifier->_checked || $count_exclusive_modifiers > 0) {
                     $_modifier->_state = 'forbidden';
                 } else {
                     $_modifier->_state = 'not_recommended';
                 }
                 break;
             case "J":
                 $checked = $codable->_class == 'COperation' && CAppUI::pref('precode_modificateur_J');
                 $_modifier->_state = $checked ? 'prechecked' : null;
                 break;
             case 'K':
                 $checked = !$act->montant_depassement && ($act->_ref_executant->secteur == 1 || $act->_ref_executant->secteur == 2 && $patient->cmu || $act->_ref_executant->contrat_acces_soins || $act->_ref_executant->option_coordination);
                 if ($checked) {
                     $_modifier->_state = 'prechecked';
                 } elseif (!in_array($discipline, $spe_gyneco)) {
                     $_modifier->_state = 'not_recommended';
                 }
                 if (self::isModifierchecked('K', $act) && !$act->montant_depassement) {
                     $checked = true;
                 }
                 break;
             case 'L':
                 if (self::isModifierchecked('L', $act)) {
                     $_modifier->_state = 'prechecked';
                     $checked = true;
                 }
                 break;
             case 'M':
                 $checked = 0;
                 if (!in_array($discipline->text, $spe_gen_pediatre)) {
                     $_modifier->_state = 'not_recommended';
                 }
                 break;
             case 'N':
                 $checked = $patient->_annees < 13;
                 $_modifier->_state = $checked ? 'prechecked' : 'not_recommended';
                 break;
             case 'P':
                 $checked = ($count_exclusive_modifiers == 1 && $_modifier->_checked || $count_exclusive_modifiers == 0) && in_array($discipline->text, $spe_gen_pediatre) && ($time > "20:00:00" && $time < "23:59:59");
                 if ($checked) {
                     $_modifier->_state = 'prechecked';
                 } elseif ($count_exclusive_modifiers == 1 && $_modifier->_checked || $count_exclusive_modifiers > 0) {
                     $_modifier->_state = 'forbidden';
                 } else {
                     $_modifier->_state = 'not_recommended';
                 }
                 break;
             case 'R':
                 if (self::isModifierchecked('R', $act)) {
                     $_modifier->_state = 'prechecked';
                     $checked = true;
                 }
                 break;
             case 'S':
                 $checked = (in_array($discipline->text, $spe_gen_pediatre) || $codable->_class == "COperation" && $codable->_lu_type_anesth) && ($time >= "00:00:00" && $time < "08:00:00") && ($count_exclusive_modifiers == 1 && $_modifier->_checked || $count_exclusive_modifiers == 0);
                 if ($checked) {
                     $_modifier->_state = 'prechecked';
                 } elseif ($count_exclusive_modifiers == 1 && $_modifier->_checked || $count_exclusive_modifiers > 0) {
                     $_modifier->_state = 'forbidden';
                 } else {
                     $_modifier->_state = 'not_recommended';
                 }
                 break;
             case 'U':
                 $checked = ($count_exclusive_modifiers == 1 && $_modifier->_checked || $count_exclusive_modifiers == 0) && !in_array($discipline->text, $spe_gen_pediatre) && ($time > '20:00:00' || $time < '08:00:00');
                 if ($checked) {
                     $_modifier->_state = 'prechecked';
                 } elseif ($count_exclusive_modifiers == 1 && $_modifier->_checked || $count_exclusive_modifiers > 0) {
                     $_modifier->_state = 'forbidden';
                 } else {
                     $_modifier->_state = 'not_recommended';
                 }
                 break;
             case "7":
                 $checked = CAppUI::pref('precode_modificateur_7') && $codable->_class == 'COperation' && (isset($codable->anesth_id) || $act->_ref_executant->isAnesth());
                 if ($checked) {
                     $_modifier->_state = 'prechecked';
                 } else {
                     $_modifier->_state = $codable->_class == 'COperation' && (isset($codable->anesth_id) || $act->_ref_executant->isAnesth()) ? null : 'not_recommended';
                 }
                 break;
             default:
                 $checked = 0;
                 break;
         }
         if (!$act->_id && !isset($_modifier->_checked)) {
             $_modifier->_checked = $checked;
         }
     }
     /* Handle the case where the mods S and U are both prechecked */
     if (isset($modifiers['S']) && isset($modifiers['U'])) {
         $modS =& $modifiers['S'];
         $modU =& $modifiers['U'];
         if ($modS->_state == 'prechecked' && $modU->_state == 'prechecked') {
             $modU->_checked = 0;
             $modU->_state = 'forbidden';
         }
     }
 }
Exemplo n.º 16
0
<?php

/**
 * $Id$
 *
 * @package    Mediboard
 * @subpackage Cabinet
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
CCanDo::checkEdit();
$rectif = CMbDT::transform("+0 DAY", CMbDT::date(), "%d") - 1;
$month_deb = CMbDT::date("-{$rectif} DAYS", CMbDT::date());
$date_min = CValue::getOrSession("_date_min", $month_deb);
$date_max = CValue::getOrSession("_date_max", CMbDT::date());
$etat = CValue::getOrSession("etat", "ouvert");
$etat_cloture = CValue::getOrSession("etat_cloture", 0);
$etat_relance = CValue::getOrSession("etat_relance", 0);
$facture_id = CValue::getOrSession("facture_id");
$patient_id = CValue::getOrSession("patient_id");
$no_finish_reglement = CValue::getOrSession("no_finish_reglement", 0);
$type_date_search = CValue::getOrSession("type_date_search", "cloture");
$chirSel = CValue::getOrSession("chirSel", "-1");
$num_facture = CValue::getOrSession("num_facture", "");
$numero = CValue::getOrSession("numero", 0);
$search_easy = CValue::getOrSession("search_easy", "0");
$xml_etat = CValue::getOrSession("xml_etat", "");
// Liste des chirurgiens
$user = new CMediusers();
$listChir = $user->loadPraticiens(PERM_EDIT);
Exemplo n.º 17
0
foreach ($mediChir->_back["secondary_functions"] as $curr_sec_func) {
    $secondary_functions[] = $curr_sec_func->function_id;
}
// Chargement de la liste des blocs opératoires
$bloc = new CBlocOperatoire();
$blocs = $bloc->loadGroupList(null, "nom");
foreach ($blocs as $_bloc) {
    $_bloc->loadRefsSalles();
    $_bloc->_date_min = CMbDT::date("+ " . $_bloc->days_locked . " DAYS");
}
// Chargement des plages pour le chir ou sa spécialité par bloc
$where = array();
$selectPlages = "(plagesop.chir_id = %1 OR plagesop.spec_id = %2 OR plagesop.spec_id " . CSQLDataSource::prepareIn($secondary_functions) . ")";
$where[] = $ds->prepare($selectPlages, $mediChir->user_id, $mediChir->function_id);
$month_min = CMbDT::transform("+ 0 month", $date, "%Y-%m-00");
$month_max = CMbDT::transform("+ 1 month", $date, "%Y-%m-00");
$where["date"] = "BETWEEN '{$month_min}' AND '{$month_max}'";
if (!$resp_bloc) {
    $where[] = "date >= '" . CMbDT::date() . "'";
}
$order = "date, debut";
$plage = new CPlageOp();
$listPlages = array();
foreach ($blocs as $_bloc) {
    $where["salle_id"] = CSQLDataSource::prepareIn(array_keys($_bloc->_ref_salles));
    $listPlages[$_bloc->_id] = $plage->loadList($where, $order);
    if (!count($listPlages[$_bloc->_id])) {
        unset($listPlages[$_bloc->_id]);
    }
}
$time = explode(":", $curr_op_time);
Exemplo n.º 18
0
 /**
  * Logs aggregation
  *
  * @param int  $std_agg
  * @param int  $avg_agg
  * @param int  $sup_agg
  * @param bool $dry_run
  */
 static function aggregate($std_agg = 10, $avg_agg = 60, $sup_agg = 1440, $dry_run = true)
 {
     $al = new static();
     $table = $al->_spec->table;
     $ds = $al->getDS();
     $ds->exec("SET SESSION group_concat_max_len = 100000;");
     $last_month = CMbDT::transform("- 1 MONTH", CMbDT::dateTime(), "%Y-%m-%d 00:00:00");
     $last_year = CMbDT::transform("- 1 YEAR", CMbDT::dateTime(), "%Y-%m-%d 00:00:00");
     // Get the oldest log to aggregate
     $query = "SELECT `period`\n              FROM {$table}\n              WHERE `period` <= '{$last_month}'\n                AND `aggregate` <= IF (`period` <= '{$last_year}', '{$avg_agg}', '{$std_agg}')\n              ORDER BY `period` LIMIT 1;";
     $oldest_from = $ds->loadResult($query);
     if (!$oldest_from) {
         CAppUI::setMsg("No log to aggregate", UI_MSG_OK);
         return;
     }
     // Take the 1 month period to aggregate
     $oldest_to = min(CMbDT::transform("+ 1 MONTH", $oldest_from, "%Y-%m-%d 00:00:00"), $last_month);
     // Dry run mode, just compute the number of logs to aggregate
     if ($dry_run) {
         // Récupération des IDs de journaux à supprimer
         $query = "SELECT count(`accesslog_id`) AS count\n                FROM {$table}\n                WHERE `period` BETWEEN '{$oldest_from}' AND '{$oldest_to}'\n                   AND `aggregate` <= IF (`period` <= '{$last_year}', '{$avg_agg}', '{$std_agg}');";
         $count = $ds->loadResult($query);
         $msg = "%d access logs to aggregate from %s to %s";
         CAppUI::setMsg($msg, UI_MSG_OK, $count, CMbDT::date($oldest_from), CMbDT::date($oldest_to));
         return;
     }
     // Récupération des IDs de journaux à agréger à l'heure
     $query = "SELECT\n                CAST(GROUP_CONCAT(`accesslog_id` SEPARATOR ',') AS CHAR) AS ids,\n                `module_action_id`,\n                `period`,\n                `bot`\n              FROM {$table}\n              WHERE `period` BETWEEN '{$oldest_from}' AND '{$oldest_to}'\n                AND `period` <= '{$last_month}'\n                AND `period`  > '{$last_year}'\n                AND `aggregate` < '{$avg_agg}'\n              GROUP BY `module_action_id`, date_format(`period`, '%Y-%m-%d %H:00:00'), `bot`";
     $month_IDs_to_aggregate = $ds->loadList($query);
     if ($month_IDs_to_aggregate) {
         foreach ($month_IDs_to_aggregate as $_aggregate) {
             $query = "INSERT INTO `access_log_archive` (\n                    `module_action_id`,\n                    `period`,\n                    `aggregate`,\n                    `bot`,\n                    `hits`,\n                    `duration`,\n                    `request`,\n                    `nb_requests`,\n                    `size`,\n                    `errors`,\n                    `warnings`,\n                    `notices`,\n                    `processus`,\n                    `processor`,\n                    `peak_memory`\n                  )\n                  SELECT\n                    `module_action_id`,\n                    date_format(`period`, '%Y-%m-%d %H:00:00'),\n                    '{$avg_agg}',\n                    `bot`,\n                    @hits        := SUM(`hits`),\n                    @duration    := SUM(`duration`),\n                    @request     := SUM(`request`),\n                    @nb_requests := SUM(`nb_requests`),\n                    @size        := SUM(`size`),\n                    @errors      := SUM(`errors`),\n                    @warnings    := SUM(`warnings`),\n                    @notices     := SUM(`notices`),\n                    @processus   := SUM(`processus`),\n                    @processor   := SUM(`processor`),\n                    @peak_memory := SUM(`peak_memory`)\n                  FROM {$table}\n                  WHERE `accesslog_id` IN (" . $_aggregate['ids'] . ")\n                  GROUP BY `module_action_id`, DATE_FORMAT(`period`, '%Y-%m-%d %H:00:00'), `bot`\n                  ON DUPLICATE KEY UPDATE\n                    `hits`        = `hits`        + @hits,\n                    `duration`    = `duration`    + @duration,\n                    `request`     = `request`     + @request,\n                    `nb_requests` = `nb_requests` + @nb_requests,\n                    `size`        = `size`        + @size,\n                    `errors`      = `errors`      + @errors,\n                    `warnings`    = `warnings`    + @warnings,\n                    `notices`     = `notices`     + @notices,\n                    `processus`   = `processus`   + @processus,\n                    `processor`   = `processor`   + @processor,\n                    `peak_memory` = `peak_memory` + @peak_memory";
             if (!$ds->exec($query)) {
                 CAppUI::setMsg("Failed to insert aggregated access logs", UI_MSG_ERROR);
                 return;
             }
             // Delete previous logs
             $query = "DELETE\n                  FROM {$table}\n                  WHERE `accesslog_id` IN (" . $_aggregate['ids'] . ")";
             $ds->exec($query);
         }
     }
     // Récupération des IDs de journaux à agréger à la journée
     $query = "SELECT\n                CAST(GROUP_CONCAT(`accesslog_id` SEPARATOR ',') AS CHAR) AS ids,\n                `module_action_id`,\n                `period`,\n                `bot`\n              FROM {$table}\n              WHERE `period` BETWEEN '{$oldest_from}' AND '{$oldest_to}'\n                AND `period` <= '{$last_year}'\n                AND `aggregate` < '{$sup_agg}'\n              GROUP BY `module_action_id`, date_format(`period`, '%Y-%m-%d 00:00:00'), `bot`";
     $year_IDs_to_aggregate = $ds->loadList($query);
     if ($year_IDs_to_aggregate) {
         foreach ($year_IDs_to_aggregate as $_aggregate) {
             $query = "INSERT INTO `access_log_archive` (\n                    `module_action_id`,\n                    `period`,\n                    `aggregate`,\n                    `bot`,\n                    `hits`,\n                    `duration`,\n                    `request`,\n                    `nb_requests`,\n                    `size`,\n                    `errors`,\n                    `warnings`,\n                    `notices`,\n                    `processus`,\n                    `processor`,\n                    `peak_memory`\n                  )\n                  SELECT\n                    `module_action_id`,\n                    date_format(`period`, '%Y-%m-%d 00:00:00'),\n                    '{$sup_agg}',\n                    `bot`,\n                    @hits        := SUM(`hits`),\n                    @duration    := SUM(`duration`),\n                    @request     := SUM(`request`),\n                    @nb_requests := SUM(`nb_requests`),\n                    @size        := SUM(`size`),\n                    @errors      := SUM(`errors`),\n                    @warnings    := SUM(`warnings`),\n                    @notices     := SUM(`notices`),\n                    @processus   := SUM(`processus`),\n                    @processor   := SUM(`processor`),\n                    @peak_memory := SUM(`peak_memory`)\n                  FROM {$table}\n                  WHERE `accesslog_id` IN (" . $_aggregate['ids'] . ")\n                  GROUP BY `module_action_id`, DATE_FORMAT(`period`, '%Y-%m-%d 00:00:00'), `bot`\n                  ON DUPLICATE KEY UPDATE\n                    `hits`        = `hits`        + @hits,\n                    `duration`    = `duration`    + @duration,\n                    `request`     = `request`     + @request,\n                    `nb_requests` = `nb_requests` + @nb_requests,\n                    `size`        = `size`        + @size,\n                    `errors`      = `errors`      + @errors,\n                    `warnings`    = `warnings`    + @warnings,\n                    `notices`     = `notices`     + @notices,\n                    `processus`   = `processus`   + @processus,\n                    `processor`   = `processor`   + @processor,\n                    `peak_memory` = `peak_memory` + @peak_memory";
             if (!$ds->exec($query)) {
                 CAppUI::setMsg("Failed to insert aggregated access logs", UI_MSG_ERROR);
                 return;
             }
             // Delete previous logs
             $query = "DELETE\n                  FROM {$table}\n                  WHERE `accesslog_id` IN (" . $_aggregate['ids'] . ")";
             $ds->exec($query);
         }
     }
     $IDs_to_aggregate = array_merge($year_IDs_to_aggregate, $month_IDs_to_aggregate);
     $msg = "%d access logs inserted from %s to %s";
     CAppUI::setMsg($msg, UI_MSG_OK, count($IDs_to_aggregate), CMbDT::date($oldest_from), CMbDT::date($oldest_to));
 }
Exemplo n.º 19
0
<?php

/**
 * $Id: $
 *
 * @package    Mediboard
 * @subpackage Stats
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision: 19288 $
 */
CCanDo::read();
$year = CValue::get("year", CMbDT::transform(null, null, "%Y"));
$type = CValue::get("type", "traitant");
CView::enforceSlave();
$group_id = CGroups::loadCurrent()->_id;
// Compteur d'années
$years = array();
for ($_year = 1980; $_year <= 2030; $_year++) {
    $years[] = $_year;
}
// En utilisant les médecins adressant le séjour
$queryAdresse = "SELECT\n                   COUNT(DISTINCT(`sejour`.`sejour_id`)) AS total,\n                   `medecin`.`nom`, `medecin`.`prenom`, `medecin`.`adresse`, `medecin`.`ville`, `medecin`.`cp`\n                 FROM `sejour`\n                 LEFT JOIN `medecin`\n                   ON `medecin`.`medecin_id` = `sejour`.`adresse_par_prat_id`\n                 WHERE `sejour`.`entree` BETWEEN '{$year}-01-01' AND '{$year}-12-31'\n                   AND `sejour`.`group_id` = '{$group_id}'\n                 GROUP BY `sejour`.`adresse_par_prat_id`\n                 ORDER BY total DESC";
// En utilisant le médecin traitant
$queryTraitant = "SELECT\n                    COUNT(DISTINCT(`sejour`.`sejour_id`)) AS total,\n                    `medecin`.`nom`, `medecin`.`prenom`, `medecin`.`adresse`, `medecin`.`ville`, `medecin`.`cp`\n                  FROM `sejour`\n                  LEFT JOIN `patients`\n                    ON `patients`.`patient_id` = `sejour`.`patient_id`\n                  LEFT JOIN `medecin`\n                    ON `medecin`.`medecin_id` = `patients`.`medecin_traitant`\n                  WHERE `sejour`.`entree` BETWEEN '{$year}-01-01' AND '{$year}-12-31'\n                    AND `sejour`.`group_id` = '{$group_id}'\n                  GROUP BY `patients`.`medecin_traitant`\n                  ORDER BY total DESC";
// En utilisant l'adresse du patient
$baseINSEE = CSQLDataSource::get("INSEE")->config["dbname"];
$queryPatient = "SELECT\n                    COUNT(DISTINCT(`sejour`.`sejour_id`)) AS total,\n                    `{$baseINSEE}`.`communes_france`.`commune` AS ville, `patients`.`cp`\n                  FROM `sejour`\n                  LEFT JOIN `patients`\n                    ON `patients`.`patient_id` = `sejour`.`patient_id`\n                  LEFT JOIN `{$baseINSEE}`.`communes_france`\n                    ON `{$baseINSEE}`.`communes_france`.`code_postal` = `patients`.`cp`\n                  WHERE `sejour`.`entree` BETWEEN '{$year}-01-01' AND '{$year}-12-31'\n                    AND `sejour`.`group_id` = '{$group_id}'\n                  GROUP BY `patients`.`cp`\n                  ORDER BY total DESC";
$source = CSQLDataSource::get("std");
$listResult = array();
switch ($type) {
Exemplo n.º 20
0
 /**
  * Compute stock balance
  *
  * @param CProduct[] $products Products
  * @param CService[] $services Services
  * @param int        $year     Year
  * @param int        $month    Month
  *
  * @return array
  */
 static function computeBalance(array $products, array $services, $year, $month = null)
 {
     $flows = array();
     // YEAR //////////
     $year_flows = array("in" => array(), "out" => array());
     $start = CMbDT::date(null, "{$year}-01-01");
     self::fillFlow($year_flows, $products, 12, $start, "MONTH", $services);
     $flows["year"] = array($year_flows, "%b", "Bilan annuel", "graph" => self::getFlowGraph($year_flows, "Bilan annuel", $services));
     // MONTH //////////
     if ($month) {
         $month_flows = array("in" => array(), "out" => array());
         $start = CMbDT::date(null, "{$year}-{$month}-01");
         self::fillFlow($month_flows, $products, CMbDT::transform("+1 MONTH -1 DAY", $start, "%d"), $start, "DAY", $services);
         $flows["month"] = array($month_flows, "%d", "Bilan mensuel", "graph" => self::getFlowGraph($month_flows, "Bilan mensuel", $services));
     }
     // Balance des stocks ////////////////
     $balance = array("in" => $flows["year"][0]["in"], "out" => array(), "diff" => array());
     $start = CMbDT::date(null, "{$year}-01-01");
     for ($i = 0; $i < 12; $i++) {
         $from = CMbDT::date("+{$i} MONTH", $start);
         $to = CMbDT::date("+1 MONTH", $from);
         $balance["in"][$from] = array(0, 0);
         $balance["out"][$from] = array(0, 0);
         $supply_multiple = self::getSupplyMultiple($products, $from, $to);
         $consum_multiple = self::getConsumptionMultipleProducts($products, $from, $to, null, false);
         /** @var CProduct $_product */
         foreach ($products as $_product) {
             $supply = CValue::read($supply_multiple, $_product->_id, 0);
             //$supply = $_product->getSupply($from, $to);
             $consum = CValue::read($consum_multiple, $_product->_id, 0);
             //$consum = $_product->getConsumption($from, $to, null, false);
             $coeff = 1;
             $ref = reset($_product->loadRefsReferences(true));
             if ($ref) {
                 $coeff = $ref->price;
             }
             $balance["in"][$from][0] += $supply;
             $balance["in"][$from][1] += $supply * $coeff;
             $balance["out"][$from][0] += $consum;
             $balance["out"][$from][1] += $consum * $coeff;
         }
     }
     $cumul = 0;
     $cumul_price = 0;
     foreach ($balance["in"] as $_date => $_balance) {
         $diff = $balance["in"][$_date][0] - $balance["out"][$_date][0];
         $diff_price = $balance["in"][$_date][1] - $balance["out"][$_date][1];
         $balance["diff"][$_date][0] = $diff + $cumul;
         $balance["diff"][$_date][1] = $diff_price + $cumul_price;
         $cumul += $diff;
         $cumul_price += $diff_price;
     }
     $balance = array_map_recursive(array("CProduct", "round2"), $balance);
     $options = CFlotrGraph::merge("bars", array("title" => "Rotation des stocks", "legend" => array("show" => true), "xaxis" => array("ticks" => array()), "yaxis" => array("min" => null, "title" => utf8_encode("Valeur (euro)")), "y2axis" => array("min" => null)));
     $graph = array("data" => array(), "options" => $options);
     $params = array("in" => array("label" => "Entrée", "color" => "#4DA74D"), "out" => array("label" => "Sortie", "color" => "#CB4B4B"), "diff" => array("label" => "Cumul", "color" => "#00A8F0"));
     foreach ($balance as $_type => $_data) {
         $data = array("data" => array(), "label" => utf8_encode($params[$_type]["label"]), "color" => $params[$_type]["color"]);
         if ($_type == "diff") {
             $data["lines"]["show"] = true;
             $data["bars"]["show"] = false;
             $data["points"]["show"] = true;
             $data["mouse"]["track"] = true;
             //$data["yaxis"] = 2;
         }
         if (empty($graph["options"]["xaxis"]["ticks"])) {
             foreach ($_data as $_date => $_values) {
                 if ($_date == "total") {
                     continue;
                 }
                 $graph["options"]["xaxis"]["ticks"][] = array(count($graph["options"]["xaxis"]["ticks"]), $_date);
             }
         }
         foreach ($_data as $_date => $_values) {
             if ($_date == "total") {
                 continue;
             }
             $v = $_type === "out" ? -$_values[1] : $_values[1];
             $data["data"][] = array(count($data["data"]), $v);
         }
         $graph["data"][] = $data;
     }
     $balance["graph"] = $graph;
     return array($flows, $balance, "flows" => $flows, "balance" => $balance);
 }
 /**
  * Create a NGAP acte
  *
  * @param String[]  $data         Data with fiel and value
  * @param CMbObject $object       Reference object
  * @param String    $praticien_id Praticen id
  *
  * @return CActeNGAP
  */
 function createActeNGAP($data, $object, $praticien_id)
 {
     $ngap = new CActeNGAP();
     $ngap->code = $data["code"];
     $ngap->coefficient = $data["coefficient"];
     $ngap->quantite = $data["quantite"] ? $data["quantite"] : 1;
     $ngap->numero_dent = $data["numero_dent"];
     $ngap->comment = $data["comment"];
     $ngap->montant_depassement = $data["montantDepassement"];
     $ngap->numero_forfait_technique = $data["numeroForfaitTechnique"];
     $ngap->numero_agrement = $data["numeroAgrementAppareil"];
     $ngap->minor_coef = $data["minor_coef"];
     $ngap->minor_pct = $data["minor_pct"];
     $ngap->major_coef = $data["major_coef"];
     $ngap->major_pct = $data["major_pct"];
     $ngap->facturable = $data["facturable"] ? $data["facturable"] == "non" ? "0" : "1" : "1";
     $ngap->rapport_exoneration = $data["rapportExoneration"];
     $date = $data["date"];
     $heure = $data["heure"];
     if (!$heure) {
         $heure = $this->getHourWithObject($object);
     } else {
         $heure = CMbDT::transform(null, $heure, "%H:%M:%S");
     }
     $ngap->execution = "{$date} {$heure}";
     $complement = null;
     if ($data["executionNuit"] && $data["executionNuit"] !== "non") {
         $complement = "N";
     }
     if ($data["executionDimancheJourFerie"] && $data["executionDimancheJourFerie"] !== "non") {
         $complement = "F";
     }
     $ngap->complement = $complement;
     $ngap->setObject($object);
     $ngap->executant_id = $praticien_id;
     return $ngap;
 }
Exemplo n.º 22
0
 /**
  * @see parent::updateFormFields()
  */
 function updateFormFields()
 {
     parent::updateFormFields();
     $this->_view = sprintf("Plage du %s de %s à %s", CMbDT::transform($this->date, null, CAppUI::conf("date")), CMbDT::transform($this->debut, null, CAppUI::conf("time")), CMbDT::transform($this->fin, null, CAppUI::conf("time")));
 }
Exemplo n.º 23
0
 /**
  * constructor
  *
  * @param string $date current date in the planning
  */
 function __construct($date)
 {
     $this->date = $date;
     $this->_hours = $this->hours;
     //load nonworking days
     $this->loadHolidays();
     //the current day is loaded
     $this->_ref_day = new CMbDay($date);
     //list of days in the current year
     $year = CMbDT::transform("", $date, "%Y");
     $day = CMbDT::date("last Monday", "{$year}-01-01");
     while ($day != CMbDT::date("next Monday", "{$year}-12-31")) {
         $this->year_day_list[$day] = new CMbDay($day);
         $day = CMbDT::date("+1 DAY", $day);
     }
     $this->no_dates = 0;
 }
Exemplo n.º 24
0
 /**
  * Edition de la liste de contrôle
  *
  * @return void
  */
 function editCheckList()
 {
     $colonnes = array("Nom" => 20, "Prenom" => 20, "Dossier" => 25, "Type" => 15, "Entree" => 15, "Sortie" => 15, "Statut" => 20, "Montant" => 25);
     $this->editTableau($colonnes, 5, 25);
     $debut_lignes = 30;
     $ligne = 0;
     $montant_total = 0;
     foreach ($this->factures as $facture) {
         $this->pdf->setX(5);
         $ligne++;
         $valeurs = array("Nom" => $facture->_ref_patient->nom, "Prenom" => $facture->_ref_patient->prenom, "Dossier" => $facture->_view . " " . $facture->_ref_last_sejour->type, "Type" => $facture->type_facture, "Entree" => CMbDT::transform("", $facture->_ref_last_sejour->entree_prevue, '%d/%m/%Y'), "Sortie" => CMbDT::transform("", $facture->_ref_last_sejour->sortie_prevue, '%d/%m/%Y'), "Statut" => $facture->envoi_xml ? "Facture électronique" : "", "Montant" => sprintf("%.2f", $facture->_montant_avec_remise));
         $x = 0;
         foreach ($colonnes as $key => $value) {
             $cote = $key == "Montant" ? "R" : "L";
             $this->editCell($this->pdf->getX() + $x, $debut_lignes + $ligne * 4, $value, $valeurs[$key], $cote);
             $x = $value;
         }
         if ($debut_lignes + $ligne * 4 >= 200) {
             $ligne = $this->ajoutPage($colonnes);
         }
         $montant_total += $facture->_montant_avec_remise;
     }
     $ligne += 2;
     $pos_ligne = $debut_lignes + $ligne * 4;
     $this->editCell(180, $pos_ligne, 80, "Montant total:", "R");
     $this->editCell(210, $pos_ligne, 80, $montant_total, "R");
 }
Exemplo n.º 25
0
}
$where = array();
$where["entree"] = "<= '" . CMbDT::dateTime() . "'";
$where["sortie"] = ">= '" . CMbDT::dateTime() . "'";
$where["function_id"] = "IS NOT NULL";
$affectation = new CAffectation();
/** @var CAffectation[] $blocages_lit */
$blocages_lit = $affectation->loadList($where);
$where["function_id"] = "IS NULL";
foreach ($blocages_lit as $blocage) {
    $blocage->loadRefLit()->loadRefChambre()->loadRefService();
    $where["lit_id"] = "= '{$blocage->lit_id}'";
    if ($affectation->loadObject($where)) {
        $sejour = $affectation->loadRefSejour();
        $patient = $sejour->loadRefPatient();
        $blocage->_ref_lit->_view .= " indisponible jusqu'à " . CMbDT::transform($affectation->sortie, null, "%Hh%Mmin %d-%m-%Y");
        $blocage->_ref_lit->_view .= " (" . $patient->_view . " (" . strtoupper($patient->sexe) . ") ";
        $blocage->_ref_lit->_view .= CAppUI::conf("dPurgences age_patient_rpu_view") ? $patient->_age . ")" : ")";
    }
}
// Tableau de contraintes pour les champs du RPU
// Contraintes sur le mode d'entree / provenance
//$contrainteProvenance[6] = array("", 1, 2, 3, 4);
$contrainteProvenance[7] = array("", 1, 2, 3, 4);
$contrainteProvenance[8] = array("", 5, 8);
// Contraintes sur le mode de sortie / destination
$contrainteDestination["mutation"] = array("", 1, 2, 3, 4);
$contrainteDestination["transfert"] = array("", 1, 2, 3, 4);
$contrainteDestination["normal"] = array("", 6, 7);
// Contraintes sur le mode de sortie / orientation
$contrainteOrientation["mutation"] = array("", "HDT", "HO", "SC", "SI", "REA", "UHCD", "MED", "CHIR", "OBST");
Exemplo n.º 26
0
/**
 * 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);
}
/**
 * Calcul le taux d'utilisation de prise de rendez-vous par créneaux de 5 minutes
 *
 * @param CPlageconsult[] $plages Plages
 * @param array           $list   Liste
 * @param CPlageconsult   $plage  Plage
 *
 * @return array
 */
function utilisation_rdv($plages, $list, $plage)
{
    $utilisation = array();
    // Granularité de 5 minutes.
    // 288 créneaux de 5 minutes dans 24 heures
    for ($i = 0; $i < 288; $i++) {
        $time = CMbDT::time($i * 5 . " minutes", $plage->debut);
        $utilisation[$time] = 0;
        if ($time == $plage->fin) {
            break;
        }
    }
    foreach ($plages as $_plage) {
        $rdvs = $_plage->loadRefsConsultations(false);
        $freq = CMbDT::transform($_plage->freq, null, "%M");
        foreach ($rdvs as $_rdv) {
            $nb_cases = $_rdv->duree * $freq / 5;
            for ($i = 0; $i < $nb_cases; $i++) {
                $time = CMbDT::time($i * 5 . " minutes", $_rdv->heure);
                if (!isset($utilisation[$time])) {
                    continue;
                }
                $utilisation[$time]++;
            }
        }
    }
    ksort($utilisation);
    // Granularité à la fréquence des consultations de la plage
    $creneaux = array_flip(CMbArray::pluck($list, "time"));
    $save_key = 0;
    foreach ($utilisation as $key => $_util) {
        if (!isset($creneaux[$key]) && isset($utilisation[$save_key])) {
            $utilisation[$save_key] = max($_util, $utilisation[$save_key]);
            unset($utilisation[$key]);
        } else {
            $utilisation[$key] = $_util;
            $save_key = $key;
        }
    }
    return $utilisation;
}
Exemplo n.º 28
0
 *  
 * @category Maternite
 * @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
 */
$date = CValue::getOrSession("date", CMbDT::date());
$view = CValue::getOrSession("view", "all");
$ds = CSQLDataSource::get("std");
$group = CGroups::loadCurrent();
$bank_holidays = CMbDate::getHolidays($date);
$next = CMbDT::date("+1 DAY", $date);
$month_min = CMbDT::transform("+ 0 month", $date, "%Y-%m-01");
$month_max = CMbDT::transform("+ 1 month", $month_min, "%Y-%m-01");
$prev_month = CMbDT::date("-1 month", $date);
$next_month = CMbDT::date("+1 month", $date);
$date_before = CMbDT::date("-1 day", $date);
$date_after = CMbDT::date("+1 day", $date);
// Initialisation du tableau de jours
$days = array();
for ($day = $month_min; $day < $month_max; $day = CMbDT::date("+1 DAY", $day)) {
    $days[$day] = array("num1" => "0", "num2" => "0", "num3" => "0");
}
// Liste des admissions par jour
$query = "SELECT DATE_FORMAT(`sejour`.`entree`, '%Y-%m-%d') AS `date`, COUNT(`sejour`.`sejour_id`) AS `num`\n  FROM `sejour`\n  WHERE `sejour`.`entree` BETWEEN '{$month_min}' AND '{$month_max}'\n    AND `sejour`.`group_id` = '{$group->_id}'\n    AND `sejour`.`annule` = '0'\n    AND `sejour`.`type_pec` = 'O'\n  GROUP BY `date`\n  ORDER BY `date`";
foreach ($ds->loadHashList($query) as $day => $num1) {
    $days[$day]["num1"] = $num1;
}
// Liste des admissions non effectuées par jour
Exemplo n.º 29
0
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
CAppUI::requireLibraryFile("jpgraph/src/mbjpgraph");
CAppUI::requireLibraryFile("jpgraph/src/jpgraph_bar");
$debut = CValue::get("debut", CMbDT::date("-1 YEAR"));
$fin = CValue::get("fin", CMbDT::date());
$prat_id = CValue::get("prat_id", 0);
$service_id = CValue::get("service_id", 0);
$pratSel = new CMediusers();
$pratSel->load($prat_id);
$service = new CSalle();
$service->load($service_id);
$datax = array();
for ($i = $debut; $i <= $fin; $i = CMbDT::date("+1 MONTH", $i)) {
    $datax[] = CMbDT::transform("+0 DAY", $i, "%m/%Y");
}
$sql = "SELECT * FROM service WHERE";
if ($service_id) {
    $sql .= "\nAND id = '{$service_id}'";
}
$ds = CSQLDataSource::get("std");
$services = $ds->loadlist($sql);
$opbysalle = array();
foreach ($services as $service) {
    $id = $service["service_id"];
    $opbysalle[$id]["nom"] = $salle["nom"];
    $sql = "SELECT COUNT(sejour.sejour_id) AS total," . "\nDATE_FORMAT(sejour.entree_prevue, '%m/%Y') AS mois," . "\nDATE_FORMAT(sejour.entre_prevue, '%Y%m') AS orderitem," . "\nservice.nom AS nom" . "\nFROM sejour, affectation, services, chambre, lit" . "\nWHERE sejour.annule = '0'" . "\nAND sejour.entree_prevue BETWEEN '{$debut}' AND '{$fin}'";
    if ($prat_id) {
        $sql .= "\nAND sejour.praticien_id = '{$prat_id}'";
    }
Exemplo n.º 30
0
/**
 * $Id: vw_hospitalisation.php 21751 2014-01-23 09:55:17Z rhum1 $
 *
 * @package    Mediboard
 * @subpackage dPstats
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision: 21751 $
 */
CCanDo::checkRead();
$filter = new CSejour();
$filter->_date_min = CValue::get("_date_min", CMbDT::date("-1 YEAR"));
$rectif = CMbDT::transform("+0 DAY", $filter->_date_min, "%d") - 1;
$filter->_date_min = CMbDT::date("-{$rectif} DAYS", $filter->_date_min);
$filter->_date_max = CValue::get("_date_max", CMbDT::date());
$rectif = CMbDT::transform("+0 DAY", $filter->_date_max, "%d") - 1;
$filter->_date_max = CMbDT::date("-{$rectif} DAYS", $filter->_date_max);
$filter->_date_max = CMbDT::date("+ 1 MONTH", $filter->_date_max);
$filter->_date_max = CMbDT::date("-1 DAY", $filter->_date_max);
$filter->_service = CValue::get("service_id", 0);
$filter->type = CValue::get("type", 1);
$filter->praticien_id = CValue::get("prat_id", 0);
$filter->_specialite = CValue::get("discipline_id", 0);
$filter->septique = CValue::get("septique", 0);
$type_data = CValue::get("type_data", "prevue");
$user = new CMediusers();
$listPrats = $user->loadPraticiens(PERM_READ);
$service = new CService();
$where = array();
$where["cancelled"] = "= '0'";
$listServices = $service->loadGroupList($where);