Пример #1
0
        public ActionResult GetEmergencyAppointments(AppointmentSearchWithPrioritiesDTO parameters)
        {
            _freeAppointmentSearchService.SetNewDateTimesForEmergency(parameters.InitialParameters);
            List <Examination> unchangedExaminations = (List <Examination>)_freeAppointmentSearchService.GetUnchangedAppointmentsForEmergency(parameters);

            if (unchangedExaminations.Count != 0)
            {
                List <EmergencyExaminationDTO> sortedAndAlignedExamination =
                    GetSortedAndAlignedExaminations(
                        new List <Examination>()
                {
                    unchangedExaminations[0]
                },
                        new List <Examination>()
                {
                    unchangedExaminations[0]
                }
                        );

                return(Ok(sortedAndAlignedExamination));
            }

            unchangedExaminations.Clear();
            unchangedExaminations = _freeAppointmentSearchService.GetOnlyAdequateAppointmentsForEmergency(parameters);
            List <Examination> shiftedExaminations = (List <Examination>)_freeAppointmentSearchService.GetShiftedAndSortedAppoinmentsForEmergency(parameters);

            List <EmergencyExaminationDTO> sortedAndAlignedExaminations = GetSortedAndAlignedExaminations(unchangedExaminations, shiftedExaminations);

            return(Ok(sortedAndAlignedExaminations));
        }
        private void SearchAppointmentsButton_Click(object sender, RoutedEventArgs e)
        {
            if (!CheckIsDateTimeIntervalValid())
            {
                return;
            }

            DateTime startDate = AppointmentSearchStartDatePicker.SelectedDate.Value.Date;
            DateTime startTime = AppointmentSearchStartTimePicker.SelectedTime.Value;

            DateTime endDate = AppointmentSearchEndDatePicker.SelectedDate.Value.Date;
            DateTime endTime = AppointmentSearchEndTimePicker.SelectedTime.Value;

            DateTime appointmentSearchStartDateTime = new DateTime(startDate.Year, startDate.Month, startDate.Day, startTime.Hour, startTime.Minute, startTime.Second, DateTimeKind.Utc);
            DateTime appointmentSearchEndDateTime   = new DateTime(endDate.Year, endDate.Month, endDate.Day, endTime.Hour, endTime.Minute, endTime.Second, DateTimeKind.Utc);

            string doctorJmbg    = ((DoctorDTO)AppointmentDoctorComboBox.SelectedItem).Jmbg;
            int    patientCardId = ((PatientBasicDTO)AppointmentSearchPatientComboBox.SelectedItem).PatientCardId;

            int doctorSpecialtyId = ((SpecialtyDTO)AppointmentDoctorSpecializationComboBox.SelectedItem).Id;

            SearchPriority searchPriority;

            if ((bool)AppointmentSearchDoctorPriorityRadioButton.IsChecked)
            {
                searchPriority = SearchPriority.Doctor;
            }
            else
            {
                searchPriority = SearchPriority.Date;
            }


            List <int> appointmentRequiredEquipmentTypes = new List <int>();

            foreach (EquipmentTypeForViewDTO equipmentType in AllEquipmentTypes)
            {
                if (equipmentType.IsSelected)
                {
                    appointmentRequiredEquipmentTypes.Add(equipmentType.EquipmentType.Id);
                }
            }

            AppointmentService appointmentService = new AppointmentService();
            AppointmentSearchWithPrioritiesDTO appointmentSearchParametersDTO = new AppointmentSearchWithPrioritiesDTO(
                new BasicAppointmentSearchDTO(patientCardId, doctorJmbg, appointmentRequiredEquipmentTypes,
                                              appointmentSearchStartDateTime,
                                              appointmentSearchEndDateTime), searchPriority, doctorSpecialtyId);

            List <ExaminationDTO> examinationDTOs = appointmentService.GetFreeAppointments(appointmentSearchParametersDTO);

            ExaminationSearchResults = examinationDTOs;
            List <ExaminationDTO> examinationDTOsWithoutDuplicates = RemoveAppointmentsWithDuplicateTimes(examinationDTOs);

            AppointmentSearchResultsDataGrid.ItemsSource = examinationDTOsWithoutDuplicates;

            AppointmentSearchScrollViewer.ScrollToBottom();
        }
Пример #3
0
        public ActionResult GetFreeAppointments(AppointmentSearchWithPrioritiesDTO appointmentDTO)
        {
            List <Examination> examinations = (List <Examination>)_freeAppointmentSearchService.SearchWithPriorities(appointmentDTO);

            examinations.ForEach(e => e.Doctor = _doctorService.GetDoctorByJmbg(e.DoctorJmbg));
            List <ExaminationDTO> allExaminations = new List <ExaminationDTO>();

            examinations.ForEach(e => allExaminations.Add(ExaminationMapper.Examination_To_ExaminationDTO(e)));

            return(Ok(allExaminations));
        }
        private ICollection <Examination> RelaxDoctor(AppointmentSearchWithPrioritiesDTO parameters)
        {
            ICollection <Doctor> allDoctors       = _doctorRepository.GetDoctorsBySpecialty(parameters.SpecialtyId);
            List <Examination>   freeAppointments = new List <Examination>();

            foreach (Doctor doctor in allDoctors)
            {
                parameters.InitialParameters.DoctorJmbg = doctor.Jmbg;
                freeAppointments.AddRange(BasicSearch(parameters.InitialParameters));
            }

            return(freeAppointments);
        }
        public List <Examination> GetOnlyAdequateAppointmentsForEmergency(AppointmentSearchWithPrioritiesDTO parameters)
        {
            List <Examination> unavailableAppointments = GetUnavailableAppointments(parameters.InitialParameters);

            foreach (Examination examination in unavailableAppointments.ToList())
            {
                if (!_roomService.CheckIfRoomHasRequiredEquipment(examination.IdRoom, parameters.InitialParameters.RequiredEquipmentTypes) ||
                    !IsPatientAvailable(parameters.InitialParameters.PatientCardId, examination.DateAndTime) ||
                    !examination.Doctor.CheckIfDoctorHasSpecialty(parameters.SpecialtyId))
                {
                    unavailableAppointments.Remove(examination);
                }
            }
            return(unavailableAppointments);
        }
        private ICollection <Examination> RelaxDates(AppointmentSearchWithPrioritiesDTO parameters)
        {
            for (int i = 0; i < PRIORITY_DATE_INTERVAL; i++)
            {
                BasicAppointmentSearchDTO initialParameters = SetupDates(parameters.InitialParameters);

                ICollection <Examination> freeAppointments = BasicSearch(initialParameters);

                if (freeAppointments.Count != 0)
                {
                    return(freeAppointments);
                }
            }

            return(new List <Examination>());
        }
        public ICollection <Examination> GetUnchangedAppointmentsForEmergency(AppointmentSearchWithPrioritiesDTO parameters)
        {
            SetNewDateTimesForEmergency(parameters.InitialParameters);
            ICollection <Doctor> allDoctors = _doctorRepository.GetDoctorsBySpecialty(parameters.SpecialtyId);
            List <Examination>   allUnchangedAppointments = new List <Examination>();

            foreach (Doctor doctor in allDoctors)
            {
                parameters.InitialParameters.DoctorJmbg = doctor.Jmbg;
                List <Examination> freeAppointments = (List <Examination>)BasicSearch(parameters.InitialParameters);
                freeAppointments.ForEach(e => e.Doctor = doctor);
                allUnchangedAppointments.AddRange(freeAppointments);
            }
            allUnchangedAppointments.ForEach(e => e.ExaminationStatus = ExaminationStatus.AVAILABLE);

            return(allUnchangedAppointments);
        }
        public ICollection <Examination> GetShiftedAndSortedAppoinmentsForEmergency(AppointmentSearchWithPrioritiesDTO parameters)
        {
            SetNewDateTimesForEmergency(parameters.InitialParameters);
            List <Examination> adequateAppoinments = GetOnlyAdequateAppointmentsForEmergency(parameters);

            ICollection <Examination> shiftedAppointments = new List <Examination>();

            foreach (Examination examination in adequateAppoinments)
            {
                List <Examination> availableAppointments = GetShiftedAppointmentForEmergency(parameters.InitialParameters, examination);
                availableAppointments = availableAppointments.OrderBy(e => e.DateAndTime).ToList();
                Doctor doctor = _doctorRepository.GetDoctorByJmbg(availableAppointments[0].DoctorJmbg);
                availableAppointments[0].Doctor = doctor;
                shiftedAppointments.Add(availableAppointments[0]);
            }

            return(shiftedAppointments);
        }
        public ICollection <Examination> SearchWithPriorities(AppointmentSearchWithPrioritiesDTO parameters)
        {
            ICollection <Examination> freeAppointments = BasicSearch(parameters.InitialParameters);

            if (freeAppointments.Count == 0)
            {
                if (parameters.Priority == SearchPriority.Doctor)
                {
                    return(RelaxDates(parameters));
                }
                else
                {
                    return(RelaxDoctor(parameters));
                }
            }

            return(freeAppointments);
        }
        private void ScheduleEmergencyAppointmentButton_Click(object sender, RoutedEventArgs e)
        {
            int patientCardId = ((PatientBasicDTO)AppointmentSearchPatientComboBox.SelectedItem).PatientCardId;

            int doctorSpecialtyId = ((SpecialtyDTO)AppointmentDoctorSpecializationComboBox.SelectedItem).Id;

            List <int> appointmentRequiredEquipmentTypes = new List <int>();

            foreach (EquipmentTypeForViewDTO equipmentType in AllEquipmentTypes)
            {
                if (equipmentType.IsSelected)
                {
                    appointmentRequiredEquipmentTypes.Add(equipmentType.EquipmentType.Id);
                }
            }


            AppointmentSearchWithPrioritiesDTO appointmentSearchParametersDTO = new AppointmentSearchWithPrioritiesDTO
            {
                InitialParameters = new BasicAppointmentSearchDTO(patientCardId, doctorJmbg: "0909965768767", appointmentRequiredEquipmentTypes,
                                                                  earliestDateTime: new DateTime(DateTime.Now.Year, DateTime.Now.Month, 29, 7, 0, 0, DateTimeKind.Utc), latestDateTime: new DateTime()),
                Priority    = SearchPriority.Date,
                SpecialtyId = doctorSpecialtyId
            };

            AppointmentService appointmentService = new AppointmentService();



            if (EmergencyAppointmentSearchResultsDataGrid.SelectedItem == null)
            {
                List <EmergencyExaminationDTO> emergencyExaminationSearchResults = appointmentService.GetEmergencyAppointments(appointmentSearchParametersDTO);

                if (emergencyExaminationSearchResults.Count == 1 && emergencyExaminationSearchResults[0].UnchangedExamination.DateTime.Equals(emergencyExaminationSearchResults[0].ShiftedExamination.DateTime))
                {
                    appointmentService.AddExamination(emergencyExaminationSearchResults[0].UnchangedExamination, appointmentRequiredEquipmentTypes);


                    InfoDialog infoDialog = new InfoDialog(String.Format("Uspešno ste zakazali pregled!{0}{0}Nakon zatvaranja ovog dijaloga, biće prikazano više informacija o zakazanom pregledu.", Environment.NewLine));
                    infoDialog.ShowDialog();
                    ShowDialogWithMoreDetailsAboutScheduledExamination(emergencyExaminationSearchResults[0].UnchangedExamination);

                    ClearAppointmentSearchFields();
                    AppointmentSearchScrollViewer.ScrollToTop();
                }
                else
                {
                    EmergencyAppointmentSearchResultsDataGrid.ItemsSource = emergencyExaminationSearchResults;

                    InfoDialog infoDialog = new InfoDialog("Nažalost u skorijem periodu nema slobodnih termina koji odgovaraju unetim parametrima. Možete pomeriti neki od postojećih termina. Termini su sortirani u tabeli po pogodnosti za pomeranje. Termin koji je najpogodniji za pomeranje je posebno naglašen.");
                    infoDialog.ShowDialog();
                }
            }
            else
            {
                EmergencyExaminationDTO selectedEmergencyExamination = (EmergencyExaminationDTO)EmergencyAppointmentSearchResultsDataGrid.SelectedItem;

                ExaminationDTO unchangedExamination = selectedEmergencyExamination.UnchangedExamination;

                ExaminationDTO examinationForScheduleDTO = new ExaminationDTO(unchangedExamination.DateTime, unchangedExamination.Doctor, unchangedExamination.RoomId, patientCardId);

                RescheduleExaminationDTO rescheduleExaminationDTO = new RescheduleExaminationDTO(examinationForScheduleDTO, selectedEmergencyExamination.UnchangedExamination, selectedEmergencyExamination.ShiftedExamination);

                appointmentService.RescheduleExamination(rescheduleExaminationDTO);


                InfoDialog infoDialog = new InfoDialog(String.Format("Uspešno ste zakazali pregled!{0}{0}Nakon zatvaranja ovog dijaloga, biće prikazano više informacija o zakazanom pregledu.", Environment.NewLine));
                infoDialog.ShowDialog();
                ShowDialogWithMoreDetailsAboutScheduledExamination(examinationForScheduleDTO);

                ClearAppointmentSearchFields();
                AppointmentSearchScrollViewer.ScrollToTop();
            }
        }
Пример #11
0
        public List <EmergencyExaminationDTO> GetEmergencyAppointments(AppointmentSearchWithPrioritiesDTO appointmentSearchWithPrioritiesDTO)
        {
            List <EmergencyExaminationDTO> response = HTTPGetRequestWithObjectAsParam <EmergencyExaminationDTO>("appointment/emergency", appointmentSearchWithPrioritiesDTO);

            return(response);
        }