private void RenovateRoom(object sender, RoutedEventArgs e)
 {
     setDates();
     if (setDestinationRoomId())
     {
         DestinationRoomComboBox.SelectedIndex = 0;
         try
         {
             RenovationDto renovationDto    = CreateRenovationDto(timeInterval);
             SchedulingDto schDto           = renovationDto.toSchedulingDto();
             List <int>    unavailableRooms = roomServerController.GetUnavailableRooms(schDto).ToList();
             if (unavailableRooms.Count > 0)
             {
                 ShowAlternativeRenovationAppointments(unavailableRooms, renovationDto);
             }
             else
             {
                 ScheduleRenovation(schDto);
             }
         }
         catch
         {
             MessageBox.Show("End time must be after start time!", "");
         }
     }
 }
        private IEnumerable <RoomRenovationDto> BasicRenovationSearch(SchedulingDto dto)
        {
            List <RoomRenovationDto> appointments          = new List <RoomRenovationDto>();
            List <Shift>             availableShiftsSource = new List <Shift>();
            IEnumerable <Shift>      shiftsForSourceRoom   = _shiftWrapper.Repository.GetShiftsByRoomID(dto.SourceRoomId);

            foreach (Shift shift in shiftsForSourceRoom)
            {
                List <Shift> shiftList = new List <Shift>();
                shiftList.Add(shift);
                IEnumerable <RecommendationDto> recommendationsSourceRoom = FindRecommendationsInShifts(shiftList, MaximumAppointmentsInShift);
                if (recommendationsSourceRoom.Count() == MaximumAppointmentsInShift)
                {
                    availableShiftsSource.Add(shift);
                }
            }

            foreach (Shift shift in availableShiftsSource)
            {
                RoomRenovationDto roomRenovationDto = new RoomRenovationDto()
                {
                    SourceRoomId      = dto.SourceRoomId,
                    DestinationRoomId = dto.DestinationRoomId,
                    TimeInterval      = shift.TimeInterval
                };
                appointments.Add(roomRenovationDto);
            }
            return(appointments);
        }
 private void RelocateEquipment(object sender, RoutedEventArgs e)
 {
     startDate =
         DateTime.ParseExact(startDatePicker.SelectedDate.Value.ToString("MM/dd/yyyy")
                             + " " + StartTime.Text, "MM/dd/yyyy HH:mm", null);
     endDate =
         DateTime.ParseExact(startDatePicker.SelectedDate.Value.ToString("MM/dd/yyyy")
                             + " " + EndTime.Text, "MM/dd/yyyy HH:mm", null);
     try{
         TimeInterval timeInterval = new TimeInterval(startDate, endDate);
         if (AmountIsValid())
         {
             EquipmentRelocationDto eqRelDto         = CreateEquipmentRelocationDto(timeInterval);
             SchedulingDto          schDto           = eqRelDto.toSchedulingDto();
             List <int>             unavailableRooms = roomServerController.GetUnavailableRooms(schDto).ToList();
             if (unavailableRooms.Count > 0)
             {
                 ShowAlternativeRelocationAppointments(unavailableRooms, eqRelDto);
             }
             else
             {
                 ScheduleRelocation(schDto);
             }
         }
     } catch
     {
         MessageBox.Show("End time must be after start time!", "");
     }
 }
        private void ShowAlternativeRenovationAppointments(List <int> unavailableRooms, RenovationDto renovationDto)
        {
            SchedulingDto dto = renovationDto.toSchedulingDto();
            AlternativeRenovationAppointments newWindow =
                new AlternativeRenovationAppointments(unavailableRooms[0], this, dto);

            newWindow.Show();
        }
        private void AddScheduleRenovationButton(int row, RenovationDto renovation)
        {
            Button scheduleBtn = CreateScheduleButton();

            Grid.SetRow(scheduleBtn, row);
            Grid.SetColumn(scheduleBtn, DynamicGrid.ColumnDefinitions.Count - 2);
            DynamicGrid.Children.Add(scheduleBtn);

            SchedulingDto schDto = renovation.toSchedulingDto();

            timeInterval = new TimeInterval(schDto.TimeInterval.Start, schDto.TimeInterval.End);

            scheduleBtn.Click += (s, e) =>
            {
                List <int> doctors = doctorServerController.GetDoctorsByRoomsAndShifts(schDto).ToList();
                foreach (int doctorId in doctors)
                {
                    renovationServerController.ScheduleRenovation(renovation.TimeInterval, doctorId, AllConstants.PatientIdForRenovation);
                }
                MessageBox.Show("Renovation is successfully scheduled!");
                foreach (Window window in Application.Current.Windows)
                {
                    if (window.GetType() == typeof(RoomRenovation))
                    {
                        if ((window as RoomRenovation).RenovationTypeComboBox.Text.Equals("Complex"))
                        {
                            RoomInformation roomInformation = new RoomInformation(schDto);

                            if ((window as RoomRenovation).ComplexRenovationTypeComboBox.Text.Equals("Separate room"))
                            {
                                roomInformation.MergingStackPanel.Visibility  = Visibility.Hidden;
                                roomInformation.DividingStackPanel.Visibility = Visibility.Visible;
                                roomInformation.Room1Name.Text = mapObjectController.GetMapObjectById(renovation.SourceRoomId).Name;
                                int workTime = mapObjectController.GetMapObjectById(renovation.SourceRoomId).MapObjectDescription.Information.Split("=")[1].Length;
                                roomInformation.WorkTime1.Text = mapObjectController.GetMapObjectById(renovation.SourceRoomId).MapObjectDescription.Information.Split("=")[1].Substring(0, workTime - 1);
                            }
                            else if ((window as RoomRenovation).ComplexRenovationTypeComboBox.Text.Equals("Join rooms"))
                            {
                                roomInformation.DividingStackPanel.Visibility = Visibility.Hidden;
                                roomInformation.MergingStackPanel.Visibility  = Visibility.Visible;
                                roomInformation.RoomName.Text = mapObjectController.GetMapObjectById(renovation.SourceRoomId).Name;
                                int workTime = mapObjectController.GetMapObjectById(renovation.SourceRoomId).MapObjectDescription.Information.Split("=")[1].Length;
                                roomInformation.WorkTime.Text = mapObjectController.GetMapObjectById(renovation.SourceRoomId).MapObjectDescription.Information.Split("=")[1].Substring(0, workTime - 1);
                                List <int> doctors1 = doctorServerController.GetDoctorsByRoomsAndShifts(schDto).ToList();
                                foreach (int doctorId in doctors1)
                                {
                                    startDate = schDto.TimeInterval.Start.AddDays(1);
                                    examinationServerController.ScheduleExamination(startDate, doctorId, AllConstants.PatientIdForRelocation);
                                }
                            }
                            roomInformation.ShowDialog();
                        }
                    }
                }
                this.Close();
            };
        }
 public SearchResultDialog(List <SearchResultDTO> searchResults, SearchType searchType, SchedulingDto schDto)
 {
     InitializeComponent();
     this.schDto        = schDto;
     this.searchType    = searchType;
     this.searchResults = searchResults;
     ShowDynamicGrid();
     AddContent(searchResults);
 }
        public IEnumerable <int> GetUnavailableRooms(SchedulingDto schedulingDto)
        {
            var client  = new RestClient(AllConstants.ConnectionUrl);
            var request = new RestRequest("/api/schedule/examination/unavailable-rooms", Method.POST);

            request.AddParameter(AllConstants.AuthorizationTokenKey, LoggedUser.Cookie, ParameterType.Cookie);
            request.AddJsonBody(SchedulingDtoToJson(schedulingDto));
            var response = client.Post <List <int> >(request);

            return(response.Data);
        }
예제 #8
0
        public List <RenovationDto> GetRenovationAppointments(SchedulingDto scheduleDto)
        {
            var client  = new RestClient(AllConstants.ConnectionUrl);
            var request = new RestRequest("/api/schedule/examination/recommend-renovation-appointment", Method.POST);

            request.AddParameter(AllConstants.AuthorizationTokenKey, LoggedUser.Cookie, ParameterType.Cookie);
            request.AddJsonBody(RecommendationEquipmentRelocationDtoToJson(scheduleDto));
            var response = client.Post <List <RenovationDto> >(request);

            return(response.Data);
        }
 public AlternativeRelocationAppointments(int roomId, EquipmentRelocation er, SchedulingDto eqRequest, string equipmentName)
 {
     InitializeComponent();
     this.equipmentName = equipmentName;
     this.eqRequest     = eqRequest;
     this.er            = er;
     this.roomId        = roomId;
     givenRoom.Text     = "Room with id: " + roomId.ToString() + " is unavailable in given time interval. " +
                          "Click 'Show on map' to see that room and click on 'Show appointments' " +
                          "to see available appointments for relocation";
 }
        public IEnumerable <int> GetDoctorsByRoomsAndShifts(SchedulingDto dto)
        {
            var client  = new RestClient(AllConstants.ConnectionUrl);
            var request = new RestRequest("/api/schedule/examination/get-doctors-by-rooms-and-shifts", Method.POST);

            request.AddParameter(AllConstants.AuthorizationTokenKey, LoggedUser.Cookie, ParameterType.Cookie);
            request.AddJsonBody(EquipmentRelocationDtoToJson(dto));
            var response = client.Post <List <int> >(request);

            return(response.Data);
        }
 public IEnumerable <RoomRenovationDto> RecommendRenovationAppointments(SchedulingDto dto)
 {
     if (dto.DestinationRoomId == -1)
     {
         return(BasicRenovationSearch(dto));
     }
     else
     {
         return(ComplexRenovationSearch(dto));
     }
 }
 public AlternativeRenovationAppointments(int roomId, RoomRenovation roomRenovation, SchedulingDto schedulingDto)
 {
     InitializeComponent();
     this.roomId         = roomId;
     this.roomRenovation = roomRenovation;
     this.roomId         = roomId;
     this.schedulingDto  = schedulingDto;
     givenRoom.Text      = "Room with id: " + roomId.ToString() + " is unavailable in given time interval. " +
                           "Click on 'Show appointments' " +
                           "to see available appointments for renovation";
 }
        private IEnumerable <RoomRenovationDto> ComplexRenovationSearch(SchedulingDto dto)
        {
            List <RoomRenovationDto> appointments               = new List <RoomRenovationDto>();
            List <Shift>             availableShiftsSource      = new List <Shift>();
            List <Shift>             availableShiftsDestination = new List <Shift>();
            IEnumerable <Shift>      shiftsForDestinationRoom   = _shiftWrapper.Repository.GetShiftsByRoomID(dto.DestinationRoomId);
            IEnumerable <Shift>      shiftsForSourceRoom        = _shiftWrapper.Repository.GetShiftsByRoomID(dto.SourceRoomId);

            foreach (Shift shift in shiftsForSourceRoom)
            {
                List <Shift> shiftList = new List <Shift>();
                shiftList.Add(shift);
                IEnumerable <RecommendationDto> recommendationsSourceRoom = FindRecommendationsInShifts(shiftList, MaximumAppointmentsInShift);
                if (recommendationsSourceRoom.Count() == MaximumAppointmentsInShift)
                {
                    availableShiftsSource.Add(shift);
                }
            }
            foreach (Shift shift in shiftsForDestinationRoom)
            {
                List <Shift> shiftList = new List <Shift>();
                shiftList.Add(shift);
                IEnumerable <RecommendationDto> recommendationsDestinationRoom = FindRecommendationsInShifts(shiftList, MaximumAppointmentsInShift);
                if (recommendationsDestinationRoom.Count() == MaximumAppointmentsInShift)
                {
                    availableShiftsDestination.Add(shift);
                }
            }

            List <TimeInterval> availableTimeIntervals = new List <TimeInterval>();

            foreach (Shift shiftSource in availableShiftsSource)
            {
                foreach (Shift shiftDest in availableShiftsDestination)
                {
                    if (shiftDest.TimeInterval.Start.Date == shiftSource.TimeInterval.Start.Date && shiftDest.TimeInterval.End.Date == shiftSource.TimeInterval.End.Date)
                    {
                        availableTimeIntervals.Add(shiftDest.TimeInterval);
                    }
                }
            }
            foreach (TimeInterval timeInterval in availableTimeIntervals)
            {
                RoomRenovationDto roomRenovationDto = new RoomRenovationDto()
                {
                    SourceRoomId      = dto.SourceRoomId,
                    DestinationRoomId = dto.DestinationRoomId,
                    TimeInterval      = timeInterval
                };
                appointments.Add(roomRenovationDto);
            }
            return(appointments);
        }
        private void ShowAlternativeRelocationAppointments(List <int> unavailableRooms, EquipmentRelocationDto equipmentRelocationDto)
        {
            SchedulingDto eqRequest = new SchedulingDto()
            {
                SourceRoomId      = equipmentRelocationDto.SourceRoomId,
                DestinationRoomId = equipmentRelocationDto.DestinationRoomId,
                TimeInterval      = equipmentRelocationDto.TimeInterval
            };

            AlternativeRelocationAppointments newWindow =
                new AlternativeRelocationAppointments(unavailableRooms[0], this, eqRequest, relocationEquipmentName);

            newWindow.Show();
        }
        public IEnumerable <int> GetDoctorsByRoomsAndShifts(SchedulingDto schDto)
        {
            HashSet <int> doctors = new HashSet <int>();
            List <Shift>  shifts  = _shiftsWrapper.Repository
                                    .GetMatching(s => (s.AssignedExamRoomId == schDto.SourceRoomId ||
                                                       s.AssignedExamRoomId == schDto.DestinationRoomId) &&
                                                 s.TimeInterval.Start.Date == schDto.TimeInterval.Start.Date).ToList();

            foreach (Shift shift in shifts)
            {
                doctors.Add(shift.DoctorId);
            }
            return(doctors.ToList());
        }
        public IEnumerable <EquipmentRelocationDto> RecommendEquipmentRelocation(SchedulingDto dto)
        {
            int dateInterval = dto.TimeInterval.End.Day - dto.TimeInterval.Start.Day;
            IEnumerable <Shift> shiftsForDestinationRoom = _shiftWrapper.Repository.GetByTimeInterval
                                                               (dto.TimeInterval).Where(shift => shift.AssignedExamRoomId == dto.DestinationRoomId);

            IEnumerable <Shift> shiftsForSourceRoom = _shiftWrapper.Repository.GetByTimeInterval
                                                          (dto.TimeInterval).Where(shift => shift.AssignedExamRoomId == dto.SourceRoomId);

            IEnumerable <RecommendationDto> recommendationsSourceRoom      = FindRecommendationsInShifts(shiftsForSourceRoom, 20 * dateInterval);
            IEnumerable <RecommendationDto> recommendationsDestinationRoom = FindRecommendationsInShifts(shiftsForDestinationRoom, 20 * dateInterval);

            return(FindCommonEquipmentRelocationAppointments(dto, recommendationsSourceRoom, recommendationsDestinationRoom));
        }
예제 #17
0
        public static EventDto FromDomainObject(Event source, App app)
        {
            var result = SimpleMapper.Map(source, new EventDto
            {
                Settings = new Dictionary <string, ChannelSettingDto>()
            });

            result.Properties = source.Properties ?? EmptyProperties;

            if (source.Formatting.Subject.TryGetValue(app.Language, out var subject))
            {
                result.DisplayName = subject;
            }
            else
            {
                result.DisplayName = source.Formatting.Subject.Values.FirstOrDefault() ?? string.Empty;
            }

            if (source.Formatting != null)
            {
                result.Formatting = NotificationFormattingDto.FromDomainObject(source.Formatting);
            }

            if (source.Scheduling != null)
            {
                result.Scheduling = SchedulingDto.FromDomainObject(source.Scheduling);
            }

            if (source.Settings?.Count > 0)
            {
                result.Settings = new Dictionary <string, ChannelSettingDto>();

                foreach (var(key, value) in source.Settings)
                {
                    if (value != null)
                    {
                        result.Settings[key] = ChannelSettingDto.FromDomainObject(value);
                    }
                }
            }
            else
            {
                result.Settings = EmptySettings;
            }

            result.Counters = source.Counters ?? EmptyCounters;

            return(result);
        }
        private void ScheduleRelocation(SchedulingDto schDto)
        {
            List <int> doctors = doctorServerController.GetDoctorsByRoomsAndShifts(schDto).ToList();

            foreach (int doctorId in doctors)
            {
                startDate = schDto.TimeInterval.Start;
                while (startDate < endDate)
                {
                    examinationServerController.ScheduleExamination(startDate, doctorId, AllConstants.PatientIdForRelocation);
                    startDate = startDate.AddMinutes(30);
                }
            }
            MessageBox.Show("Relocation is successfully scheduled!", "");
            this.Close();
        }
        public IEnumerable <int> GetUnavailableRooms(SchedulingDto schDto)
        {
            HashSet <int>      unavailableRoomsIds         = new HashSet <int>();
            List <Examination> relocationRoomsExaminations = _examinationWrapper.Repository
                                                             .GetMatching(e => (e.RoomId == schDto.SourceRoomId) ||
                                                                          e.RoomId == schDto.DestinationRoomId).ToList();

            foreach (Examination examination in relocationRoomsExaminations)
            {
                if (examination.TimeInterval.Overlaps(schDto.TimeInterval))
                {
                    unavailableRoomsIds.Add(examination.RoomId);
                }
            }
            return(unavailableRoomsIds);
        }
        private void ScheduleRenovation(SchedulingDto schDto)
        {
            List <int> doctors = doctorServerController.GetDoctorsByRoomsAndShifts(schDto).ToList();

            foreach (int doctorId in doctors)
            {
                renovationServerController.ScheduleRenovation(timeInterval, doctorId, AllConstants.PatientIdForRenovation);
            }
            DestinationRoomComboBox.SelectedIndex = 0;
            MessageBox.Show("Renovation is successfully scheduled!");
            if (RenovationTypeComboBox.Text.Equals("Complex"))
            {
                RoomInformation roomInformation = new RoomInformation(schDto);

                if (ComplexRenovationTypeComboBox.Text.Equals("Separate room"))
                {
                    roomInformation.MergingStackPanel.Visibility  = Visibility.Hidden;
                    roomInformation.DividingStackPanel.Visibility = Visibility.Visible;
                    roomInformation.Room1Name.Text = mapObjectController.GetMapObjectById(mapObjectId).Name;
                    int workTime = mapObjectController.GetMapObjectById(mapObjectId).MapObjectDescription.Information.Split("=")[1].Length;
                    roomInformation.WorkTime1.Text = mapObjectController.GetMapObjectById(mapObjectId).MapObjectDescription.Information.Split("=")[1].Substring(0, workTime - 1);
                }
                else if (ComplexRenovationTypeComboBox.Text.Equals("Join rooms"))
                {
                    roomInformation.DividingStackPanel.Visibility = Visibility.Hidden;
                    roomInformation.MergingStackPanel.Visibility  = Visibility.Visible;
                    roomInformation.RoomName.Text = mapObjectController.GetMapObjectById(mapObjectId).Name;
                    int workTime = mapObjectController.GetMapObjectById(mapObjectId).MapObjectDescription.Information.Split("=")[1].Length;
                    roomInformation.WorkTime.Text = mapObjectController.GetMapObjectById(mapObjectId).MapObjectDescription.Information.Split("=")[1].Substring(0, workTime - 1);
                    List <int> doctors1 = doctorServerController.GetDoctorsByRoomsAndShifts(schDto).ToList();
                    foreach (int doctorId in doctors1)
                    {
                        startDate = schDto.TimeInterval.Start.AddDays(1);
                        examinationServerController.ScheduleExamination(startDate, doctorId, AllConstants.PatientIdForRelocation);
                    }
                }

                roomInformation.ShowDialog();
            }
            this.Close();
        }
        private void AddScheduleRelocationButton(int row, EquipmentRelocationDto relocation)
        {
            Button scheduleBtn = CreateScheduleButton();

            Grid.SetRow(scheduleBtn, row);
            Grid.SetColumn(scheduleBtn, DynamicGrid.ColumnDefinitions.Count - 2);
            DynamicGrid.Children.Add(scheduleBtn);

            SchedulingDto schedulingDto = relocation.toSchedulingDto();

            scheduleBtn.Click += (s, e) =>
            {
                List <int> doctors = new DoctorServerController().GetDoctorsByRoomsAndShifts(relocation.toSchedulingDto()).ToList();
                IExaminationServerController examinationServerController = new ExaminationServerController();
                foreach (int doctorId in doctors)
                {
                    examinationServerController.ScheduleExamination(relocation.TimeInterval.Start, doctorId, AllConstants.PatientIdForRelocation);
                }
                MessageBox.Show("Relocation is successfully scheduled!");
                this.Close();
            };
        }
예제 #22
0
 public IEnumerable <int> GetUnavailableRooms(SchedulingDto dto)
 {
     return(roomTypeServerService.GetUnavailableRooms(dto));
 }
예제 #23
0
 public IActionResult GetRenovationAppointments(SchedulingDto dto)
 {
     return(Ok(_recommendationService.RecommendRenovationAppointments(dto)));
 }
 private String EquipmentRelocationDtoToJson(SchedulingDto dto)
 {
     return(JsonConvert.SerializeObject(dto));
 }
예제 #25
0
 private String RecommendationEquipmentRelocationDtoToJson(SchedulingDto equipmentRecomendationRequestDto)
 {
     return(JsonConvert.SerializeObject(equipmentRecomendationRequestDto));
 }
 private String SchedulingDtoToJson(SchedulingDto schedulingDto)
 {
     return(JsonConvert.SerializeObject(schedulingDto));
 }
예제 #27
0
 public IEnumerable <int> GetDoctorsByRoomsAndShifts(SchedulingDto dto)
 {
     return(doctorServerService.GetDoctorsByRoomsAndShifts(dto));
 }
 public List <EquipmentRelocationDto> GetEquipmentRelocationAppointments(SchedulingDto scheduleDto)
 {
     return(schedulingServerService.GetEquipmentRelocationAppointments(scheduleDto));
 }
 public List <RenovationDto> GetRenovationAppointments(SchedulingDto schedulingDto)
 {
     return(schedulingServerService.GetRenovationAppointments(schedulingDto));
 }
        private IEnumerable <EquipmentRelocationDto> FindCommonEquipmentRelocationAppointments(SchedulingDto dto, IEnumerable <RecommendationDto> recsDestinationRoom, IEnumerable <RecommendationDto> recsSourceRoom)
        {
            List <EquipmentRelocationDto> equipmentRelocationDtos = new List <EquipmentRelocationDto>();

            foreach (RecommendationDto recDestination in recsDestinationRoom)
            {
                foreach (RecommendationDto recSource in recsSourceRoom)
                {
                    if (recDestination.TimeInterval.Start == recSource.TimeInterval.Start && recDestination.TimeInterval.End == recSource.TimeInterval.End)
                    {
                        EquipmentRelocationDto eqDto = new EquipmentRelocationDto()
                        {
                            SourceRoomId      = dto.SourceRoomId,
                            DestinationRoomId = dto.DestinationRoomId,
                            Amount            = 0,
                            TimeInterval      = recDestination.TimeInterval
                        };
                        equipmentRelocationDtos.Add(eqDto);
                    }
                    if (equipmentRelocationDtos.Count == 5)
                    {
                        return(equipmentRelocationDtos);
                    }
                }
            }
            return(equipmentRelocationDtos);
        }