} // end of Event

        #endregion

        //--------------------------------------------------------------------------------------------------
        // State Change
        //--------------------------------------------------------------------------------------------------

        #region Trigger

        /// <summary>
        /// State change of event. Sends patient to the special service model
        /// </summary>
        /// <param name="time">Time event is triggered</param>
        /// <param name="simEngine">SimEngine responsible for simulation execution</param>
        protected override void StateChange(DateTime time, ISimulationEngine simEngine)
        {
            ControlUnitManagement jointControl = (ControlUnitManagement)ParentControlUnit.FindSmallestJointControl(Availability.ServiceControl);

            if (Patient != null)
            {
                ActivityMove movePatientToSpecialTreatment
                    = new ActivityMove(jointControl,
                                       Patient,
                                       ParentControlUnit,
                                       Availability.ServiceControl,
                                       ReturnDelegate,
                                       jointControl.InputData.DurationMove(Patient,
                                                                           ParentControlUnit,
                                                                           Availability.ServiceControl));
                SequentialEvents.Add(movePatientToSpecialTreatment.StartEvent);
            } // end if
        }     // end of Trigger
Exemplo n.º 2
0
        } // end of OriginalRequest

        #endregion

        #region TakeNextAction

        /// <summary>
        /// Action taking along path. Different actions for return and
        /// actions within the special service department
        /// </summary>
        /// <param name="simEngine">SimEngine responsible for simulation execution</param>
        /// <param name="currentEvent">Event after which next action is taken</param>
        /// <param name="time">Time next action is taken</param>
        /// <param name="parentControlUnit">Control unit that hosts the next action</param>
        /// <returns>Returns true if Patient goes in an waiting activitiy before next action, else false </returns>
        public override bool TakeNextAction(
            ISimulationEngine simEngine,
            Event currentEvent,
            DateTime time,
            ControlUnit parentControlUnit)
        {
            ControlUnit parentDepartmentControl = parentControlUnit;

            if (parentControlUnit is ControlUnitOrganizationalUnit)
            {
                parentDepartmentControl = ((ControlUnitOrganizationalUnit)parentControlUnit).ParentDepartmentControl;
            }

            if (GetCurrentActionType().Type == "Return")
            {
                ControlUnitManagement jointControl = (ControlUnitManagement)parentControlUnit.FindSmallestJointControl(OriginalRequest.OriginControlUnit);

                ActivityMove movePatientBack = new ActivityMove(parentControlUnit,
                                                                ParentPatient,
                                                                parentDepartmentControl,
                                                                OriginalRequest.OriginControlUnit,
                                                                OriginalRequest,
                                                                jointControl.InputData.DurationMove(ParentPatient,
                                                                                                    parentControlUnit,
                                                                                                    OriginalRequest.OriginControlUnit));


                movePatientBack.StartEvent.Trigger(time, simEngine);

                return(false);
            } // end if

            SpecialServiceActionTypeClass currentType = GetCurrentActionType();

            RequestSpecialFacilityAction req =
                new RequestSpecialFacilityAction(ParentPatient, 0, currentType, time, new ResourceSet());

            parentControlUnit.AddRequest(req);

            return(true);
        } // end if TakeNextAction
        } // end of PerformDisptatching

        #endregion

        #region PerformControlled

        /// <summary>
        /// Sends assisting staff members that are not further required back to their origin
        /// control unit
        /// </summary>
        /// <param name="startTime">Time rules are executed</param>
        /// <param name="simEngine">SimEngine responsible for simulation execution</param>
        /// <returns>False</returns>
        protected bool PerformControlled(DateTime time, ISimulationEngine simEngine)
        {
            IEnumerable <EntityDoctor>            assistingDocs    = HandledDoctors.Where(p => p.BaseControlUnit != this);
            IEnumerable <RequestOutpatientAction> assistedRequests = RAEL.Where(p => p.GetType() == typeof(RequestOutpatientAction) && ((RequestOutpatientAction)p).IsAssistedDoctor).Cast <RequestOutpatientAction>().ToList();

            bool moveTriggered = false;

            foreach (EntityDoctor doc in assistingDocs)
            {
                bool skillRequired = false;

                if (doc.IsWaiting())
                {
                    foreach (RequestOutpatientAction req in assistedRequests)
                    {
                        foreach (SkillSet skillSet in req.ActionType.AssistingDoctorRequirements)
                        {
                            if (doc.SatisfiesSkillSet(skillSet))
                            {
                                skillRequired = true;
                            }
                        } // end foreach
                    }     // end foreach

                    if (!skillRequired)
                    {
                        ControlUnitManagement jointControl = (ControlUnitManagement)FindSmallestJointControl(doc.BaseControlUnit);
                        ActivityMove          moveBack     = new ActivityMove(jointControl, doc, this, doc.BaseControlUnit, null, jointControl.InputData.DurationMove(doc, this, doc.BaseControlUnit));
                        doc.StopCurrentActivities(time, simEngine);
                        moveBack.StartEvent.Trigger(time, simEngine);
                        moveTriggered = true;
                    } // end if
                }     // end if
            }         // end foreach


            return(moveTriggered);

            return(false);
        } // end of PerformControlled
Exemplo n.º 4
0
        } // end of

        #endregion

        #region HandleImmediateSpecialServiceRequest

        /// <summary>
        /// Standard method to handle a "immediate" booking of a special service control.
        /// Sends the patient on a move from the requesting control to the special service control.
        /// </summary>
        /// <param name="del">The availability delegate</param>
        /// <param name="controlUnit">The control unit that filed the original request</param>
        /// <param name="time">Time the request is filed</param>
        /// <param name="simEngine">SimEngine responsible for simulation execution</param>
        /// <returns>True if request has been handled</returns>
        public static bool HandleImmediateSpecialServiceRequest(IDelegate del, ControlUnit controlUnit, DateTime time, ISimulationEngine simEngine)
        {
            #region ServiceRequests

            DelegateAvailabilitiesForRequest availability = (DelegateAvailabilitiesForRequest)del;

            if (availability.BookingType != SpecialServiceBookingTypes.Immediate)
            {
                throw new InvalidOperationException("Only immediate bookings handled");
            }

            if (availability.OriginalServiceRequest is RequestSpecialFacilitiyService)
            {
                RequestSpecialFacilitiyService req = (RequestSpecialFacilitiyService)availability.OriginalServiceRequest;

                ControlUnitManagement jointControl = (ControlUnitManagement)controlUnit.ParentControlUnit.FindSmallestJointControl(availability.ServiceControl);

                ActivityMove movePatientToSpecialTreatment
                    = new ActivityMove(jointControl,
                                       req.Patient,
                                       controlUnit,
                                       availability.ServiceControl,
                                       req,
                                       jointControl.InputData.DurationMove(req.Patient,
                                                                           controlUnit,
                                                                           availability.ServiceControl));

                req.Patient.StopWaitingActivity(time, simEngine);
                movePatientToSpecialTreatment.StartEvent.Trigger(time, simEngine);

                return(true);
            } // end if

            #endregion

            return(false);
        } // end of HandleAvailabilitiesSpecialServiceRequest