$sejour->_ref_consult_anesth->_ref_consultation->loadRefsDocItems(false);
    $sejour->_ref_consult_anesth->loadRefsDocItems(false);
}
// Chargement du patient
$patient = $sejour->loadRefPatient();
$patient->loadComplete();
$patient->loadIPP();
// Chargement du dossier medical
$dossier_medical = $patient->_ref_dossier_medical;
$dossier_medical->canRead();
$dossier_medical->countAntecedents();
$dossier = array();
$list_lines = array();
if (CModule::getActive("dPprescription")) {
    // Chargement du dossier de soins cloturé
    $prescription = $sejour->loadRefPrescriptionSejour();
    // Chargement des lignes
    $prescription->loadRefsLinesMedComments("1", "1", "1", "", "", "0", "1");
    $prescription->loadRefsLinesElementsComments("1");
    $prescription->loadRefsPrescriptionLineMixes("", "1");
    $prescription->loadRefsLinesInscriptions();
    $where = array();
    $where["planification"] = " = '0'";
    if ($datetime_min) {
        $where["dateTime"] = " >= '{$datetime_min}'";
    }
    if (count($prescription->_ref_prescription_line_mixes)) {
        foreach ($prescription->_ref_prescription_line_mixes as $_prescription_line_mix) {
            $_prescription_line_mix->loadRefsLines();
            $_prescription_line_mix->calculQuantiteTotal();
            $_prescription_line_mix->loadRefPraticien();
$sejour = new CSejour();
$sejour->load($sejour_id);
// Chargement de la prescription de sejour
$sejour->loadRefPrescriptionSejour();
// Verification que la prescription est vide
if ($sejour->_ref_prescription_sejour->countBackRefs("prescription_line_element")) {
    CAppUI::setMsg("Impossible de dupliquer l'ancien séjour car ce séjour possède déjà une prescription", UI_MSG_WARNING);
    CAppUI::redirect('m=ssr&tab=vw_aed_sejour_ssr&sejour_id=' . $sejour_id);
}
// Chargement du sejour à dupliquer
$original_sejour = new CSejour();
$original_sejour->load($original_sejour_id);
// Chargement des references: bilan, fiche d'autonomie, prescriptions, evenements
$bilan_ssr = $original_sejour->loadRefBilanSSR();
$fiche_autonomie = $original_sejour->loadRefFicheAutonomie();
$prescription_sejour = $original_sejour->loadRefPrescriptionSejour();
$lines_element = $prescription_sejour->loadRefsLinesElement();
// Chargement evenements de la derniere semaine complete
$original_last_friday = CMbDT::date("last friday", CMbDT::date("+ 1 DAY", $original_sejour->sortie));
$monday = CMbDT::date("last monday", $original_last_friday);
$next_monday = CMbDT::date("next monday", $monday);
// 1er vendredi du nouveau sejour
$next_friday = CMbDT::date("next friday", CMbDT::date("- 1 DAY", $sejour->entree));
// Calcul du nombre de decalage entre les 2 sejours
$nb_decalage = CMbDT::daysRelative($original_last_friday, $next_friday);
$evenement_ssr = new CEvenementSSR();
$where = array();
$where["sejour_id"] = " = '{$original_sejour->_id}'";
$where["debut"] = " BETWEEN '{$monday}' AND '{$next_monday}'";
/** @var CEvenementSSR[] $evenements */
$evenements = $evenement_ssr->loadList($where);