//Removes a patient from ward public void TransferPatient(Patient patient) { DeliveryRoom tempRoom = Ward.DeliveryRooms.Find(x => x.PatientsInRoom.Contains(patient)); if (tempRoom != null) { if (patient.Children.Count > 0) { foreach (Patient child in patient.Children) { if (tempRoom.PatientsInRoom.Contains(child)) { tempRoom.PatientsInRoom.Remove(child); CurrentPatients.Remove(child); } } } tempRoom.PatientsInRoom.Remove(patient); CurrentPatients.Remove(patient); tempRoom.Occupied = false; } else { throw new ArgumentException("Input patient not found in room"); } }
public static void ReadRooms(string FilePath) { Stream AccountFile = File.Open(FilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); using (StreamReader sr = new StreamReader(AccountFile)) { string _tempString; string[] _subStrings; DeliveryRoom currentRoom; while ((_tempString = sr.ReadLine()) != null) { _subStrings = _tempString.Split(' '); currentRoom = new DeliveryRoom(Convert.ToInt32(_subStrings[0]), Convert.ToBoolean(_subStrings[1])); Ward.DeliveryRooms.Add(currentRoom); if (_subStrings.Length > 2) { for (int i = 2; i < _subStrings.Length; i++) { currentRoom.PatientsInRoom.Add(Ward.Patients.Find(x => x.CPR == _subStrings[i])); } } } } }
public void DischargePatientFromRoom(DeliveryRoom room) { if (room.PatientsInRoom.Contains(this)) { room.PatientsInRoom.Remove(this); } else { throw new ArgumentException(Name + " with CPR:" + CPR.ToString() + " is NOT in room:" + room.RoomID.ToString()); } }
public void AdmitPatientToRoom(DeliveryRoom room) { if (!room.PatientsInRoom.Contains(this)) { room.PatientsInRoom.Add(this); } else { throw new ArgumentException(Name + " with CPR:" + CPR.ToString() + " is already in room:" + room.RoomID.ToString()); } }
//Puts a patient in a vacant room private void AssignPatientToDRoom(Patient _patient) { DeliveryRoom currentRoom = Ward.DeliveryRooms.Find(x => x.Occupied == false); if (currentRoom != null) { currentRoom.PatientsInRoom.Add(_patient); currentRoom.Occupied = true; } else { throw new Exception("There are no empty rooms to assign patients to"); } }