Esempio n. 1
0
 // - Nombre de consultations
 $where = array();
 $consultation = new CConsultation();
 $ljoin["plageconsult"] = "consultation.plageconsult_id = plageconsult.plageconsult_id";
 $ljoin["users_mediboard"] = "plageconsult.chir_id = users_mediboard.user_id";
 $ljoin["functions_mediboard"] = "users_mediboard.function_id = functions_mediboard.function_id";
 $where["functions_mediboard.group_id"] = " = '{$current_group}'";
 $res_current_etab["CConsultation"] = $consultation->countList($where, null, $ljoin);
 // - Lits
 $ljoin = array();
 $where = array();
 $lit = new C**t();
 $ljoin["chambre"] = "lit.chambre_id = chambre.chambre_id";
 $ljoin["service"] = "chambre.service_id = service.service_id";
 $where["service.group_id"] = " = '{$current_group}'";
 $res_current_etab["C**t"] = $lit->countList($where, null, $ljoin);
 // - Chambres
 $ljoin = array();
 $where = array();
 $chambre = new CChambre();
 $ljoin["service"] = "chambre.service_id = service.service_id";
 $where["service.group_id"] = " = '{$current_group}'";
 $res_current_etab["CChambre"] = $chambre->countList($where, null, $ljoin);
 // - Utilisateurs
 $ljoin = array();
 $where = array();
 $mediuser = new CMediusers();
 $ljoin["functions_mediboard"] = "users_mediboard.function_id = functions_mediboard.function_id";
 $where["functions_mediboard.group_id"] = " = '{$current_group}'";
 $res_current_etab["CMediusers"] = $mediuser->countList($where, null, $ljoin);
 $smarty->assign("res_current_etab", $res_current_etab);
        // $datas["BOX"]++;
    }
}
//totaux
$lit = new C**t();
$where = array();
$ljoin = array();
$ljoin["chambre"] = "lit.chambre_id = chambre.chambre_id";
$ljoin["service"] = "service.service_id = chambre.service_id";
$where["service.externe"] = "= '0'";
$where["service.uhcd"] = "= '1'";
$where["service.group_id"] = " = '{$group->_id}'";
$where["lit.annule"] = " = '0'";
//uhcd
$totporte = CAppUI::conf("dPurgences send_RPU totporte", $group);
$datas["TOTPORTE"] = $totporte ? $totporte : $lit->countList($where, null, $ljoin);
//urgences
$where["service.uhcd"] = " IS NOT NULL";
$where["service.urgence"] = "= '1'";
$where["chambre.is_examination_room"] = " = '1'";
$totbox = CAppUI::conf("dPurgences send_RPU totbox", $group);
$datas["TOTBOX"] = $totbox ? $totbox : $lit->countList($where, null, $ljoin);
$where["chambre.is_examination_room"] = " IS NOT NULL";
$where["chambre.is_sas_dechoc"] = " = '1'";
$totdechoc = CAppUI::conf("dPurgences send_RPU totdechoc", $group);
$datas["TOTDECHOC"] = $totdechoc ? $totdechoc : $lit->countList($where, null, $ljoin);
// Appel de la fonction d'extraction du RPUSender
$rpuSender = $extractPassages->getRPUSender();
if (!$rpuSender) {
    CAppUI::stepAjax("Aucun sender définit dans le module dPurgences.", UI_MSG_ERROR);
}
$date_temp = $date_min;
$series = array();
while ($date_temp <= $date_max) {
    $dates[] = array(count($dates), CMbDT::dateToLocale($date_temp));
    $date_temp = CMbDT::date("+1 day", $date_temp);
}
// Table temporaraire de dates pour les jointures
$tab_name = CSQLDataSource::tempTableDates($date_min, $date_max);
// Nombre de lits totaux sur le service
$lit = new C**t();
$where = array();
$ljoin = array();
$ljoin["chambre"] = "chambre.chambre_id = lit.chambre_id";
$where["service_id"] = " = '{$service_id}'";
$where["lit.annule"] = " = '0'";
$nb_lits = $lit->countList($where, null, $ljoin);
if (!$nb_lits) {
    $smarty->display("inc_form_stats.tpl");
    CAppUI::stepMessage(UI_MSG_WARNING, "warning-hospi-stats-no_beds");
    return;
}
// Lits ouverts (non bloqués - non compris les blocages des urgence)
$serie = array("data" => array(), "label" => utf8_encode("Ouvert / Total"), "markers" => array("show" => true));
// Sauvegarde des lits ouverts par date
$lits_ouverts_par_date = array();
foreach ($dates as $key => $_date) {
    $date = CMbDT::dateFromLocale($_date[1]);
    $query = "SELECT count(DISTINCT l.lit_id) as lits_ouverts\n    FROM lit l\n    JOIN affectation a ON a.lit_id = l.lit_id AND\n    DATE_FORMAT(a.entree, '%Y-%m-%d') <= '{$date}' AND DATE_FORMAT(a.sortie, '%Y-%m-%d') >= '{$date}'\n    AND a.sejour_id != 0\n    LEFT JOIN chambre c ON c.chambre_id = l.chambre_id\n    WHERE  c.service_id = '{$service_id}'";
    $lits_ouverts = $ds->loadResult($query);
    $serie['data'][] = array(count($serie['data']) - 0.3, $lits_ouverts, $lits_ouverts / $nb_lits);
    $lits_ouverts_par_date[$date] = $lits_ouverts;