//echo 'erfolgreich discharged';
     } else {
         echo 'DischargeFromDept failed.';
     }
     $forwardfile = "location:amb_clinic_patients.php" . URL_REDIRECT_APPEND . $fileappend;
     echo 'replace ward from station pn=' . $pn;
     if ($ward_obj->ReplaceWard($pn, $trwd, 2)) {
         //echo 'erfolgreich angemeldet.';
         header($forwardfile);
         exit;
     } else {
         echo 'ReplaceWard failed.';
     }
 } else {
     //transfer from ward to ward
     if ($ward_obj->DischargeFromWard($pn, $dis_type, $date, $time)) {
         switch ($mode) {
             case 'transferbed':
                 # Assign to ward,room and bed
                 if ($ward_obj->AdmitInWard($pn, $ward_nr, $rm, $bd)) {
                     //echo "ok";
                     $ward_obj->setAdmittedInWard($pn, $ward_nr, $rm, $bd);
                     header($forwardfile);
                     exit;
                 }
                 break;
             case 'transferward':
                 if ($ward_obj->ReplaceWard($pn, $trwd, 1)) {
                     header($forwardfile);
                     exit;
                 }