示例#1
0
        //--------------------------------------------------------------------------------------------------
        // Constructor
        //--------------------------------------------------------------------------------------------------

        #region Constructor

        /// <summary>
        /// Basic constructor that creates a staff handler for a day time line config for different weeekdays
        /// </summary>
        /// <param name="daysPerWeekConfigs">Configs defining the staff handler per weekday</param>
        public StaffPerPeriodHandler(Dictionary <DayOfWeek, DayTimeLineConfig> daysPerWeekConfigs)
        {
            _daysPerWeekConfig          = daysPerWeekConfigs;
            _staffChangingPerDayAndTime = new Dictionary <DayOfWeek, Dictionary <TimeSpan, StaffChangingPoint> >();
            _staffPerPeriod             = new Dictionary <DayOfWeek, Dictionary <StaffAvailabilityPeriod, ResourceAssignmentStaff[]> >();
            _sortedChangeTimesPerDay    = new Dictionary <DayOfWeek, List <TimeSpan> >();

            // in case day was not specified empty list is added
            StaffAvailabilityPeriod emptyPeriod = new StaffAvailabilityPeriod(0,
                                                                              24,
                                                                              Helpers <ResourceAssignment <SkillSet> > .EmptyArray(),
                                                                              Helpers <ResourceAssignment <SkillSet> > .EmptyArray());

            foreach (DayOfWeek day in Helpers <DayOfWeek> .GetEnumValues())
            {
                if (!DaysPerWeekConfigs.Keys.Contains(day))
                {
                    DaysPerWeekConfigs.Add(day, new DayTimeLineConfig(emptyPeriod));
                } // end if

                // adding all period changes
                _staffChangingPerDayAndTime.Add(day, new Dictionary <TimeSpan, StaffChangingPoint>());
                _staffPerPeriod.Add(day, new Dictionary <StaffAvailabilityPeriod, ResourceAssignmentStaff[]>());

                foreach (StaffAvailabilityPeriod period in DaysPerWeekConfigs[day].StaffAvailabilityPeriods)
                {
                    if (!StaffChangingPerDayAndTime[day].ContainsKey(period.StartTime))
                    {
                        StaffChangingPerDayAndTime[day].Add(period.StartTime, new StaffChangingPoint(day, period.StartTime));
                    } // end if

                    StaffChangingPerDayAndTime[day][period.StartTime].PeriodsStarting.Add(period);

                    if (!StaffChangingPerDayAndTime[day].ContainsKey(period.EndTime))
                    {
                        StaffChangingPerDayAndTime[day].Add(period.EndTime, new StaffChangingPoint(day, period.EndTime));
                    } // end if

                    StaffChangingPerDayAndTime[day][period.EndTime].PeriodsEnding.Add(period);
                } // end foreach

                _sortedChangeTimesPerDay.Add(day, StaffChangingPerDayAndTime[day].Values.Select(p => p.TimeOfDay).OrderBy(q => q.Ticks).ToList());
            } // end foreach

            // initializing staff lists
            _doctors = new List <EntityDoctor>();
            _nurses  = new List <EntityNurse>();

            // -----------------------------------------------------------------------------
            // we assume here that for each availability period new staff members join
            // availability periods can overlap, so to avoid unrealistic shift changes
            // overlaping periods can be used
            // further, staff members are generated separately for each period, to avoid that
            // they can be directly passed to availability periods and will be used here
            // -----------------------------------------------------------------------------

            foreach (KeyValuePair <DayOfWeek, DayTimeLineConfig> dayConfig in DaysPerWeekConfigs)
            {
                _staffPerPeriod[dayConfig.Key] = new Dictionary <StaffAvailabilityPeriod, ResourceAssignmentStaff[]>();

                foreach (StaffAvailabilityPeriod period in dayConfig.Value.StaffAvailabilityPeriods)
                {
                    List <ResourceAssignmentStaff> stafferPeriod = new List <ResourceAssignmentStaff>();

                    if (period.DoctorsAvailable != null)
                    {
                        stafferPeriod.AddRange(period.DoctorsAvailable);
                    }
                    else
                    {
                        foreach (ResourceAssignment <SkillSet> skillAssignment in period.DoctorSkillsAvailable)
                        {
                            stafferPeriod.Add(new ResourceAssignmentStaff(new EntityDoctor(skillAssignment.Resource), skillAssignment.OrganizationalUnit, skillAssignment.AssignmentType));
                        } // end foreach
                    }     // end if

                    if (period.NursesAvailable != null)
                    {
                        stafferPeriod.AddRange(period.NursesAvailable);
                    }
                    else
                    {
                        foreach (ResourceAssignment <SkillSet> skillAssignment in period.NurseSkillsAvailable)
                        {
                            stafferPeriod.Add(new ResourceAssignmentStaff(new EntityNurse(skillAssignment.Resource), skillAssignment.OrganizationalUnit, skillAssignment.AssignmentType));
                        } // end foreach
                    }     // end if

                    _staffPerPeriod[dayConfig.Key].Add(period, stafferPeriod.ToArray());
                } // end foreach
            }     // end foreach
        }         // end of StaffPerPeriodHandler
示例#2
0
        } // end of DayTimeLineConfig

        /// <summary>
        /// Basic constructor for a time line config that consists of a single staff
        /// availability period
        /// </summary>
        /// <param name="staffAvailablities">Staff availability period</param>
        public DayTimeLineConfig(StaffAvailabilityPeriod staffAvailablities)
        {
            _staffAvailabilityPeriods = new StaffAvailabilityPeriod[] { staffAvailablities };
        } // end of DayTimeLineConfig