public void Get_doctor_work_day_by_date_and_doctor_id_invalid() { DoctorWorkDayService doctorWorkDayService = new DoctorWorkDayService(CreateDoctorWorkDayStubRepository(), null); DoctorWorkDay result = doctorWorkDayService.GetDoctorWorkDayByDateAndDoctorId(new DateTime(2022, 12, 7), 1); Assert.Null(result); }
protected bool CheckIfAppointmentTimeIsAvailableForGivenWorkDay(DoctorWorkDay doctorWorkDay, Appointment appointment) { if (doctorWorkDay.ScheduledAppointments.Where(o => DateTime.Compare(o.StartTime, appointment.StartTime) == 0 && o.Canceled == false).ToList().Count == 0) { return(true); } return(false); }
protected bool CheckIfPatientAlreadyHasAppointmentForGivenWorkDay(DoctorWorkDay doctorWorkDay, Appointment appointment) { if (doctorWorkDay.ScheduledAppointments.Where(o => o.MedicalExamination.PatientId == appointment.MedicalExamination.PatientId).ToList().Count == 0) { return(true); } return(false); }
public bool ScheduleAppointment(Appointment appointment) { DoctorWorkDay doctorWorkDay = GetEntity(appointment.DoctorWorkDayId); if (CheckIfAppointmentTimeIsAvailableForGivenWorkDay(doctorWorkDay, appointment)) { doctorWorkDay.ScheduledAppointments.Add(appointment); UpdateEntity(doctorWorkDay); return(true); } return(false); }
public static DoctorWorkDayDto DoctorWorkDayToDoctorWorkDayDto(DoctorWorkDay doctorWorkDay, List <Appointment> availableAppointments) { DoctorWorkDayDto dto = null; if (doctorWorkDay != null) { dto = new DoctorWorkDayDto(); dto.Id = doctorWorkDay.Id; dto.DoctorId = doctorWorkDay.DoctorId; dto.RoomId = doctorWorkDay.RoomId; dto.AvailableAppointments = availableAppointments; dto.Specialization = doctorWorkDay.Doctor.Specialitation.SpecialitationForDoctor; dto.DoctorFullName = "Dr " + doctorWorkDay.Doctor.Name + " " + doctorWorkDay.Doctor.Surname; } return(dto); }
public void CancelPatientAppointment(int doctorWorkDayId, int appointmentId, DateTime today) { DoctorWorkDay doctorWorkDay = GetEntity(doctorWorkDayId); foreach (Appointment appointmentForCancelation in doctorWorkDay.ScheduledAppointments) { if (appointmentForCancelation.Id == appointmentId) { if (today < appointmentForCancelation.StartTime.AddHours(-48)) { appointmentForCancelation.Canceled = true; appointmentForCancelation.CancellationDate = today; UpdateEntity(doctorWorkDay); return; } } } }
public void UpdateEntity(DoctorWorkDay entity) { doctorWorkDayRepository.UpdateEntity(entity); }
public void DeleteEntity(DoctorWorkDay entity) { doctorWorkDayRepository.DeleteEntity(entity); }
public DoctorWorkDay AddEntity(DoctorWorkDay entity) { return(doctorWorkDayRepository.AddEntity(entity)); }