private void DoSearch(bool isSpecialistSearch)
        {
            ClearAllResults();
            if (isSpecialistSearch ? InvalidInputForSpecialistAppointment() : InvalidInputForAppointment())
            {
                MessageBox.Show("Invalid input.");
                return;
            }

            DateTime startDate = DateTime.ParseExact(GetStartDatePicker(isSpecialistSearch).SelectedDate.Value.ToString("MM/dd/yyyy") + AllConstants.DayStart, "MM/dd/yyyy HH:mm", null);
            DateTime endDate   = DateTime.ParseExact(GetEndDatePicker(isSpecialistSearch).SelectedDate.Value.ToString("MM/dd/yyyy") + AllConstants.DayEnd, "MM/dd/yyyy HH:mm", null);

            Doctor chosenDoctor = GetChosenDoctor(isSpecialistSearch);
            RecommendationRequestDto recommendationRequestDto = new RecommendationRequestDto()
            {
                DoctorId     = chosenDoctor.Id,
                SpecialtyId  = chosenDoctor.DepartmentId,
                TimeInterval = new TimeInterval(startDate, endDate),
                Preference   = GetRecommendationPreference(isSpecialistSearch ? specialistPriorityComboBox : PriorityComboBox)
            };
            List <RecommendationDto> searchResults = schedulingController.GetAppointments(recommendationRequestDto);

            if (!IsValidRequest(isSpecialistSearch, searchResults))
            {
                MessageBox.Show(isSpecialistSearch ? "There is no room with required equipment!" : "There are no available appointments for chosen period!");
                return;
            }

            ISearchResultStrategy strategy          = new SearchResultStrategy(new AppointmentSearchResult(searchResults));
            SearchResultDialog    appointmentDialog = new SearchResultDialog(strategy.GetSearchResult(), SearchType.AppointmentSearch);

            appointmentDialog.ShowDialog();
        }
        private List <RecommendationDto> RecommendWithTime(RecommendationRequestDto dto)
        {
            List <RecommendationDto> recommendations = new List <RecommendationDto>();

            recommendations.AddRange(RecommendForDoctorInTimeInterval(dto, GetRemainingSlots(recommendations)));
            recommendations.AddRange(RecommendAnyDoctorInTimeInterval(dto, GetRemainingSlots(recommendations)));

            return(recommendations);
        }
        public IEnumerable <RecommendationDto> RecommendEmergency(RecommendationRequestDto dto)
        {
            if (dto.TimeInterval == null)
            {
                return(null);
            }
            List <RecommendationDto> recommendations = new List <RecommendationDto>();

            recommendations.AddRange(RecommendEmergencyInTimeInterval(dto, GetRemainingSlots(recommendations)));
            return(recommendations);
        }
Ejemplo n.º 4
0
        public List <RecommendationDto> GetEmergencyAppointments(RecommendationRequestDto recDto)
        {
            var client  = new RestClient(AllConstants.ConnectionUrl);
            var request = new RestRequest("/api/schedule/examination/emergency", Method.POST);

            request.AddParameter(AllConstants.AuthorizationTokenKey, LoggedUser.Cookie, ParameterType.Cookie);
            request.AddJsonBody(RecommendationDtoToJson(recDto));
            var response = client.Post <List <RecommendationDto> >(request);

            return(response.Data);
        }
        private List <RecommendationDto> RecommendForDoctorInTimeInterval(RecommendationRequestDto dto, int remainingSlots)
        {
            if (remainingSlots == 0)
            {
                return(new List <RecommendationDto>());
            }

            var selectedDoctorShifts =
                _shiftWrapper.Repository.GetByDoctorIdAndTimeInterval(dto.DoctorId, dto.TimeInterval).ToList();

            return(FindRecommendationsInShifts(selectedDoctorShifts, remainingSlots));
        }
        public IEnumerable <RecommendationDto> Recommend(RecommendationRequestDto dto)
        {
            if (dto.TimeInterval == null)
            {
                return(null);
            }
            if (dto.TimeInterval.Start < DateTime.Now)
            {
                return(null);
            }

            return(dto.Preference == RecommendationPreference.Time ? RecommendWithTime(dto) : RecommendWithDoctor(dto));
        }
        private List <RecommendationDto> RecommendForDoctorAnyTimeInterval(RecommendationRequestDto dto, int remainingSlots)
        {
            if (remainingSlots == 0)
            {
                return(new List <RecommendationDto>());
            }

            var selectedDoctorShifts = _shiftWrapper.Repository.GetByDoctorIdAndTimeInterval(
                dto.DoctorId,
                new TimeInterval
            {
                Start = (dto.TimeInterval.Start.AddMonths(-1) < DateTime.Now ? DateTime.Now : dto.TimeInterval.Start.AddMonths(-1)),
                End   = dto.TimeInterval.End.AddMonths(1)
            }
                );

            return(FindRecommendationsInShifts(selectedDoctorShifts, remainingSlots));
        }
        private List <RecommendationDto> RecommendAnyDoctorInTimeInterval(RecommendationRequestDto dto, int remainingSlots)
        {
            if (remainingSlots == 0)
            {
                return(new List <RecommendationDto>());
            }

            IEnumerable <int> doctorIds =
                _doctorConnection.Get <IEnumerable <int> >($"specialty/ids/{dto.SpecialtyId}");

            IEnumerable <Shift> allShifts = _shiftWrapper.Repository
                                            .GetMatching(shift =>
                                                         doctorIds.Contains(shift.DoctorId) &&
                                                         shift.TimeInterval.Start.Date >= dto.TimeInterval.Start.Date &&
                                                         shift.TimeInterval.Start.Date <= dto.TimeInterval.End.Date
                                                         );

            return(FindRecommendationsInShifts(allShifts, remainingSlots));
        }
        private void EmergencyExamination_Click(object sender, RoutedEventArgs e)
        {
            if (InvalidInputForEmergencyAppointment())
            {
                MessageBox.Show("Invalid input.");
                return;
            }

            int    specialtyId  = GetChosenSpecialtyId();
            Doctor chosenDoctor = doctorServerController.GetDoctorsBySpecialty(specialtyId).ElementAt(0);

            DateTime startDate = DateTime.Now.AddHours(1);
            DateTime endDate   = startDate.AddHours(3);

            RecommendationRequestDto recommendationRequestDto = new RecommendationRequestDto()
            {
                DoctorId     = chosenDoctor.Id,
                SpecialtyId  = specialtyId,
                TimeInterval = new TimeInterval(startDate, endDate),
                Preference   = RecommendationPreference.Time
            };

            List <RecommendationDto> searchResults = schedulingController.GetEmergencyAppointments(recommendationRequestDto);

            if (searchResults.Count() != 0)
            {
                ScheduleWindow scheduleWindow = new ScheduleWindow(searchResults.ElementAt(0), null);
                scheduleWindow.ShowDialog();
            }
            else
            {
                MessageBox.Show("Appointment analysis is needed!");
                AppointmentAnalysisWindow appointmentAnalysisWindow = new AppointmentAnalysisWindow(recommendationRequestDto.SpecialtyId);
                appointmentAnalysisWindow.ShowDialog();
            }
        }
Ejemplo n.º 10
0
        private void FillObservableCollection(int specialtyId)
        {
            examinationWithAvailableRescheduling = new ObservableCollection <ExaminationWithAvailableReschedulingDto>();
            List <Examination> examinations = examinationServerController.GetBySpecialtyId(specialtyId).ToList();

            foreach (Examination exam in examinations)
            {
                ExaminationWithAvailableReschedulingDto examination = new ExaminationWithAvailableReschedulingDto(exam.Id, exam.PatientId, exam.DoctorId, exam.Priority, exam.TimeInterval.Start, DateTime.Now, exam.RequiredSpecialtyId);
                examinationWithAvailableRescheduling.Add(examination);
                examinationSearchComboBox.Items.Add(exam.Id);
            }

            foreach (ExaminationWithAvailableReschedulingDto exam in examinationWithAvailableRescheduling)
            {
                RecommendationRequestDto recommendationRequestDto = new RecommendationRequestDto {
                    DoctorId     = exam.DoctorId,
                    Preference   = RecommendationPreference.Time,
                    SpecialtyId  = exam.RequiredSpecialtyId,
                    TimeInterval = new TimeInterval(DateTime.Now.AddHours(1), DateTime.Now.AddDays(5))
                };
                List <RecommendationDto> recommendationDtos = schedulingController.GetAppointments(recommendationRequestDto);
                exam.ReschedulingDate = recommendationDtos[0].TimeInterval.Start;
            }
        }
 public List <RecommendationDto> GetEmergencyAppointments(RecommendationRequestDto recommendationRequestDto)
 {
     return(schedulingServerService.GetEmergencyAppointments(recommendationRequestDto));
 }
Ejemplo n.º 12
0
 private String RecommendationDtoToJson(RecommendationRequestDto recDto)
 {
     return(JsonConvert.SerializeObject(recDto));
 }
Ejemplo n.º 13
0
 public IActionResult RecommendEmergencyExamination(RecommendationRequestDto dto)
 {
     return(Ok(_recommendationService.RecommendEmergency(dto)));
 }