} // 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 InputData #endregion //-------------------------------------------------------------------------------------------------- // Enter Leave //-------------------------------------------------------------------------------------------------- #region EntityEnterControlUnit public override Event EntityEnterControlUnit(DateTime time, ISimulationEngine simEngine, Entity entity, IDelegate originDelegate) { if (entity is EntityHealthCareStaff) { return(new EventControlUnitStaffEnterLeave(this, true, (EntityStaff)entity, originDelegate, WaitingRoomForStaff((EntityHealthCareStaff)entity))); } EntityPatient patient = (EntityPatient)entity; if (originDelegate is RequestSpecialFacilitiyService) { return(new EventOutpatientArrival(this, patient, time, InputData, null)); } else if (originDelegate is RequestMoveOutpatient) { RequestMoveOutpatient outDel = (RequestMoveOutpatient)originDelegate; return(new EventOutpatientWaitingListPatientArrival( WaitingListControlUnit, this, patient, outDel.OutpatientAdmission, InputData)); } // end if return(null); } // end of EntityEnterControlUnit
/// <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