public void GetPatientIdIfExistsExistingUserTest() { // Act var result = patientData.GetPatientIdIfExists("9999977777"); // Assert Assert.AreEqual(result.ToString(), "23"); }
public ActionResult BookAppointment(AssistantsBookAppointmentViewModel model, string returnUrl) { if (Session["userId"] == null) { return(Redirect("~")); } if (model.SelectedTimeSlot > 0 && !string.IsNullOrEmpty(model.PatientPhoneNumber) && !string.IsNullOrEmpty(model.Details)) { Appointment appointment = model.ToAppointment(model); appointment.AppointmentTimeId = (byte)model.SelectedTimeSlot; var patientData = new PatientData(); int patientId = patientData.GetPatientIdIfExists(model.PatientPhoneNumber); //returns 0 if patient doesn't exist if ((int)Session["roleID"] == (int)Roles.Assistant) { if (patientId == 0) //returns 0 if patient doesn't exist { TempData["RegisterModel"] = model; return(RedirectToAction("RegisterPatient", "Assistant")); } else { appointment.PatientId = patientId; appointment.AppointmentStatusId = (byte)ClinicManagementSystemDOL.Enums.AppointmentStatus.Open; appointment.CreatedAt = DateTime.Now; try { if (new Appointments().AddAppointment(appointment)) { return(RedirectToAction("AppointmentList", "Assistant")); } else { return(View(model)); } } catch (Exception ex) { ModelState.AddModelError("", ex.Message); return(View(model)); } } } } return(View(model)); }
public ActionResult PopulateTimeSlot(TimeSlotViewModel model) { if (Session["userId"] == null) { return(Redirect("~")); } //model.Date = (DateTime)TempData["SelectedDateForAppointment"]; ScheduleBasedAppointmentManagement appointmentManagement = new ScheduleBasedAppointmentManagement(); var doctorAvailability = appointmentManagement.GetAvailability(model.DoctorId, model.Date); model.FromSlot = doctorAvailability.FromTime; model.ToSlot = doctorAvailability.ToTime; DoctorScheduleManagement doctorScheduleManagement = new DoctorScheduleManagement(); model.TimeSlots = new DoctorsData().GetDoctorAvailableTimeSlots(model.DoctorId, model.Date); var patientData = new PatientData(); int patientId = patientData.GetPatientIdIfExists(model.PatientPhone); model.RemoveExistingAppointmentSlots(patientId, model.Date); return(View(model)); }