Example #1
0
        public static void InitializeAppointments()
        {
            List <Appointment> appointmentList = HospitalDB.FetchAppointments();

            foreach (Appointment appointment in appointmentList)
            {
                // Fetching Appointment Patient
                String patientID = HospitalDB.FetchAppointmentPatient(appointment.ID);
                appointment.Patient = (AppointmentPatient)Patients[patientID];
                ((AppointmentPatient)Patients[patientID]).addAppointment(appointment);

                // Fetching Appointment Doctor
                String doctorID = HospitalDB.FetchAppointmentDoctor(appointment.ID);
                appointment.Doctor = (Doctor)Employees[doctorID];
                ((Doctor)Employees[doctorID]).addAppointment(appointment);

                // Adding Doctor, Patient Relations
                if (((Doctor)Employees[doctorID]).Patients.ContainsKey(patientID) == false)
                {
                    ((Doctor)Employees[doctorID]).addPatient(Patients[patientID]);
                }

                if (((AppointmentPatient)Patients[patientID]).Doctors.ContainsKey(doctorID) == false)
                {
                    Patients[patientID].assignDoctor((Doctor)Employees[doctorID]);
                }

                Appointments.Add(appointment.ID, appointment);
            }
        }