} // end of Event #endregion //-------------------------------------------------------------------------------------------------- // Statechange //-------------------------------------------------------------------------------------------------- #region Trigger /// <summary> /// Overriden state change of the event. If the patient's path indicates a inpatient or outpatient /// admission the corresponding request is sent up the control tree. /// </summary> /// <param name="time">Time the patient leaves</param> /// <param name="simEngine">SimEngine responsible for simulation execution</param> protected override void StateChange(DateTime time, ISimulationEngine simEngine) { ParentControlUnit.RemoveEntity(Patient); Patient.CorrespondingDoctor = null; if (Patient.OutpatientTreatmentPath.InpatientAdmission != null) { RequestMoveInpatient reqMoveInpatient = new RequestMoveInpatient(Patient.ToArray(), time, Patient, ParentControlUnit, Patient.OutpatientTreatmentPath.InpatientAdmission); ParentControlUnit.DelegateOutBox.Add(reqMoveInpatient); } // end if if (Patient.OutpatientTreatmentPath.OutpatientAdmission != null) { RequestMoveOutpatient reqMoveOutPatient = new RequestMoveOutpatient(Patient.ToArray(), time, Patient, ParentControlUnit, Patient.OutpatientTreatmentPath.OutpatientAdmission); ParentControlUnit.DelegateOutBox.Add(reqMoveOutPatient); } // end if Patient.OutpatientTreatmentPath = null; } // end of Trigger
} // end of HandleMoveOutpatient #endregion #region HandleMoveInpatient /// <summary> /// Handles the move or admission of a patient to an inpatient department in the model. The patient is /// directly referred to the inpatient control via the enter method. The handling of arriving /// patients is left to the target control. /// </summary> /// <param name="del">The RequestMoveInpatient 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 HandleMoveInpatient(IDelegate del, ControlUnit controlUnit, DateTime time, ISimulationEngine simEngine) { #region MoveInpatient if (del is RequestMoveInpatient) { ControlUnit controlForAction; RequestMoveInpatient outDel = (RequestMoveInpatient)del; InpatientAdmissionTypes admissionType = (InpatientAdmissionTypes)outDel.InpatientAdmission.AdmissionType; controlForAction = ((ControlUnitHealthCare)controlUnit).FindControlForInpatientAdmission(admissionType); if (controlForAction == null) { controlUnit.SendDelegateTo(controlUnit.ParentControlUnit, outDel); return(true); } else { 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 HandleMoveInpatient