Exemplo n.º 1
0
        public static void InitializeEmployees()
        {
            List <Doctor> doctorList = HospitalDB.FetchDoctors();

            foreach (Doctor doctor in doctorList)
            {
                // Fetching Doctor's Department
                String departmentID = HospitalDB.FetchPersonDepartment(doctor.ID);

                // Assigning Doctor to his Department
                if (Departments.ContainsKey(departmentID))
                {
                    doctor.Department = Departments[departmentID];
                    Departments[departmentID].addDoctor(doctor);

                    // Checking if the Doctor is the Department's Head
                    if (doctor.IsHead)
                    {
                        Departments[departmentID].HeadID = doctor.ID;
                    }
                }


                Employees.Add(doctor.ID, doctor);
            }

            List <Nurse> nurseList = HospitalDB.FetchNurses();

            foreach (Nurse nurse in nurseList)
            {
                // Fetching Nurse's Department
                String departmentID = HospitalDB.FetchPersonDepartment(nurse.ID);

                // Assigning Nurse to her Department
                if (Departments.ContainsKey(departmentID))
                {
                    nurse.Department = Departments[departmentID];
                    Departments[departmentID].addNurse(nurse);
                }

                // Fetching Nurse's Rooms
                List <String> roomsID = HospitalDB.FetchNurseRooms(nurse.ID);

                // Assigning Nurses to their Rooms
                foreach (String roomID in roomsID)
                {
                    nurse.addRoom(Rooms[roomID]);
                    Rooms[roomID].addNurse(nurse);
                }

                Employees.Add(nurse.ID, nurse);
            }
        }