} // end of Event #endregion //-------------------------------------------------------------------------------------------------- // State Change //-------------------------------------------------------------------------------------------------- #region Trigger /// <summary> /// Acutal state change of arrival. If patient arrives from waiting list path is set, otherwise /// next action is taken. /// </summary> /// <param name="time">Time the patient arrives</param> /// <param name="simEngine">SimEngine responsible for simulation execution</param> protected override void StateChange(DateTime time, ISimulationEngine simEngine) { //-------------------------------------------------------------------------------------------------- // In case Patient is returning from special service facility the path // has already been set and needs update to next action //-------------------------------------------------------------------------------------------------- if (Patient.OutpatientTreatmentPath != null) { Patient.OutpatientTreatmentPath.UpdateNextAction(); } else { Patient.OutpatientTreatmentPath = InputData.CreateOutpatientTreatmentPath(Patient, Admission, ScheduledTime, false); ParentControlUnit.AddEntity(Patient); } // end if if (Patient.OutpatientTreatmentPath.TakeNextAction(simEngine, this, time, ParentControlUnit)) { if (Patient.OccupiedFacility == null || Patient.OccupiedFacility.ParentDepartmentControl != ParentControlUnit) { SequentialEvents.Add(Patient.StartWaitingActivity(((ControlUnitOutpatient)ParentControlUnit).WaitingAreaPatientForNextActionType(Patient.OutpatientTreatmentPath.GetCurrentActionType()))); } else { ActivityWaitInFacility waitInFacility = new ActivityWaitInFacility(ParentControlUnit, Patient, Patient.OccupiedFacility); SequentialEvents.Add(waitInFacility.StartEvent); } // end if } // end if } // end of Trigger
} // end of HealthCareActionEnd #endregion #region WaitInFacilityEnd /// <summary> /// Method that visualized the end of a wait in facility activity, patient is removed from /// the drawing system /// </summary> /// <param name="activity">Instance of wait in facility activity</param> /// <param name="time">Time the activity is ended</param> public void WaitInFacilityEnd(Activity activity, DateTime time) { ActivityWaitInFacility waitInFrac = (ActivityWaitInFacility)activity; if (waitInFrac.Facility is EntityMultiplePatientTreatmentFacility) { return; } RemoveDrawingObjectPerEntity(waitInFrac.Patient); } // end of WaitInFacilityEnd
} // end of WaitInFacilityEnd #endregion #region WaitInFacilityStart /// <summary> /// Method that visualized the start of a wait in facility action, patient is added to /// the drawing system and set to the corresponding positions in the treatment facility /// (if it is not a multiple patient treatment facility). /// </summary> /// <param name="activity">Instance of health care action</param> /// <param name="time">Time the activity is started</param> public void WaitInFacilityStart(Activity activity, DateTime time) { ActivityWaitInFacility waitInFac = (ActivityWaitInFacility)activity; if (waitInFac.Facility is EntityMultiplePatientTreatmentFacility) { return; } DrawPatient drawPatient = (DrawPatient)DrawingObjectPerEntity(waitInFac.Patient); DrawTreatmentFacility drawTreatFac = (DrawTreatmentFacility)ParentDepartmentVisualization.DrawingObjectPerEntity(waitInFac.Facility); drawPatient.SetPositionType(drawTreatFac.PatientPositionType); drawPatient.SetPosition(drawTreatFac.PatientInRoomPosition); } // end of WaitInFacilityEnd
} // end of Event #endregion //-------------------------------------------------------------------------------------------------- // State Change //-------------------------------------------------------------------------------------------------- #region StateChange /// <summary> /// Overriden state change of the event. If the patient is arrving externaly then the next arrival is /// scheduled. Else the path is updated and the next/first action is taken from the path. /// </summary> /// <param name="time">Time the patient arrives</param> /// <param name="simEngine">SimEngine responsible for simulation execution</param> protected override void StateChange(DateTime time, ISimulationEngine simEngine) { // if patient has a path it is updated if (Patient.EmergencyTreatmentPath != null) { Patient.EmergencyTreatmentPath.UpdateNextAction(); } else { // if patient has no path he is arriving externaly // path is created Patient.EmergencyTreatmentPath = ((ControlUnitEmergency)ParentControlUnit).InputData.CreateEmergencyPath(Patient); // patient is added to control unit ParentControlUnit.AddEntity(Patient); // arrival of next patient is created and scheduled EntityPatient nextPatient = ((ControlUnitEmergency)ParentControlUnit).InputData.GetNextPatient(); EventEmergencyPatientArrival nextPatientArrival = new EventEmergencyPatientArrival(ParentControlUnit, nextPatient, InputData); simEngine.AddScheduledEvent(nextPatientArrival, time + ((ControlUnitEmergency)ParentControlUnit).InputData.PatientArrivalTime(time)); } // end if // next action on path is taken if (Patient.EmergencyTreatmentPath.TakeNextAction(simEngine, this, time, ParentControlUnit)) { // possible waiting or waiting in facility is triggered if (Patient.OccupiedFacility == null || Patient.OccupiedFacility.ParentDepartmentControl != ParentControlUnit) { SequentialEvents.Add(Patient.StartWaitingActivity(((ControlUnitEmergency)ParentControlUnit).WaitingAreaPatientForNextActionType(Patient.EmergencyTreatmentPath.GetCurrentActionType()))); } else { ActivityWaitInFacility waitInFacility = new ActivityWaitInFacility(ParentControlUnit, Patient, Patient.OccupiedFacility); SequentialEvents.Add(waitInFacility.StartEvent); } // end if } // end if } // end of Trigger