public async Task <IActionResult> PostAppointment(mp_appointment appointment) { // var email = _userManager.GetUserId(HttpContext.User); // var user = await _userManager.FindByEmailAsync(email); appointment.created_by = appointment.client_id.ToString(); _appointmentService.Add(appointment); return(Ok(appointment.id)); }
public AppointmentModel(mp_appointment appointment) { id = appointment.id; title = appointment.appointment_typeNavigation.name; doctor = new DoctorModel(appointment.clinician_); appointmentDate = appointment.start_date; member = new MemberModel(appointment.client_); service = appointment.appointment_serviceNavigation.name; duration = appointment.appointment_serviceNavigation.time_minutes; }
public void Update(mp_appointment appointment) { var old = _context.mp_appointment.FirstOrDefault(e => e.id == appointment.id); appointment.created_at = old.created_at; appointment.created_by = old.created_by; _context.Entry(old).CurrentValues.SetValues(appointment); _context.SaveChanges(); }
public Guid Add(mp_appointment appointment) { appointment.id = Guid.NewGuid(); appointment.created_by = "Self"; appointment.created_at = DateTime.Now; _context.mp_appointment.Add(appointment); _context.SaveChanges(); return(appointment.id); }
public string GetAppoinmentDetails(mp_appointment appointment) { var appointment_service = Options.GetAppointmentServices().FirstOrDefault(e => e.id == appointment.appointment_service); var appointment_details = "<strong>Date of appointment:</strong> " + appointment.start_date.ToString("dd MMM, yyyy hh:mm tt") + "<br/>"; appointment_details += "<strong>Appointment type: </strong>" + Options.GetAppointmentTypeName(appointment.appointment_type) + "<br/>"; appointment_details += "<strong>Appointment activity:</strong>" + Options.GetAppointmentSubActivityName(appointment.appointment_activity_sub_id) + "<br/>"; appointment_details += "<strong>Appointment service:</strong>" + appointment_service.name + "<br/>"; appointment_details += "<strong>Duration: </strong>" + appointment_service.time_minutes + " minutes <br/>"; return(appointment_details); }
private mp_profile GetAvailableClinician(mp_appointment appointment) { List <Guid> available_clinician_ids = _clinicianAvailabilityService.GetOtherCliniciansAvailabilityByDateRange(appointment).Select(e => e.clinician_id).ToList(); List <Guid> taken_slots = _appointmentService.GetOtherCliniciansAppointmentsByDateRange(appointment).Where(e => available_clinician_ids.Contains(e.clinician_id)).Select(e => e.clinician_id).ToList(); List <mp_profile> profiles = _profileService.Get().Where(e => available_clinician_ids.Contains(e.id) && !taken_slots.Contains(e.id)).ToList(); if (profiles.Count() > 0) { return(profiles.First()); } return(null); }
public Appointment(mp_appointment appointment) { id = appointment.id; client_id = appointment.client_id; clinician_id = appointment.clinician_id; start_date = appointment.start_date; appointment_type = appointment.appointment_type; appointment_service = appointment.appointment_service; clinician_id = appointment.clinician_id; client_id = appointment.client_id; appointment_serviceNavigation = appointment.appointment_serviceNavigation; appointment_typeNavigation = appointment.appointment_typeNavigation; client = appointment.client_; clinician = appointment.clinician_; }
public ActionResult NewAppointment(mp_appointment appointment) { var service = DAL.Utils.Options.GetAppointmentServices().FirstOrDefault(e => e.id == appointment.appointment_service); var collection = Request.Form; var date = collection["date"] + " " + collection["time"]; var start_date = DateTime.Parse(date); appointment.start_date = start_date; appointment.end_date = start_date.AddMinutes(service.time_minutes); Guid logged_user_id = Guid.Parse(_userManager.GetUserId(HttpContext.User)); mp_profile user_profile = _profileService.GetByUserId(logged_user_id); appointment.client_id = user_profile.id; Guid appointment_id; var day_available = _clinicianAvailabilityService.Get().FirstOrDefault(e => e.day_name == start_date.DayOfWeek.ToString() && e.clinician_id == appointment.clinician_id); if (day_available != null) { // var clinician_available = _clinicianAvailabilityService.GetClinicianAvailabilityByDateRange(appointment); if (1 == 1)//if (AppointmentBL.IsClinicianAvailable(day_available.start_time,day_available.end_time,appointment.start_date,appointment.end_date)) { //clinician is available by settings //now check if clinician already has appointment fixed // var clinician_appointments = _appointmentService.GetClinicianAppointmentsByDateRange(appointment); if (1 == 1)//if (AppointmentBL.IsAppointmentClashing(appointment.clinician_id,appointment)) { //clinician does not have appointments set for that time //fix appointment appointment.status = 169; appointment_id = _appointmentService.Add(appointment); TempData["appointment_id"] = appointment_id; TempData["AlertType"] = "alert-success"; TempData["AlertMessage"] = "We have found an available clinician for you. Please make payment to confirm your booking"; return(RedirectToAction(nameof(ConfirmAppointment))); } } } //if we got here, then no clinician was available TempData["AlertType"] = "alert-warning"; TempData["AlertMessage"] = "Sorry, the clinician will not be available at the time you chose. Please can you review their availability and adjust."; return(RedirectToAction("NewAppointment", "Appointment", new { id = collection["profile_match"] })); }
public ActionResult ConfirmAppointment(Guid?id) { string appointment_id_str = TempData["appointment_id"]?.ToString(); mp_appointment appointment = null; if (!String.IsNullOrEmpty(appointment_id_str)) { Guid appointment_id = Guid.Parse(appointment_id_str); appointment = _appointmentService.Get(appointment_id); } else if (String.IsNullOrEmpty(appointment_id_str) && id.HasValue) { appointment = _appointmentService.Get(id.Value); } var service_cost = _serviceCostService.Get().FirstOrDefault(e => e.clinician_id == appointment.clinician_id && e.appointment_service_id == appointment.appointment_service && e.appointment_activity_sub_id == appointment.appointment_activity_sub_id); ViewBag.service_cost = service_cost; return(View(appointment)); }
public IActionResult GetClinicianAvailability(mp_appointment appointment) { //check if clinician has availability setting matching these criteria var availability = _clinicianAvailabilityService.GetClinicianAvailabilityByDateRange(appointment); if (availability == null) { return(Ok(false)); } //now check if the clinician already an appointment for the same schedule var matching_existing_appointments = _appointmentService.GetClinicianAppointmentsByDateRange(appointment); if (matching_existing_appointments.Count() > 0) { return(Ok(false)); } return(Ok(true)); }
public async Task <ActionResult> ConfirmAppointment(IFormCollection collection) { var user_id = _userManager.GetUserId(HttpContext.User); var appointment_id = collection["appointment_id"]; try { mp_appointment appointment = _appointmentService.Get().Include(x => x.client_).Include(x => x.clinician_).FirstOrDefault(e => e.id == Guid.Parse(appointment_id)); mp_credit credit = new mp_credit { amount = Convert.ToDecimal(collection["amount"]), profile_id = appointment.client_id, created_by = user_id, appointment_id = appointment.id, mode_of_payment = 1, transaction_reference = collection["transaction_reference"] }; _creditService.Add(credit); appointment.status = 234; _appointmentService.Update(appointment); var admins = await _userManager.GetUsersInRoleAsync("super_admin"); await new NotificationHelper(_emailSender).AppointmentScheduled(appointment, admins); TempData["AlertType"] = "alert-success"; TempData["AlertMessage"] = "Successfully booked an appointment"; return(RedirectToAction("CompletedBooking", "Appointment")); } catch (Exception ex) { TempData["AlertType"] = "alert-warning"; TempData["AlertMessage"] = "Payment for appointment was not successful, Kindly select the appoinment and go to payment"; return(RedirectToAction("ConfirmAppointment", "Appointment", new { id = appointment_id })); } }
public static bool IsAppointmentClashing(Guid clinician_id, mp_appointment appointment) { DateTime new_apt_start = appointment.start_date, new_apt_end = appointment.end_date; var appointments = new AppointmentService().Get().Where(e => e.clinician_id == clinician_id && e.start_date.Date == appointment.start_date.Date); var result = true; foreach (var appt in appointments) { DateTime old_apt_start = appt.start_date, old_apt_end = appt.end_date; if ((old_apt_start < new_apt_start && old_apt_end < new_apt_start) || (old_apt_start > new_apt_start && old_apt_end > new_apt_end)) { result = true; } else { return(false); } } return(result); }
public IQueryable <mp_clinician_availability> GetOtherCliniciansAvailabilityByDateRange(mp_appointment appointment) { return(_context.mp_clinician_availability.Where(e => e.status.Value && e.day_name == appointment.start_date.DayOfWeek.ToString() && e.start_time.TimeOfDay >= appointment.start_date.TimeOfDay && e.end_time.TimeOfDay <= appointment.end_date.TimeOfDay && e.clinician_id != appointment.clinician_id).AsQueryable()); }
public mp_clinician_availability GetClinicianAvailabilityByDateRange(mp_appointment appointment) { return(_context.mp_clinician_availability.AsEnumerable().Where(e => e.status.Value && e.day_name == appointment.start_date.DayOfWeek.ToString() && e.end_time.TimeOfDay > appointment.start_date.TimeOfDay && appointment.end_date.TimeOfDay < e.end_time.TimeOfDay && e.clinician_id == appointment.clinician_id).FirstOrDefault()); }
public IQueryable <mp_appointment> GetOtherCliniciansAppointmentsByDateRange(mp_appointment appointment) { return(_context.mp_appointment.Where(e => e.start_date >= appointment.start_date && e.end_date <= appointment.end_date && e.clinician_id != appointment.clinician_id).AsQueryable()); }
public async Task AppointmentScheduled(mp_appointment appointment, IList <ApplicationUser> admins) { var appointment_service = Options.GetAppointmentServices().FirstOrDefault(e => e.id == appointment.appointment_service); var appointment_details = "<strong>Date of appointment:</strong> " + appointment.start_date.ToString("dd MMM, yyyy hh:mm tt") + "<br/>"; appointment_details += "<strong>Appointment type: </strong>" + Options.GetAppointmentTypeName(appointment.appointment_type) + "<br/>"; appointment_details += "<strong>Appointment activity:</strong>" + Options.GetAppointmentSubActivityName(appointment.appointment_activity_sub_id) + "<br/>"; appointment_details += "<strong>Appointment service:</strong>" + appointment_service.name + "<br/>"; appointment_details += "<strong>Duration: </strong>" + appointment_service.time_minutes + " minutes <br/>"; var notification = new mp_notification { created_by = "sys_admin", created_by_name = "System Admin", notification_type = 3, read = 0, user_id = appointment.client_.user_id }; notification.title = "Appointment scheduled successfully"; notification.notification = "Appointment scheduled successfully.<br/><strong>Appointment details </strong><br/>" + appointment_details + "<strong>Provider : </strong>" + appointment.clinician_.last_name + " " + appointment.clinician_.first_name; NotificationUtil.Add(notification); await _emailSender.SendEmailAsync(appointment.client_.email, "Appointment successful - MySpace MyTime", $"Thanks you " + appointment.client_.last_name + " " + appointment.client_.first_name + ". Your appointment has been scheduled successfully.<br/><strong>Appointment details </strong><br/>" + appointment_details + "<strong>Provider : </strong>" + appointment.clinician_.last_name + " " + appointment.clinician_.first_name); notification = new mp_notification { created_by = "sys_admin", created_by_name = "System Admin", notification_type = 4, read = 0, user_id = appointment.clinician_.user_id }; //notification.user_id = appointment.clinician_.user_id; //notification.notification_type = 4; notification.title = "Appointment scheduled successfully"; notification.notification = "Appointment scheduled successfully.<br/><strong>Appointment details </strong><br/>" + appointment_details + "<strong>Member : </strong>" + appointment.client_.last_name + " " + appointment.client_.first_name; NotificationUtil.Add(notification); //NotificationUtil.AddNotification(notification); await _emailSender.SendEmailAsync(appointment.clinician_.email, "New appointment scheduled - MySpace MyTime", $"Hi " + appointment.clinician_.last_name + " " + appointment.clinician_.first_name + ", a new appointment has been scheduled for you.<br/><strong>Appointment details </strong><br/>" + appointment_details + "<strong>Member : </strong>" + appointment.client_.last_name + " " + appointment.client_.first_name); foreach (var admin in admins) { notification = new mp_notification { created_by = "sys_admin", created_by_name = "System Admin", notification_type = 4, read = 0, user_id = admin.Id }; notification.title = "Recieved Payment For An Appointment"; notification.notification = $"Recieved Payment For An Appointment, Clinician is " + appointment.clinician_.last_name + " " + appointment.clinician_.first_name + " and Member is " + appointment.client_.last_name + " " + appointment.client_.first_name; NotificationUtil.Add(notification); } }
public ActionResult Create(mp_appointment appointment) { var service = DAL.Utils.Options.GetAppointmentServices().FirstOrDefault(e => e.id == appointment.appointment_service); var collection = Request.Form; var date = collection["date"] + " " + collection["time"]; var start_date = DateTime.Parse(date); appointment.start_date = start_date; appointment.end_date = start_date.AddMinutes(service.time_minutes); Guid logged_user_id = Guid.Parse(_userManager.GetUserId(HttpContext.User)); mp_profile user_profile = _profileService.GetByUserId(logged_user_id); appointment.client_id = user_profile.id; Guid appointment_id; var clinician_available = _clinicianAvailabilityService.GetClinicianAvailabilityByDateRange(appointment); if (clinician_available != null) { //clinician is available by settings //now check if clinician already has appointment fixed var clinician_appointments = _appointmentService.GetClinicianAppointmentsByDateRange(appointment); if (clinician_appointments.Count() < 1) { //clinician does not have appointments set for that time //fix appointment appointment_id = _appointmentService.Add(appointment); TempData["appointment_id"] = appointment_id; TempData["AlertType"] = "alert-success"; TempData["AlertMessage"] = "We have found an available clinician for you. Please make payment to confirm your booking"; return(RedirectToAction(nameof(ConfirmAppointment))); } //else //{ // //clinician is already occupied // alternative_clinician = GetAvailableClinician(appointment); // if (alternative_clinician != null) // { // appointment.clinician_id = alternative_clinician.id; // appointment_id = _appointmentService.Add(appointment); // TempData["appointment_id"] = appointment_id; // TempData["AlertType"] = "alert-success"; // TempData["AlertMessage"] = "We have found an available clinician for you. Please make payment to confirm your booking"; // return RedirectToAction(nameof(ConfirmAppointment)); // } // //check for other available clinicians //} } //else //{ // alternative_clinician = GetAvailableClinician(appointment); // if (alternative_clinician != null) // { // appointment.clinician_id = alternative_clinician.id; // appointment_id = _appointmentService.Add(appointment); // TempData["appointment_id"] = appointment_id; // TempData["AlertType"] = "alert-success"; // TempData["AlertMessage"] = "We have found an available clinician for you. Please make payment to confirm your booking"; // return RedirectToAction(nameof(ConfirmAppointment)); // } // //check for other available clinicians //} //if we got here, then no clinician was available TempData["AlertType"] = "alert-warning"; TempData["AlertMessage"] = "Sorry, we couldn't get an available clinician. Please change your dates and try again"; return(RedirectToAction("Clinicians", "Clinician")); }