Beispiel #1
0
        } // end of PatientSpecialActionTime

        #endregion

        #region CreatePatientPath

        /// <summary>
        /// Method for patient path creation, uses core path method from base class
        /// and casts action list for special service
        /// </summary>
        /// <param name="admission">Admission type for special service</param>
        /// <param name="patient">Patient the path is created for</param>
        /// <param name="orignalRequest">Request that is the basis for the patient being admitted to the special service control</param>
        /// <returns>Patient path</returns>
        public SpecialServicePatientPath CreatePatientPath(SpecialServiceAdmissionTypes admission,
                                                           EntityPatient patient,
                                                           RequestSpecialFacilitiyService orignalRequest)
        {
            List <ActionTypeClass> actions;
            Admission outpatientAdmission;
            Admission inpatientAdmission;

            GetCorePath(patient, admission, out actions, out outpatientAdmission, out inpatientAdmission);

            return(new SpecialServicePatientPath(actions.Select(p => new SpecialServiceActionTypeClass(p)).ToList(), orignalRequest, patient));
        } // end of CreatePatientPath
Beispiel #2
0
        } // end of OutpatientAdmission

        #endregion

        //--------------------------------------------------------------------------------------------------
        // Methods
        //--------------------------------------------------------------------------------------------------

        #region TakeNextAction

        /// <summary>
        /// Action taking along path. Different actions for diagnostics, leaving and
        /// actions within the emergency 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 == "Diagnostics")
            {
                RequestSpecialFacilitiyService reqeustForDiagnostics
                    = new RequestSpecialFacilitiyService(parentDepartmentControl,
                                                         ParentPatient,
                                                         time,
                                                         new SpecialServiceAdmissionTypes(GetCurrentActionType().Identifier));

                parentDepartmentControl.DelegateOutBox.Add(reqeustForDiagnostics);
                return(false);
            } // end if

            if (GetCurrentActionType().Type == "Leave")
            {
                EventEmergencyPatientLeave patientLeave = new EventEmergencyPatientLeave(parentDepartmentControl, ParentPatient, ((ControlUnitEmergency)parentDepartmentControl).InputData);
                currentEvent.SequentialEvents.Add(patientLeave);
                return(false);
            } // end if

            EmergencyActionTypeClass currentType = GetCurrentActionType();

            RequestEmergencyAction req =
                new RequestEmergencyAction(ParentPatient,
                                           0,
                                           currentType,
                                           time,
                                           new ResourceSet(ParentPatient.CorrespondingDoctor,
                                                           ParentPatient.CorrespondingNurse, null));

            parentControlUnit.AddRequest(req);

            if (currentType.IsHold)
            {
                return(false);
            }

            return(true);
        } // end of TakeNextAction
        } // end of HandleServiceRequestSpecialTreatmentModel

        #endregion

        #region BookImmediateServiceRequestSpecialTreatmentModel

        /// <summary>
        /// Standard method, to be used when special service does nor require special booking
        /// and can be "booked" immidiately. An availability delegate is sent back to
        /// the requesting control unit
        /// </summary>
        /// <param name="del">The original requests</param>
        /// <param name="controlUnit">The control unit that handles the service 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 BookImmediateServiceRequestSpecialTreatmentModel(IDelegate del,
                                                                            ControlUnit controlUnit,
                                                                            DateTime time,
                                                                            ISimulationEngine simEngine)
        {
            RequestSpecialFacilitiyService serviceRequest = (RequestSpecialFacilitiyService)del;

            ControlUnitSpecialServiceModel specialFacilityControl = (ControlUnitSpecialServiceModel)controlUnit;

            Slot slot = specialFacilityControl.WaitingListSchedule.GetEarliestSlotTime(time,
                                                                                       time,
                                                                                       serviceRequest.Patient,
                                                                                       new Admission(serviceRequest.Patient, serviceRequest.SpecialFacilityAdmissionTypes));

            DelegateAvailabilitiesForRequest availDel = new DelegateAvailabilitiesForRequest(specialFacilityControl, serviceRequest, SpecialServiceBookingTypes.Immediate, Helpers <Slot> .ToList(slot));

            controlUnit.SendDelegateTo(del.OriginControlUnit, availDel);

            return(true);
        } // end of
        } // 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
Beispiel #5
0
        } // end of RemoveEntity

        #endregion

        //--------------------------------------------------------------------------------------------------
        // Find ControlUnits
        //--------------------------------------------------------------------------------------------------

        #region FindControlUnitForSpecialFacitlityService

        /// <summary>
        /// Looks for a control unit in the tree that handles a specific special facility service (e.g. diagnostics)
        /// request
        /// </summary>
        /// <param name="request">The special facility service request</param>
        /// <returns>Either a control unit that handles the request or null if no such control unit exists</returns>
        public ControlUnit FindControlUnitForSpecialFacitlityService(RequestSpecialFacilitiyService request)
        {
            if (request is RequestSpecialFacilitiyService)
            {
                if (!HandledSpecialFacilityAdmissionTypes.Contains(((RequestSpecialFacilitiyService)request).SpecialFacilityAdmissionTypes))
                {
                    if (ParentControlUnit != null)
                    {
                        return(((ControlUnitHealthCare)ParentControlUnit).FindControlUnitForSpecialFacitlityService((RequestSpecialFacilitiyService)request));
                    }
                    else
                    {
                        return(null);
                    }
                } // end if

                if (this.ControlUnitType == Enums.ControlUnitType.SpecialFacilityModel &&
                    this.HandledSpecialFacilityAdmissionTypes.Contains(((RequestSpecialFacilitiyService)request).SpecialFacilityAdmissionTypes))
                {
                    return(this);
                }
                else
                {
                    foreach (ControlUnitHealthCare child in ChildHealthCareControlUnits.Where(p => p.HandledSpecialFacilityAdmissionTypes.Contains(((RequestSpecialFacilitiyService)request).SpecialFacilityAdmissionTypes)))
                    {
                        ControlUnit foundControl = child.FindControlUnitForSpecialFacitlityService(request);
                        if (foundControl != null)
                        {
                            return(foundControl);
                        }
                    } // end foreach
                }     // end if
            }         // end if

            return(null);
        } // end of FindControlUnitForSpecialFacitlityService