コード例 #1
0
        /**
         * Checks if a given appointment is available, based on
         * doctor chosen and timeslot
         *
         * @param appointment Appointment object representing desired
         *  appointment information
         * @returns true if there is a slot open at that time with that
         *  doctor, otherwise false
         */
        public static bool IsAppointmentAvailable(AppointmentInfo appointment)
        {
            HospitalSystemEntities1 entities = new HospitalSystemEntities1();

            List <HospitalSystem.Appointment> appointments =
                (from appt in entities.Appointments
                 where (appt.DoctorID == appointment.DoctorID) && (appt.Time == appointment.TimeSlot)
                 select appt).ToList();

            return(appointments.Count == 0);
        }
コード例 #2
0
        public static Appointment GetAppointmentID(AppointmentInfo appointment)
        {
            HospitalSystemEntities1 entities = new HospitalSystemEntities1();

            List <HospitalSystem.Appointment> matches = (
                from appt in entities.Appointments
                where
                appt.DoctorID == appointment.DoctorID &&
                appt.PatientID == appointment.PatientID &&
                appt.Time == appointment.TimeSlot
                select appt).ToList();

            return(matches.First());
        }
コード例 #3
0
        /**
         * Creates an appointment in the database with the information
         * given in the provided Appointment object
         *
         * @param appointment Appointment object representing appointment
         *  information
         * @returns true on success, false on failure
         */
        public static bool CreateAppointment(AppointmentInfo appointment)
        {
            HospitalSystemEntities1 entities = new HospitalSystemEntities1();

            Appointment appt = new Appointment();

            appt.Date         = appointment.TimeSlot;
            appt.Time         = appointment.TimeSlot;
            appt.PatientID    = appointment.PatientID;
            appt.DoctorID     = appointment.DoctorID;
            appt.Purpose      = appointment.Purpose;
            appt.VisitSummary = "";

            entities.Appointments.Add(appt);

            entities.SaveChanges();

            return(true);
        }