public int GetCritical() { List <Patient> patientsToRemove = new List <Patient>(); lock (allPatientsLock) { foreach (Patient p in AllPatients) { if (DateTime.Now - p.ArrivedTime > Details.CriticalWaitingTimeA && p.Injury.Category == Category.A) { patientsToRemove.Add(p); p.Critical = true; } else if (DateTime.Now - p.ArrivedTime > Details.CriticalWaitingTimeB && p.Injury.Category == Category.B) { patientsToRemove.Add(p); p.Critical = true; } else if (DateTime.Now - p.ArrivedTime > Details.CriticalWaitingTimeB && p.Injury.Category == Category.C) { patientsToRemove.Add(p); p.Critical = true; } else if (DateTime.Now - p.ArrivedTime > Details.CriticalWaitingTimeB && p.Injury.Category == Category.D) { patientsToRemove.Add(p); p.Critical = true; } } } foreach (Patient p in patientsToRemove) { lock (allPatientsLock) { AllPatients.Remove(p); } PatientsA.Remove(p); PatientsB.Remove(p); PatientsC.Remove(p); PatientsD.Remove(p); } return(patientsToRemove.Count); }
private void RemoveWaitingPatient(Patient patient) { Category category = patient.Injury.Category; switch (category) { case Category.A: PatientsA.Remove(patient); break; case Category.B: PatientsB.Remove(patient); break; case Category.C: PatientsC.Remove(patient); break; case Category.D: PatientsD.Remove(patient); break; } }
private void AddPatientToWaitingList(Patient p) { Category category = p.Injury.Category; switch (category) { case Category.A: PatientsA.Add(p); break; case Category.B: PatientsB.Add(p); break; case Category.C: PatientsC.Add(p); break; case Category.D: PatientsD.Add(p); break; } }