}
 //print_r($_POST);
 $encounter_obj->setDataArray($_POST);
 if ($encounter_obj->insertDataFromInternalArray()) {
     /* Get last insert id */
     if ($dbtype == 'mysql' || $dbtype == 'mysqli') {
         $encounter_nr = $db->Insert_ID();
     } else {
         $encounter_nr = $encounter_obj->postgre_Insert_ID($dbtable, 'encounter_nr', $db->Insert_ID());
     }
     // end of if($dbtype=='mysql')
     if ($is_transmit_to_weberp_enable == 1) {
         //											$weberp_obj = new weberp($webERPServerURL,$weberpuser,$weberppassword,$weberpDebugLevel);
         //											$weberp_obj->make_patient_workorder_in_webERP($encounter_nr);
     }
     $encounter_obj->assignInDept($encounter_nr, $current_dept_nr, $current_dept_nr);
     # If appointment number available, mark appointment as "done"
     if (isset($appt_nr) && $appt_nr) {
         $encounter_obj->markAppointmentDone($appt_nr, $_POST['encounter_class_nr'], $encounter_nr);
     }
     //echo $encounter_obj->getLastQuery();
     // Add to table presciptions the registration fee's comming from admission seciton...
     if ($registration_fee != '') {
         $bill_obj->new_reg($encounter_nr, $registration_fee, $user);
     }
     if ($consultation_fee != '') {
         $bill_obj->new_reg($encounter_nr, $consultation_fee, $user);
     }
     if (isset($transFromOutp)) {
         global $pn;
         $enc_new = $_POST['encounter_nr'];
            $dept = $dept_obj->FormalName($encounter['current_dept_nr']);
        } else {
            $dept = ${$pdept};
        }
    }
    # Set the foto filename
    $photo_filename = $encounter['photo_filename'];
    /* Prepare the photo filename */
    require_once $root_path . 'include/inc_photo_filename_resolve.php';
    # Get billing type
    $billing_type =& $enc_obj->getInsuranceClassInfo($encounter['insurance_class_nr']);
    $breakfile = 'javascript:window.close()';
    # Set default breakfile
} elseif ($mode == 'save') {
    # Save data
    if ($enc_obj->assignInDept($pn, $dept_nr, $dept_nr)) {
        //@$enc_obj->setInDept($pn);
        include $root_path . 'js/reloadparent_closewin.js';
    }
}
# Start Smarty templating here
/**
 * LOAD Smarty
 */
# Note: it is advisable to load this after the inc_front_chain_lang.php so
# that the smarty script can use the user configured template theme
require_once $root_path . 'gui/smarty_template/smarty_care.class.php';
$smarty = new smarty_care('nursing');
# Title in toolbar
$smarty->assign('sToolbarTitle', $LDAmbulant);
# hide back button