// Plage de consultation selectionnée
$plageconsult_id = CValue::getOrSession("plageconsult_id", null);
$plageSel = new CPlageconsult();
if ($plageconsult_id === null && $chirSel && $is_in_period) {
    $nowTime = CMbDT::time();
    $where = array("chir_id = '{$chirSel}' OR remplacant_id = '{$chirSel}' OR pour_compte_id = '{$chirSel}'", "date" => "= '{$today}'", "debut" => "<= '{$nowTime}'", "fin" => ">= '{$nowTime}'");
    $plageSel->loadObject($where);
}
if (!$plageSel->plageconsult_id) {
    $plageSel->load($plageconsult_id);
} else {
    $plageconsult_id = $plageSel->plageconsult_id;
}
$plageSel->loadRefChir();
$plageSel->loadRefRemplacant();
$plageSel->loadRefPourCompte();
$plageSel->loadRefsNotes();
$plageSel->loadRefsBack($show_annulees, true, $show_payees);
if ($plageSel->_affected && count($plageSel->_ref_consultations)) {
    $firstconsult = reset($plageSel->_ref_consultations);
    $_firstconsult_time = substr($firstconsult->heure, 0, 5);
    $lastconsult = end($plageSel->_ref_consultations);
    $_lastconsult_time = substr($lastconsult->heure, 0, 5);
}
$consults = $plageSel->_ref_consultations;
CStoredObject::massLoadFwdRef($consults, "sejour_id");
$patients = CMbObject::massLoadFwdRef($consults, "patient_id");
CStoredObject::massCountBackRefs($patients, "notes");
CStoredObject::massLoadFwdRef($consults, "categorie_id");
// Détails sur les consultation affichées
foreach ($plageSel->_ref_consultations as $keyConsult => &$consultation) {