} // end of FindControlUnitForSpecialFacitlityService #endregion #region FindControlForOutpatientAdmission /// <summary> /// Finds a control unit that handles a specific outpatient admission type /// </summary> /// <param name="admission">The admission type that is searched for</param> /// <returns>Either a control unit that handles the admission or null if no such control unit exists</returns> public ControlUnit FindControlForOutpatientAdmission(OutpatientAdmissionTypes admission) { if (!HandledOutpatientAdmissionTypes.Contains(admission)) { return(null); } if (!HandledOutpatientAdmissionTypes.Contains(admission)) { if (ParentControlUnit != null) { return(((ControlUnitHealthCare)ParentControlUnit).FindControlForOutpatientAdmission(admission)); } else { return(null); } } // end if if (this.ControlUnitType == Enums.ControlUnitType.Outpatient && this.HandledOutpatientAdmissionTypes.Contains(admission)) { return(this); } else { foreach (ControlUnitHealthCare childControl in ChildHealthCareControlUnits.Where(p => p.HandledOutpatientAdmissionTypes.Contains(admission))) { ControlUnit foundControl = childControl.FindControlForOutpatientAdmission(admission); if (foundControl != null) { return(foundControl); } } // end foreach } // end if return(null); } // end of FindControlForOutpatientAdmission
/// <summary> /// Handles the move or admission of a patient to an outpatient department in the model. The patient is /// directly referred to the outpatient control via the enter method. The handling of arriving /// patients is left to the target control. /// </summary> /// <param name="del">The RequestMoveOutpatient delegate</param> /// <param name="controlUnit">The filing control unit</param> /// <param name="time">Time the request was filed</param> /// <param name="simEngine">SimEngine responsible</param> /// <returns>True if the request could be handled</returns> static public bool HandleMoveOutpatient(IDelegate del, ControlUnit controlUnit, DateTime time, ISimulationEngine simEngine) { #region MoveOutpatient if (del is RequestMoveOutpatient) { ControlUnit controlForAction; RequestMoveOutpatient outDel = (RequestMoveOutpatient)del; OutpatientAdmissionTypes admissionType = (OutpatientAdmissionTypes)outDel.OutpatientAdmission.AdmissionType; controlForAction = ((ControlUnitHealthCare)controlUnit).FindControlForOutpatientAdmission(admissionType); if (controlForAction == null) { controlUnit.SendDelegateTo(controlUnit.ParentControlUnit, outDel); return(true); } else { // patient is referred to the outpatient clinic EntityPatient patient = ((outDel).Patient); patient.StopCurrentActivities(time, simEngine); Event enterEvent = controlForAction.EntityEnterControlUnit(time, simEngine, patient, outDel); enterEvent.Trigger(time, simEngine); return(true); } // end if } // end if #endregion return(true); } // end of HandleMoveOutpatient