$whereObs = $where;
$whereObs["date"] = "BETWEEN '{$datetime_delta}' AND '{$datetime_avg}'";
$observations = $observation->loadList($whereObs, "date");
CStoredObject::massLoadFwdRef($observations, "user_id");
// Consultations
$consultation = new CConsultation();
$whereConsult = $where;
$whereConsult["plageconsult.date"] = "BETWEEN '{$datetime_delta}' AND '{$datetime_avg}'";
$ljoin = array("plageconsult" => "plageconsult.plageconsult_id = consultation.plageconsult_id");
$consultations = $consultation->loadList($whereConsult, "plageconsult.date", null, null, $ljoin);
CStoredObject::massLoadFwdRef($consultations, "plageconsult_id");
$smarty_cstes = new CSmartyDP("modules/dPpatients");
$smarty_cstes->assign("empty_lines", 2);
$smarty_cstes->assign("offline", 1);
// Constantes des 12 dernières heures
$where_cste = array("datetime" => "BETWEEN '" . CMbDT::subDateTime("12:00:00", $datetime_avg) . "' AND '{$datetime_avg}'");
CPrescriptionLine::$_offline_lite = true;
CPrescriptionLineMix::$_offline_lite = true;
CPrescription::$_offline_lite = true;
foreach ($sejours as $_sejour) {
    $patient = $_sejour->loadRefPatient();
    $_sejour->loadRefPraticien();
    $_sejour->loadJourOp($date);
    if ($service_id == "urgence") {
        $_sejour->_veille = CMbDT::date($_sejour->entree) != $date;
        $_sejour->loadRefRPU()->loadRefIDEResponsable();
    }
    $patients_offline[$patient->_guid]["sejour"] = $_sejour;
    // Transmissions
    $patients_offline[$patient->_guid]["transmissions"] = array();
    // Regroupement par cible