/// <summary> /// Create an appointment. /// </summary> /// <param name="appointment">Appointment to create.</param> public void CreateAppointment(Appointment appointment) { ValidateDate(appointment); var appointments = repository.GetDoctorAppointments(appointment.Doctor.Id); foreach (Appointment doctorAppointment in appointments) { if (doctorAppointment.Date.Year == appointment.Date.Year && doctorAppointment.Date.Month == appointment.Date.Month && doctorAppointment.Date.Day == appointment.Date.Day && doctorAppointment.Date.Hour == appointment.Date.Hour && doctorAppointment.Date.Minute == appointment.Date.Minute && doctorAppointment.State.Id == (int)StateEnum.Assigned) { throw new NotValidDateException("The doctor has already assigned that attention date"); } } var patient = patientService.GetPatient(appointment.Patient.Id); if (patient == null || patient.Id == 0) { throw new RecordNotFoundException("The patient does not exist"); } var doctor = doctorService.GetDoctor(appointment.Doctor.Id); if (doctor == null || doctor.Id == 0) { throw new RecordNotFoundException("The doctor does not exist"); } repository.CreateAppointment(appointment); }
public IActionResult Checkout(Appointment appointment) { var items = _shoppingCart.GetShoppingCartItems(); _shoppingCart.ShoppingCartItems = items; if (_shoppingCart.ShoppingCartItems.Count == 0) { ModelState.AddModelError("", "Ваша корзина пуста, сначала добавьте услуги"); log.Error($"Ошибка создания заказа: корзина пуста (услуг {_shoppingCart.ShoppingCartItems.Count}"); } else { StringBuilder message = new StringBuilder(); message.AppendLine("Ваш заказ: "); foreach (ShoppingCartItem shoppingCart in _shoppingCart.ShoppingCartItems) { repository.CreateAppointment(new Appointment() { DoctorId = shoppingCart.Service.DoctorId, }); message.AppendLine(shoppingCart.Service.Name + " Врач: " + shoppingCart.Service.DoctorName + " К оплате: " + shoppingCart.Service.Price); } message.AppendLine("Спасибо за заказ"); _shoppingCart.ClearCart(); SendMessage(message.ToString()); return(RedirectToAction("CheckoutComplete")); } return(View(appointment)); }
public void CreateAppointment([FromBody] BookAppointment objAppointment) { _logger.LogInformation(objAppointment.DoctorId.ToString()); _logger.LogInformation(objAppointment.PatientId.ToString()); _logger.LogInformation(objAppointment.Status); repos.CreateAppointment(objAppointment); }
public IActionResult CreateAppointment(AppointmentViewModel viewmodel) { viewmodel.Appointment.Patient = _patientrepo.GetPatientById(viewmodel.Appointment.Patient.Id); viewmodel.Appointment.Doctor = _doctorrepo.GetDoctorById(viewmodel.Appointment.Doctor.Id); viewmodel.Appointment.Technician = _techrepo.GetTechnicianById(viewmodel.Appointment.Technician.Id); _apprepo.CreateAppointment(viewmodel.Appointment); return(RedirectToAction("ListAppointments")); }
public IActionResult MadeAppointment(Models.AppointmentDto app) { if (ModelState.IsValid) { var appointment = new Models.DDD.Appointment(app); _appointmentRepository.CreateAppointment(appointment); ViewBag.HtmlStr = "<p>Appointment created succesfully!</p>"; return(RedirectToAction("GetAppointments", "Appointment", new { Date = app.PatientName })); } return(View()); }
public async Task <IHttpActionResult> CreateAppointment([FromUri(Name = "")] PrimaryCareAppointmentRequestModel pcReqAppt) { try { var obj = _repo.CreateAppointment(pcReqAppt); return(Ok(obj)); } catch (Exception ex) { throw ex; } }
public async Task <Unit> Handle(EventRequest <AppointmentCreatedEvent> request, CancellationToken cancellationToken) { _logger.DebugWithContext($"Handling event {nameof(AppointmentCreatedEvent)} for Aggregate {nameof(Appointment)}", request.Event); var model = new AppointmentReadModel() { Title = request.Event.Title, StartTime = request.Event.StartTime, Duration = request.Event.Duration.ToString(), Id = request.Event.AggregateId }; await _appointmentRepo.CreateAppointment(model); return(new Unit()); }
public IActionResult Checkout(Appointment appointment) { var items = _shoppingCart.GetShoppingCartItems(); _shoppingCart.ShoppingCartItems = items; if (_shoppingCart.ShoppingCartItems.Count == 0) { ModelState.AddModelError("", "Ваша корзина пуста, сначала добавьте услуги"); log.Error($"Ошибка создания заказа: корзина пуста (услуг {_shoppingCart.ShoppingCartItems.Count}"); } if (ModelState.IsValid) { repository.CreateAppointment(appointment); _shoppingCart.ClearCart(); return(RedirectToAction("CheckoutComplete")); } return(View(appointment)); }
public IActionResult CreatingAppointment(PatientAppointmentReferral PAR, string RequestedDate) { List <string> newList = new List <string>(); //this preloads the data for the appointment page ViewBag.Dates = newList; PAR.Decision = "Booked"; PAR.RequestedTime = RequestedDate.Substring(11); //PAR.RequestedDate.TimeOfDay.ToString(); if (PAR.RequestedDate.Date >= DateTime.Now.Date && (PAR.RequestedDate.DayOfWeek.ToString() != "Saturday" || PAR.RequestedDate.DayOfWeek.ToString() != "saturday") || (PAR.RequestedDate.DayOfWeek.ToString() != "Sunday") || (PAR.RequestedDate.DayOfWeek.ToString() != "sunday")) { if (ModelState.IsValid) { Appointment appointment = new Appointment(); appointment.AppointmentDate = DateTime.Parse(RequestedDate); //appointment.AppointmentTime = PAR.RequestedTime; appointment.AppointmentTime = RequestedDate.Substring(11); appointment.AppointmentType = "Doctor's Surgery"; appointment.County = PAR.County; appointment.CurrentDate = PAR.CurrentDate; appointment.Diagnosis = ""; appointment.DOB = PAR.DOB; appointment.PatientFullName = PAR.Name; appointment.Postcode = PAR.Postcode; appointment.Region = PAR.Region; appointment.StreetName = PAR.StreetName; appointment.StreetNumber = PAR.StreetNumber; appointment.Symptoms = PAR.Symptoms; appointment.AppointmentMedicalProfessional = PAR.MedicalPersonnel; //this checks if users are Medical personnel or not if (HttpContext.Session.GetString("Name") != "" && (HttpContext.Session.GetString("Type") == "Doctor" || HttpContext.Session.GetString("Type") == "Nurse")) { try { //this checks if usersis already in the database and adds the appointment to the appropriate database table and displays the appropriate message Account accounts = AccountRepository.Accounts.FirstOrDefault(a => a.Name == appointment.PatientFullName); if (accounts == null) { PARrepository.CreatePAR(PAR); TempData["Message"] = "Appointment Created"; } else { //Account account = AccountRepository.Accounts.FirstOrDefault(a => a.Name == appointment.PatientFullName); appointment.UserReferralID = accounts.ID; AppointmentRepository.CreateAppointment(appointment); TempData["Message"] = "Appointment Created"; } } catch { //this adds a valid appointment as a guest appointment PARrepository.CreatePAR(PAR); } //this returns the user to the practitioners index view return(RedirectToAction("Index", "Practitioners")); } else if ((HttpContext.Session.GetString("Name") != "" || HttpContext.Session.GetString("Name") != null) && HttpContext.Session.GetString("Type") == "Patient") { //this adds a logged in user's appointment as a logged in user appointment, displays the apppropriate message and redirects the user to their respected homepage Account account = HttpContext.Session.getJson <Account>("Account"); appointment.UserReferralID = account.ID; AppointmentRepository.CreateAppointment(appointment); TempData["Message"] = "Appointment Created"; return(RedirectToAction("Index", "Patient")); } else { //this adds a guest user's appointment as a guest appointment, displays the apppropriate message and redirects the user to their respected homepage PARrepository.CreatePAR(PAR); TempData["Message"] = "Appointment Created"; return(RedirectToAction("Index", "Appointment")); } } else { return(View()); } } else { return(View()); } }
public async Task <bool> CreateAppointment(AppointmentEntity appointmentToCreate) { return(await _appointmentRepository.CreateAppointment(appointmentToCreate)); }