예제 #1
0
        public void Get_work_time_for_doctor_for_date_return_doctors()
        {
            workTimeRepository.GetWorkTimesForDoctor(Guid.Parse("7bb28807-f41e-4bf4-b699-6a478051adba")).Returns(this.GetListOfWorkTimes());
            DateTime date = new DateTime(2020, 12, 05);

            WorkTime workTime = workTimeService.GetWorkTimeForDoctorForDate(Guid.Parse("7bb28807-f41e-4bf4-b699-6a478051adba"), date);

            Assert.True(this.CompareWorkTimesForDoctorForDate(this.GetFirstWorkTime(), workTime, date));
        }
예제 #2
0
        public void Get_free_appointments_return_appointments()
        {
            Guid          patientId     = Guid.Parse("7bb28807-f41e-4bf4-b699-6a478051ad11");
            Guid          doctorId      = Guid.Parse("7bb28807-f41e-4bf4-b699-6a478051adba");
            DateTime      date          = new DateTime(2020, 12, 26);
            TreatmentType treatmentType = TreatmentType.Examination;

            appointmentRepository.GetAppointmentForDoctorForDate(doctorId, date).Returns(this.GetListOfAppointmentsForDoctorForDate());
            workTimeService.GetWorkTimeForDoctorForDate(doctorId, date).Returns(GetFirstWorkTime());

            IEnumerable <AppointmentDTO> appointments = appointmentService.GetFreeAppointments(patientId, doctorId, date, treatmentType);

            IEnumerable <Appointment> output = GetListOfFreeAppointments();

            Assert.True(CompareAppointmentsDTO(output, appointments));
        }
예제 #3
0
        public IEnumerable <AppointmentDTO> GetFreeAppointments(Guid patientId, Guid doctorId, DateTime date, TreatmentType treatmentType)
        {
            List <AppointmentDTO> freeAppointments = new List <AppointmentDTO>();
            List <Appointment>    appointments     = _appointmentRepository.GetAppointmentForDoctorForDate(doctorId, date).ToList();

            WorkTime workTime = _workTimeService.GetWorkTimeForDoctorForDate(doctorId, date);

            if (workTime == null)
            {
                return(freeAppointments);
            }
            TimeSpan appointmentDuration = GetAppointmentDuration(treatmentType);

            DateTime startDateTime = new DateTime(workTime.StartDate.Year, workTime.StartDate.Month, workTime.StartDate.Day, workTime.StartTime, 0, 0);
            DateTime endDateTime   = new DateTime(workTime.EndDate.Year, workTime.EndDate.Month, workTime.EndDate.Day, workTime.EndTime, 0, 0);

            freeAppointments = FindFreeAppointments(appointments, startDateTime, endDateTime, appointmentDuration).ToList();
            freeAppointments = InitializeAppointments(freeAppointments, patientId, doctorId, treatmentType).ToList();

            return(freeAppointments);
        }