Пример #1
0
        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));
        }
Пример #2
0
        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"));
        }