$fileappend = "&dept_nr={$dept_nr}&edit={$edit}&mode=&pday={$pday}&pmonth={$pmonth}&pyear={$pyear}&station={$station}";
$breakfile = "location:amb_clinic_patients.php" . URL_APPEND . $fileappend;
$forwardfile = "location:amb_clinic_patients.php" . URL_REDIRECT_APPEND . $fileappend;
# Create ward object
require_once $root_path . 'include/care_api_classes/class_encounter.php';
$enc_obj = new Encounter();
if (isset($mode) && $mode == 'transferdept') {
    $date = date('Y-m-d');
    $time = date('H:i:s');
    # first discharge from current dept
    //echo "discharing patient $pn<br>";
    if ($enc_obj->DischargeFromDept($pn, 8, $date, $time)) {
        # discharge type nr 8 = change of department
        # Now we set new dept
        //echo "Patient dischared!<br> Now  $pn going to $tgt_nr  ";
        if ($enc_obj->setCurrentDept($pn, $tgt_nr)) {
            header($forwardfile);
            exit;
        }
        //echo "setCurrentDept person failed<br>";exit();
    }
} else {
    header($forwardfile);
    exit;
}
?>
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.0//EN" "html.dtd">
<?php 
html_rtl($lang);
?>
<HEAD>