예제 #1
0
        public static void InitializePatients()
        {
            List <Patient> patientList = HospitalDB.FetchPatients();

            foreach (Patient patient in patientList)
            {
                // Assigning Patient's Doctors
                List <String> doctorsIDs = HospitalDB.FetchPatientDoctors(patient.ID);
                foreach (String doctorID in doctorsIDs)
                {
                    patient.assignDoctor((Doctor)Employees[doctorID]);
                    ((Doctor)Employees[doctorID]).addPatient(patient);
                }

                if (patient.GetType() == typeof(ResidentPatient))
                {
                    // Fetching Patient's Department
                    String departmentID = HospitalDB.FetchPersonDepartment(patient.ID);
                    if (Departments.ContainsKey(departmentID))
                    {
                        ((ResidentPatient)patient).Department = Departments[departmentID];
                        Departments[departmentID].Patients.Add(patient.ID, patient);
                    }

                    // Fetching Patient's Room from Database
                    String roomID = HospitalDB.FetchPatientRoom(patient.ID);

                    if (Rooms.ContainsKey(roomID))
                    {
                        Rooms[roomID].addPatient(patient);
                        ((ResidentPatient)patient).Room = Rooms[roomID];

                        // Assigning Patients to Nurses in the Same Room
                        foreach (Nurse nurse in Rooms[roomID].Nurses.Values)
                        {
                            nurse.addPatient(patient);
                        }
                    }


                    // Fetching Patient's Medicine from Database
                    List <Medicine> medicineList = HospitalDB.FetchMedicine(patient.ID);
                    foreach (Medicine medicine in medicineList)
                    {
                        ((ResidentPatient)patient).addMedicine(new Medicine
                        {
                            ID           = medicine.ID,
                            Name         = medicine.Name,
                            StartingDate = medicine.StartingDate,
                            EndingDate   = medicine.EndingDate
                        });
                    }
                }

                Patients.Add(patient.ID, patient);
            }
        }