} // end of PerformAssessment #endregion #region PerformDisptatching /// <summary> /// Handles requests of staff members to leave that are out of shift, routes action requests /// to corresponding organizational control units and handles a shared treatment facility by /// assigning it to the busier organizational unit /// </summary> /// <param name="startTime">Time rules are executed</param> /// <param name="simEngine">SimEngine responsible for simulation execution</param> /// <returns>False</returns> protected bool PerformDisptatching(DateTime time, ISimulationEngine simEngine) { #region StaffOutsideShift List <RequestBeAbsent> staffEndRequests = RAEL.Where(p => p is RequestBeAbsent).Cast <RequestBeAbsent>().ToList(); foreach (RequestBeAbsent req in staffEndRequests) { if (req.StaffMember.IsWaiting() && req.StaffMember.CurrentPatients.Count == 0) { req.StaffMember.StopCurrentActivities(time, simEngine); EventStaffLeave staffLeave = new EventStaffLeave(req.StaffMember.ParentControlUnit, req.StaffMember); staffLeave.Trigger(time, simEngine); RemoveRequest(req); } // end if } // end foreach #endregion #region RequestRouting List <RequestEmergencyAction> actionRequests = new List <RequestEmergencyAction>(RAEL.Where(p => p.Activity == "ActivityHealthCareAction").Cast <RequestEmergencyAction>()); foreach (RequestEmergencyAction request in actionRequests) { if (request.ActionType.Type == "Triage" || request.ActionType.Type == "Register") { OrganizationalUnitPerName["OrgUnitTriageRegister"].AssignRequest(request); } else { if (request.Patient.PatientClass.Category == "Surgical") { OrganizationalUnitPerName["OrgUnitSurgical"].AssignRequest(request); } else { OrganizationalUnitPerName["OrgUnitInternal"].AssignRequest(request); } } // end if RemoveRequest(request); } // end foreach #endregion #region ResourceSharing foreach (EntityTreatmentFacility sharedTreatFac in AssignedTreatmentFacilities.Where(p => p.AssignmentType == AssignmentType.Shared)) { if (sharedTreatFac.PatientBlocking != null) { continue; } if (sharedTreatFac.CurrentlyAssignedOrganizationalUnit != null) { sharedTreatFac.CurrentlyAssignedOrganizationalUnit.RemoveAssignedTreatmentFacility(sharedTreatFac); } if (OrganizationalUnitPerName["OrgUnitInternal"].RAEL.Count > OrganizationalUnitPerName["OrgUnitSurgical"].RAEL.Count) { OrganizationalUnitPerName["OrgUnitSurgical"].AddAssignedTreatmentFacility(sharedTreatFac); } else { OrganizationalUnitPerName["OrgUnitInternal"].AddAssignedTreatmentFacility(sharedTreatFac); } // end if } // end foreach #endregion return(false); } // end of PerformDisptatching
} // end of WaitInFacilityEnd #endregion #region EventStaffLeave /// <summary> /// Upon staff leave events the drawing object is removed from the system /// </summary> /// <param name="ev">Staff leave event</param> public void EventLeavingStaff(Event ev) { EventStaffLeave staffLeave = (EventStaffLeave)ev; RemoveDrawingObjectPerEntity(staffLeave.StaffLeaving); } // end of EventPatientLeave
} // end of PerformAssessment #endregion #region PerformDisptatching // <summary> /// Handles requests of staff members to leave that are out of shift, register, assessment and treatment /// using patient slot times and priority /// </summary> /// <param name="startTime">Time rules are executed</param> /// <param name="simEngine">SimEngine responsible for simulation execution</param> /// <returns>False</returns> protected bool PerformDisptatching(DateTime time, ISimulationEngine simEngine) { #region StaffOutsideShift List <RequestBeAbsent> staffEndRequests = RAEL.Where(p => p is RequestBeAbsent).Cast <RequestBeAbsent>().ToList(); foreach (RequestBeAbsent req in staffEndRequests) { if (req.StaffMember.IsWaiting() && req.StaffMember.CurrentPatients.Count == 0) { req.StaffMember.StopCurrentActivities(time, simEngine); EventStaffLeave staffLeave = new EventStaffLeave(req.StaffMember.ParentControlUnit, req.StaffMember); staffLeave.Trigger(time, simEngine); RemoveRequest(req); } // end if } // end foreach #endregion #region Register List <RequestOutpatientAction> registerRequests = new List <RequestOutpatientAction>(RAEL.Where(p => p.Activity == "ActivityHealthCareAction" && ((RequestOutpatientAction)p).ActionType.Type == "Register").Cast <RequestOutpatientAction>()); while (registerRequests.Count > 0) { // Get Register request Triage-FIFO RequestOutpatientAction requestRegister = registerRequests.OrderBy(p => p.TimeRequested).First(); ResourceSet chosenResources; if (!ChooseResourcesForAction(requestRegister, out chosenResources)) { break; } // enf if RemoveRequest(requestRegister); registerRequests.Remove(requestRegister); EntityPatient patient = (EntityPatient)requestRegister.Origin.First(); ActivityHealthCareAction <OutpatientActionTypeClass> register = new ActivityHealthCareAction <OutpatientActionTypeClass>( this, InputData, patient, chosenResources, requestRegister.ActionType, patient.OutpatientTreatmentPath); chosenResources.StopCurrentActivities(time, simEngine); patient.StopCurrentActivities(time, simEngine); register.StartEvent.Trigger(time, simEngine); } // end while #endregion #region Assessment List <RequestOutpatientAction> assessmentRequests = new List <RequestOutpatientAction>(RAEL.Where(p => p.Activity == "ActivityHealthCareAction" && ((RequestOutpatientAction)p).ActionType.Type == "Assessment").Cast <RequestOutpatientAction>()); while (assessmentRequests.Count > 0) { ResourceSet chosenResources; // Get Register request Slottime-FIFO RequestOutpatientAction requestAssessment = PatientSlotTimePlusPriority(assessmentRequests); if (!ChooseResourcesForAction(requestAssessment, out chosenResources)) { break; } // enf if // Remove Request from RAEL list RemoveRequest(requestAssessment); assessmentRequests.Remove(requestAssessment); EntityPatient patient = (EntityPatient)requestAssessment.Origin.First(); ActivityHealthCareAction <OutpatientActionTypeClass> assessment = new ActivityHealthCareAction <OutpatientActionTypeClass>( this, InputData, patient, chosenResources, requestAssessment.ActionType, patient.OutpatientTreatmentPath); chosenResources.StopCurrentActivities(time, simEngine); patient.StopCurrentActivities(time, simEngine); assessment.StartEvent.Trigger(time, simEngine); } // end while #endregion #region Treatment List <RequestOutpatientAction> treatmentRequests = new List <RequestOutpatientAction>(RAEL.Where(p => p.Activity == "ActivityHealthCareAction" && ((RequestOutpatientAction)p).ActionType.Type == "Treatment").Cast <RequestOutpatientAction>()); while (treatmentRequests.Count > 0) { ResourceSet chosenResources; // Get Register request Triage-FIFO RequestOutpatientAction requestTreatment = PatientPriorityPlusFIFO <RequestOutpatientAction, OutpatientActionTypeClass>(treatmentRequests); if (!ChooseResourcesForAction(requestTreatment, out chosenResources)) { break; } // enf if // Remove Request from RAEL list and treatmentlist RemoveRequest(requestTreatment); treatmentRequests.Remove(requestTreatment); EntityPatient patient = (EntityPatient)requestTreatment.Origin.First(); ActivityHealthCareAction <OutpatientActionTypeClass> assessment = new ActivityHealthCareAction <OutpatientActionTypeClass>( this, InputData, patient, chosenResources, requestTreatment.ActionType, patient.OutpatientTreatmentPath); chosenResources.StopCurrentActivities(time, simEngine); patient.StopCurrentActivities(time, simEngine); assessment.StartEvent.Trigger(time, simEngine); } // end while #endregion return(false); } // end of PerformDisptatching