private static void ParseCommand(string[] commandArgs) { string departmentName = commandArgs[0]; string doctorFirstName = commandArgs[1]; string doctorLastName = commandArgs[2]; string patientName = commandArgs[3]; if (!departments.Any(d => d.Name == departmentName)) { departments.Add(new Department(departmentName)); } Department department = departments.Single(d => d.Name == departmentName); Patient patient = new Patient(patientName); department.AddPatientToRoom(patient); if (!doctors.Any(d => d.FirstName == doctorFirstName && d.LastName == doctorLastName)) { doctors.Add(new Doctor(doctorFirstName, doctorLastName)); } Doctor doctor = doctors.Single(d => d.FirstName == doctorFirstName && d.LastName == doctorLastName); doctor.AddPatient(patient); }
public void AddPatient(string departmentName, string doctorName, string patientName) { Department currentDepartment = this.Departments.FirstOrDefault(dep => dep.Name == departmentName); Doctor currentDoctor = this.Doctors.FirstOrDefault(d => d.FullName == doctorName); Patient patient = new Patient(patientName); currentDepartment.AddPatientInRoom(patient); currentDoctor.AddPatient(patient); }
public void Doctor_DeletePatientRelationship_DeletesRelationship() { Doctor doctor = new Doctor("Tom", "tom567", "567", "Cardiology"); doctor.Save(); Patient patient1 = new Patient("John", "john123", "123", new DateTime(1996, 04, 25)); patient1.Save(); Patient patient2 = new Patient("Tom", "john123", "123", new DateTime(1996, 04, 25)); patient2.Save(); doctor.AddPatient(patient1); doctor.AddPatient(patient2); doctor.DeletePatientRelationship(patient1); List <Patient> testList = doctor.GetPatients(); List <Patient> controlList = new List <Patient> { patient2 }; Assert.Equal(controlList, testList); }
public void Doctor_AddPatient_AssignsPatientToDoctor() { Doctor newDoctor = new Doctor("Tom", "tom567", "567", "Cardiology"); newDoctor.Save(); Patient newPatient = new Patient("John", "john123", "123", new DateTime(1996, 04, 25)); newPatient.Save(); newDoctor.AddPatient(newPatient); List <Patient> testList = newDoctor.GetPatients(); List <Patient> controlList = new List <Patient> { newPatient }; Assert.Equal(controlList, testList); }