private void StartAppointment()
        {
            DataTable CheckedInPatients = PatientDBConverter.GetCheckedInAppointments();

            if (CheckedInPatients.Rows.Count == 0)
            {
                Alert("No avaliable appointments.", "No patients are checked in. There are no appointments avalaible to be seen.");
                return;
            }

            int averageDuration         = AppointmentLogic.GetAverage();
            int remainingShiftInMinutes = StaffDBConverter.GetRemainingShiftInMinutes(DoctorID);

            if (remainingShiftInMinutes < averageDuration)
            {
                if (Confirmation("Are you sure?", "There may not be enough time in your schedule to finish the next appointment. Are you sure you would like to proceed?") == "NO")
                {
                    return;
                }
            }

            DataRow selectedAppointment = null;

            // check if any patients are waiting first.

            if (Convert.ToBoolean(CheckedInPatients.Rows[0]["isEmergency"]) == true)
            {
                selectedAppointment = CheckedInPatients.Rows[0];
            }

            foreach (DataRow dr in CheckedInPatients.Rows)
            {
                if (selectedAppointment == null)
                {
                    if (Convert.ToBoolean(dr["isReservation"]) == false)
                    {
                        selectedAppointment = dr;
                    }
                    else if (Convert.ToBoolean(dr["isReservation"]) == true && DoctorID.Equals(int.Parse(dr["AppointmentDoctorID"].ToString())))
                    {
                        selectedAppointment = dr;
                    }
                }
                else
                {
                    TimeSpan selectedAppointmentTime = TimeSpan.Parse(selectedAppointment["AppointmentTime"].ToString());
                    TimeSpan drAppointmentTime       = TimeSpan.Parse(dr["AppointmentTime"].ToString());

                    if (drAppointmentTime.Subtract(selectedAppointmentTime).TotalMinutes <= 10 && (Convert.ToBoolean(dr["isReservation"]) == false))
                    {
                        selectedAppointment = dr;
                        break;
                    }
                }
            }

            PatientDBConverter.StartAppointment(selectedAppointment, DoctorID);
            MessengerInstance.Send <string>("DoctorAppointmentView");
        }
 public void InitialiseDataTable()
 {
     AllAppointments      = PatientDBConverter.GetCheckedInAppointments();
     FilteredAppointments = AllAppointments.Copy();
 }