private void ReceiveLoginMessage(StaffUser userAccount) { if (userAccount.isReceptionist()) { string firstname = userAccount.getFirstname(); ViewModelLocator.Cleanup(); CurrentToolbarViewModel = ReceptionistToolbarVM; CurrentViewModel = ReceptionistVM; MessengerInstance.Send <NotificationMessage>(new NotificationMessage(firstname)); // FROM: MainVM TO: ReceptionistToolbarVM ~ sends logged in users first name. } else if (userAccount.isDoctor()) { UserID = StaffDBConverter.GetAccountIDByUsername(userAccount.getUsername()); CurrentToolbarViewModel = DoctorToolbarVM; if (PatientDBConverter.DoctorIsInAppointment(UserID)) { CurrentViewModel = DoctorAppointmentVM; MessengerInstance.Send <int>(UserID); } else { CurrentViewModel = DoctorVM; MessengerInstance.Send <int>(UserID); } } }
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 UpdateTimeslots() { AvaliableTimes = StaffDBConverter.GetAvaliableTimeslots(SelectedDate, RequestedDoctor, RequestedGender); if (AvaliableTimes.Rows.Count <= 0) { NoAvaliableTime = "No Avaliable Times."; } else { NoAvaliableTime = ""; } }
public ReservationAppointmentViewModel() { _dialogService = new DialogBoxService(); if (IsInDesignMode) { SelectedDate = DateTime.Parse("17/02/2000"); } else { if (DateTime.Today.Date.DayOfWeek == DayOfWeek.Friday) { SelectedDate = DateTime.Now.AddDays(3).Date; } else if (DateTime.Today.Date.DayOfWeek == DayOfWeek.Saturday) { SelectedDate = DateTime.Now.AddDays(2).Date; } else { SelectedDate = DateTime.Now.AddDays(1).Date; } } AvaliableTimes = StaffDBConverter.GetAvaliableTimeslots(SelectedDate, RequestedDoctor, RequestedGender); if (AvaliableTimes.Rows.Count <= 0) { NoAvaliableTime = "No Avaliable Times."; } else { NoAvaliableTime = ""; } MessengerInstance.Register <DateTime> ( this, (action) => UpdateTimeslots() ); MessengerInstance.Register <int>(this, UpdateTimeslotIndex); // When patientID message is received (from PatientDBConverter), set patient ID in VM. MessengerInstance.Register <double>(this, SetPatientID); BookAppointmentCommand = new RelayCommand(BookAppointment); }
private void SetUserLoggedIn(int id) { _userLoggedIn = StaffDBConverter.GetEmployeeNameByID(id); }
public void SetDoctorDetails(int msg) { DoctorID = msg; DoctorName = StaffDBConverter.GetEmployeeNameByID(DoctorID); }