public Task <List <GetAppointmentResponse> > GetAppointments(AppointmentDto request) { var endDate = request.EndDate; var fromClinicId = request.FromClinicId; var fromClinicName = request.FromClinicName; var isActive = request.IsActive; var patientId = request.PatientId; var patientName = request.PatientName; var startDate = request.StartDate; var toClinicId = request.ToClinicId; var toClinicName = request.ToClinicName; return(context .Appointment .AsNoTracking() .ConditionalWhere(endDate != default && startDate == default, x => x.EndDate == endDate) .ConditionalWhere(startDate != default && endDate == default, x => x.StartDate == startDate) .ConditionalWhere(startDate != default && endDate != default, x => x.StartDate >= startDate && x.EndDate <= x.EndDate) .ConditionalWhere(fromClinicId != Guid.Empty, x => x.FromClinicId == fromClinicId) .ConditionalWhere(!string.IsNullOrEmpty(fromClinicName), x => x.FromClinicName == fromClinicName) .ConditionalWhere(isActive.HasValue, x => x.IsActive == isActive.Value) .ConditionalWhere(patientId != Guid.Empty, x => x.IsActive == isActive.Value) .ConditionalWhere(!string.IsNullOrEmpty(patientName), x => x.PatientName == patientName) .ConditionalWhere(toClinicId != Guid.Empty, x => x.ToClinicId == toClinicId) .ConditionalWhere(!string.IsNullOrEmpty(toClinicName), x => x.ToClinicName == toClinicName) .ProjectTo <GetAppointmentResponse>(mapper.ConfigurationProvider) .ToListAsync()); }
public IActionResult Put(int id, [FromBody] AppointmentDto dto, [FromServices] UpdateAppointmentValidator validator) { dto.Id = id; var appointment = _context.Appointments.Find(id); if (appointment == null) { return(NotFound()); } var result = validator.Validate(dto); if (!result.IsValid) { throw new Exception();// prepraviti sa klasom error/ medelja 5-subota termin } _mapper.Map(dto, appointment); try { _context.SaveChanges(); return(NoContent()); } catch (Exception e) { return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public ActionResult Edit(int id) { EditAppointment modelView = new EditAppointment(); // AppointmentDto appointmentDto = new AppointmentDto(); //Get the current Appointment object string url = "AppointmentData/FindAppointment/" + id; HttpResponseMessage response = client.GetAsync(url).Result; if (response.IsSuccessStatusCode) { AppointmentDto selectedAppointment = response.Content.ReadAsAsync <AppointmentDto>().Result; modelView.AppointmentDto = selectedAppointment; } else { return(RedirectToAction("Error")); } //The view needs to be sent a list of all the Departments so the client can select an Apointmenr for an appointmnet in the view modelView.DepartmentsSelectList = GetDepartmentSelectList(); //The view needs to be sent a list of all the Doctors so the client can select a Doctors for appointmnet in the view modelView.DoctorsSelectList = GetDoctorsSelectList(); return(View(modelView)); }
public async Task <ActionResult <AppointmentDto> > Put(int id, AppointmentDto model) { try { if (!ModelState.IsValid) { return(BadRequest("Model is not valid")); } var oldAppointment = await _appointmentService.GetAppointmentByIdAsync(id); if (oldAppointment == null) { return(NotFound($"Could not find appointment with id of {id}")); } var updatedAppointment = _mapper.Map(model, oldAppointment); if (await _appointmentService.UpdateAppointment(updatedAppointment)) { return(Ok(updatedAppointment)); } } catch (Exception e) { return(this.StatusCode(StatusCodes.Status500InternalServerError, $"Database Failure: {e}")); } return(BadRequest()); }
private async Task DeleteAppointmentAsync(SchedulerDeleteEventArgs args) { AppointmentDto item = (AppointmentDto)args.Item; await AppointmentService.DeleteAsync(item.ScheduleId, item.AppointmentId); SchedulerService.Appointments.Remove(item); }
public async Task ShouldPostValidAppointment() { // arrange; const string doctorId = "auth0|6076cf2ec42780006af85a96"; var startDate = new DateTime(2021, 10, 10); const int duration = 60; var command = new Post.Command(TestUserHelper.TestPatientId, doctorId, startDate, duration, null, null); var expected = new AppointmentDto { PatientId = TestUserHelper.TestPatientId, DoctorId = "auth0|6076cf2ec42780006af85a96", StartDateTime = startDate, DurationMinutes = duration, DoctorNotes = null, PatientNotes = null }; // act; var res = await SendMediatorRequestInScopeOnBehalfOfTheTestPatient(command); // assert; res.Should().BeEquivalentTo(expected, options => options .Excluding(o => o.Location) .Excluding(o => o.AppointmentId) .Excluding(o => o.DoctorName)); // clean up; var appointmentToRemove = await Context.Appointments.FirstOrDefaultAsync(a => a.AppointmentId.Equals(res.AppointmentId)); Context.Appointments.Remove(appointmentToRemove); await Context.SaveChangesAsync(); }
public IActionResult Update(int id, [FromBody] AppointmentDto appointmentDto) { var model = Mapper.Map <Appointment>(appointmentDto); var result = _appointmentService.Update(model); return(Ok()); }
public async Task <IActionResult> Edit(Guid id, [FromForm] AppointmentDto appointmentDto) { if (id != appointmentDto.Id) { return(NotFound()); } if (ModelState.IsValid) { Appointment appointment = await _appointmentRepository.GetById(id); appointment.Note = appointmentDto.Note; appointment.StartDate = appointmentDto.StartDate; appointment.EndDate = appointmentDto.EndDate; appointment.Service = await _serviceRepository.GetById(appointmentDto.ServiceId); appointment.Provider = await _userRepository.GetById(appointmentDto.ProviderId); appointment.Status = await _context.AppointmentStatus.FindAsync(appointmentDto.StatusId); await _appointmentRepository.Update(appointment); return(RedirectToAction(nameof(Index))); } return(View()); }
public HttpResponseMessage Create(AppointmentDto appoinDto) { if (appoinDto.PatientId != null) { appoinDto.PatientId = appoinDto.PatientId; } // call to AppointmentService var result = _appointmentService.Create(appoinDto); // push noti if (result.Success) { var tokens = _tokenService.GetAll(); int[] roleIds = { (int)RoleEnum.Receptionist, (int)RoleEnum.Cashier, (int)RoleEnum.Manager }; var data = new { roleIds, message = "Có cuộc hẹn vừa được thêm." }; SendNotificationUtils.SendNotification(data, tokens); } var response = Request.CreateResponse(HttpStatusCode.OK, result); return(response); }
public async Task <int> AddAppointmentAsync(AppointmentDto dto) { m_Logger.Information($"{nameof(AddAppointmentAsync)} Invoked"); if (dto == null) { throw new ArgumentNullException(nameof(dto)); } await Task.Yield(); lock (m_AppointmentLock) { int id = dto.Id; if (id <= 0) { throw new InvalidDataException($"{nameof(id)} must be greater than 0"); } if (m_AppointmentStorage.ContainsKey(id)) { id = 0; } else { m_AppointmentStorage.Add(id, dto); } return(id); } }
public void CreateAppointmentSuccessfully() { var patient = new PatientDto { Name = "Felipe Cristo de Oliveira", BirthDate = new DateTime(1991, 2, 3) }; patient = _patientService.Create(patient); var appointment = new AppointmentDto { PatientId = patient.Id, StartedAt = new DateTime(2020, 04, 01, 15, 30, 0), FinishedAt = new DateTime(2020, 04, 01, 16, 0, 0), Comments = "Comment test" }; var appointmentCreated = _service.Create(appointment); Assert.NotEqual(0, appointmentCreated.Id); Assert.Equal(appointment.PatientId, appointmentCreated.PatientId); Assert.Equal(appointment.StartedAt, appointmentCreated.StartedAt); Assert.Equal(appointment.FinishedAt, appointmentCreated.FinishedAt); Assert.Equal(appointment.Comments, appointmentCreated.Comments); }
public void CreateAppointmentWithDateTimeConflict() { var patient = new PatientDto { Name = "Angela Maria Martins Cristo", BirthDate = new DateTime(1962, 7, 23) }; patient = _patientService.Create(patient); var appointment = new AppointmentDto { PatientId = patient.Id, StartedAt = new DateTime(2020, 04, 01, 15, 30, 0), FinishedAt = new DateTime(2020, 04, 01, 16, 0, 0), Comments = "Comment test" }; var appointmentCreated = _service.Create(appointment); var appointmentWithDateConflict = new AppointmentDto { PatientId = patient.Id, StartedAt = new DateTime(2020, 04, 01, 15, 15, 0), FinishedAt = new DateTime(2020, 04, 01, 15, 45, 0), Comments = "Comment test" }; var ex = Assert.Throws <DomainException>(() => _service.Create(appointment)); Assert.Equal("Exists another appointment at selected interval", ex.Message); }
public async Task <IActionResult> Edit(AppointmentDto appointmentDto) { var appointment = _mapper.Map <Appointment>(appointmentDto); var validationResult = _validator.Validate(appointment); if (!ModelState.IsValid) { var errors = ModelState.Values.SelectMany(x => x.Errors).Select(x => x.ErrorMessage).ToList(); return(BadRequest(errors)); } else if (!validationResult.IsValid) { var validationErrors = validationResult.Errors.Select(x => $"{x.PropertyName} failed validation: ${x.ErrorMessage}."); return(BadRequest(string.Join(";", validationErrors))); } int result = await _appointmentRepository.Update(appointment).ConfigureAwait(false); if (result == 1) { return(Ok("Appointment updated.")); } return(BadRequest("There was an error trying to update the appointment.")); }
private Mock <IAppointmentService> SetupRepository(AppointmentDto appointment, List <AppointmentDto> appointments) { var repository = CreateRepository(); switch (GetCallingMethod()) { case "Get_all_appointments": repository.Setup(m => m.GetAll()).Returns(CreateAppointments()); break; case "Add_appointment": repository.Setup(m => m.Add(appointment)).Returns(appointment); break; case "Cancel_appointment": repository.Setup(m => m.CancelAppointment(1)).Returns(appointment); break; case "Appointment_done": repository.Setup(m => m.SetAppointmentDone(1)).Returns(appointment); break; case "Finish_appointment": repository.Setup(m => m.FinishAppointment(1)).Returns(appointment); break; default: Console.WriteLine("Error"); break; } return(repository); }
public HttpResponseMessage UpdateAppointment(AppointmentDto appointmentDto) { var result = this._appointmentService.UpdateAppointment(appointmentDto.AppointmentId, appointmentDto.SampleGettingDtos); // push noti if (result.Success) { var tokens = _tokenService.GetAll(); int[] roleIds = { (int)RoleEnum.Receptionist, (int)RoleEnum.Cashier, (int)RoleEnum.Manager }; var data = new { roleIds, message = "Có cuộc hẹn vừa được chỉnh sửa." }; SendNotificationUtils.SendNotification(data, tokens); } var response = Request.CreateResponse(HttpStatusCode.OK, result); return(response); }
public async Task <IActionResult> CreateAsync([FromBody] AppointmentDto appointment) { ActionResult result = StatusCode((int)HttpStatusCode.InternalServerError, "The content could not be displayed because an internal server error has occured."); try { var newAppointment = await _appointmentService.AddAppointmentAsync(appointment); //by design, returns null if validation fails and doesn't throw, //or context fails to create without error. if (newAppointment == null) { throw new InvalidOperationException($"Could not be created."); } result = StatusCode((int)HttpStatusCode.Created, newAppointment); } catch (Exception ex) { _logger.LogError(ex, ex.Message); throw; } return(result); }
public async Task ShouldGetExistingAppointment() { // arrange; // test data set contains this Appointment; var appointmentId = new Guid("134f3726-3369-492b-b3bd-b62be67b96f8"); var expected = new AppointmentDto { AppointmentId = appointmentId, PatientId = TestUserHelper.TestPatientId, DoctorId = "auth0|6076cf2ec42780006af85a96", StartDateTime = new DateTime(2021, 7, 1, 10, 0, 0), PatientNotes = null, PatientName = "Integration and Unit Tests", DurationMinutes = 60, DoctorNotes = null, DoctorName = "Dr Demo Person", Location = "10 Demo Street, Demo Town, DE1 MO0, United Kingdom" }; // act; var res = await SendMediatorRequestInScopeOnBehalfOfTheTestPatient(new GetOne.Query(appointmentId)); // assert; res.Should().BeEquivalentTo(expected); }
public async Task DeleteAppointment_ValidAppointment_ShouldDeleteAppointment() { // arrange var order = OrderBuilder.New().First(); order.TrackingId = TokenHelper.NewToken(); order.Transferee = transferee; order.Consultant = dsc; order.ProgramManager = pm; Context.Orders.Add(order); Context.SaveChanges(); Context.Entry(order).Reload(); // Act var controller = SetUpAppointmentController(); controller.MockCurrentUserAndRole(dsc.Id, dsc.UserName, UserRoles.Consultant); var dto = new AppointmentDto() { OrderId = order.Id, Id = null, ScheduledDate = DateTime.Now, Description = "Adding a new appointment" }; var result = controller.UpsertItineraryAppointment(dto); result = controller.DeleteAppointment(order.Appointments.First().Id); // Assert Context.Entry(order).Reload(); result.Should().BeOfType <System.Web.Http.Results.OkResult>(); order.Appointments.Count.Should().Be(0); }
private List <AppointmentDto> CreateAppointments() { List <AppointmentDto> appointments = new List <AppointmentDto>(); AppointmentDto appointment1 = new AppointmentDto { Id = 1, Date = "2020-05-01", Status = AppointmentStatus.Active, DoctorId = 1, PatientId = 1, Time = "00:00AM", CancellationDate = "" }; AppointmentDto appointment2 = new AppointmentDto { Id = 2, Date = "2020-05-01", Status = AppointmentStatus.Done, DoctorId = 2, PatientId = 2, Time = "00:00AM", CancellationDate = "" }; appointments.Add(appointment1); appointments.Add(appointment2); return(appointments); }
public async Task <ActionResult <AppointmentDto> > PostAppointment(AppointmentDto appointment) { var staffId = appointment.StaffId; var userId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value); var newAppointment = await _context.Appointments .FirstOrDefaultAsync(app => app.AppointmentTime == appointment.AppointmentTime && app.ClinicStaff.Id == staffId || app.UserId == userId && app.AppointmentTime == appointment.AppointmentTime); if (newAppointment != null) { return(BadRequest("An appointment already exists!")); } newAppointment = new Appointment { UserId = userId, ClinicStaffId = staffId, Reason = appointment.Reason, AppointmentTime = appointment.AppointmentTime }; await _context.Appointments.AddAsync(newAppointment); if (await _context.SaveChangesAsync() > 0) { return(Ok()); } return(BadRequest("Failed to make an appointment")); }
public void EditAppointment(AppointmentDto input) { _userService.CheckUserPermissions(new List <Enum.RoleType> { Enum.RoleType.Enterprise }); var userCliam = _userService.UserClaim(); if (_enterpriseInfoRepository.Count(t => t.Id == userCliam.UserId) < 1) { throw new UserFriendlyException("请先完善企业资料、个人资料"); } if (input.Id.HasValue) { var appointment = _appointmentRepository.FirstOrDefault(t => t.Id == input.Id && t.IsDeleted == false); if (appointment != null) { appointment.VisitsTime = (DateTime)input.VisitsTime; appointment.Content = input.Content; appointment.UpdateTime = Clock.Now; appointment.UpdateUserId = userCliam.UserId; _appointmentRepository.UpdateAsync(appointment); } } else { _appointmentRepository.InsertAsync(new AppointmentEntity { Id = Guid.NewGuid(), Content = input.Content, CreateUserId = userCliam.UserId, EnterpriseId = userCliam.UserId, VisitsTime = (DateTime)input.VisitsTime }); } }
private void EditHandler(SchedulerEditEventArgs args) { args.IsCancelled = true;//prevent built-in edit form from showing up if (!CanMakeAppointment) { return; } AppointmentDto item = args.Item as AppointmentDto; CustomEditFormShown = true; if (!args.IsNew) // an edit operation, otherwise - an insert operation { //copying is implemented in the appointment model and it is needed because //this is a reference to the data collection so modifying it directly //will immediately modify the data and no cancelling will be possible CurrentAppointment = item.ShallowCopy(); } else { CurrentAppointment = new AppointmentDto() { Start = args.Start, End = args.End, IsAllDay = args.IsAllDay }; } }
private void CheckAppointmentQueueStorage(object source, ElapsedEventArgs e) { m_Logger.Information($"{nameof(CheckAppointmentQueueStorage)} Invoked"); try { m_QueueTimer.Stop(); CloudQueue queue = GetQueue(); CloudQueueMessage message = queue.GetMessageAsync().ConfigureAwait(false).GetAwaiter().GetResult(); if (message != null) { AppointmentDto appointment = AppointmentDto.DeSerialize <AppointmentDto>(message.AsBytes); AddAppointmentAsync(appointment).ConfigureAwait(false).GetAwaiter().GetResult(); queue.DeleteMessageAsync(message).ConfigureAwait(false).GetAwaiter().GetResult(); } } catch (Exception ex) { m_Logger.Error(ex, "Error caught checking for appointments in queue storage."); } finally { m_QueueTimer.Start(); } }
// GET: UserWeb/Appointment/Edit/{apId} public ActionResult Edit(int appointmentId) { Appointment app = _appointmentService.GetSingleById(appointmentId); AppointmentDto appDto = Mapper.Map <Appointment, AppointmentDto>(app); ViewBag.appDto = appDto; return(View("Edit", "_Layout")); }
private void PopulateProperties(AppointmentDto appointment) { DOB = appointment.DOB; MedName = appointment.MedName; Symptoms = appointment.Symptoms; Status = Convert.ToString(State.Pending); //populate other properties }
public async void Post([FromBody] string value) { PracticeInformation practice = new PracticeInformation(); AppointmentDto appointment = new AppointmentDto(); //var appointmentMade = await _bookingRepository.AddBooking(practice, appointment); }
/// <summary> /// Creates the specified meeting. /// </summary> /// <param name="appointment">The meeting.</param> /// <param name="patient">The patient.</param> public void Create(AppointmentDto appointment, LightPatientDto patient) { var patientEntity = this.Session.Get <Patient>(patient.Id); var meetingEntity = Mapper.Map <AppointmentDto, Appointment>(appointment); patientEntity.Appointments.Add(meetingEntity); this.Session.SaveOrUpdate(patientEntity); }
public void AddAppointment(AppointmentDto dto) { Appointment appointment = mapper.Map <AppointmentDto, Appointment>(dto); dbContext.Appointments.Add(appointment); dbContext.SaveChanges(); }
public async Task <AppointmentDto> GetAppointmentAsync(int id) { Appointment appointment = await _appointmentRepo.GetAsync(id); AppointmentDto result = _mapper.Map <AppointmentDto>(appointment); return(result); }
public void Appointment_dto_to_appointment() { AppointmentDto appointmentDto = CreateAppointmentDto(); Appointment myAppointment = HospitalApp.Adapters.AppointmentAdapter.AppointmentDtoToAppointment(appointmentDto); myAppointment.ShouldBeOfType(typeof(Appointment)); }