protected void ButtonDeleteMessage_Click(object sender, EventArgs e)
        {
            HospitalSystemEntities1 entities = new HospitalSystemEntities1();
            List <Message>          messages = getMessages();

            Message selected = messages[DropDownListMessages.SelectedIndex];

            entities.Messages.Attach(selected);
            entities.Messages.Remove(selected);
            entities.SaveChanges();

            ListBoxMessages.Items.Clear();
            DropDownListMessages.Items.Clear();
            if (messages.Count < 1)
            {
                ListBoxMessages.Items.Add("You have no messages.");
                DropDownListMessages.Items.Add("You have no messages.");
            }
            else
            {
                foreach (Message message in messages)
                {
                    ListBoxMessages.Items.Add(
                        message.MessageFROM + ": " + message.Message1
                        );
                    DropDownListMessages.Items.Add(
                        message.MessageFROM + ": " + message.Message1
                        );
                }
            }

            ListBoxMessages.DataBind();
            DropDownListMessages.DataBind();
        }
Esempio n. 2
0
        protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
        {
            HospitalSystemEntities1 entities = new HospitalSystemEntities1();

            string givenUser = Login1.UserName;
            string givenPass = Login1.Password;

            List <User> potentialUsers = (
                from user in entities.Users
                where
                user.UserLoginName == givenUser &&
                user.UserLoginPass == givenPass
                select user).ToList();

            if (potentialUsers.Count > 0)
            {
                Session["user"] = givenUser;

                string type = potentialUsers[0].UserLoginType.Trim();

                if (type == "doctor")
                {
                    Response.Redirect("~/Doctor/DoctorHome.aspx");
                    return;
                }
                else if (type == "patient")
                {
                    Response.Redirect("~/Patient/PatientHome.aspx");
                    return;
                }
            }
        }
Esempio n. 3
0
        /**
         * Get an appointment by its associated appointment ID
         *
         * @param appointmentID the id of the appointment to retrieve
         * @returns the associated appointment, otherwise null
         */
        public static Appointment GetAppointmentByID(int appointmentID)
        {
            HospitalSystemEntities1 entities = new HospitalSystemEntities1();

            HospitalSystem.Appointment appointment = (from appt in entities.Appointments where appt.AppointmentID == appointmentID select appt).First();

            return(appointment);
        }
Esempio n. 4
0
        public static Patient GetPatientByUserName(string username)
        {
            HospitalSystemEntities1 entities = new HospitalSystemEntities1();

            return((from patient in entities.Patients
                    where
                    patient.UserLoginName == username
                    select patient).First());
        }
Esempio n. 5
0
        public static Doctor GetDoctorByUserName(string username)
        {
            HospitalSystemEntities1 entities = new HospitalSystemEntities1();

            return((from doctor in entities.Doctors
                    where
                    doctor.UserLoginName == username
                    select doctor).First());
        }
Esempio n. 6
0
        /**
         * Get all the appointments for the given doctor
         *
         * @param doctorID id of the doctor to retrieve the appointments
         *  of
         * @returns List of Appointment objects representing the scheduled
         *  appointments of the given doctor
         */
        public static List <Appointment> GetDoctorAppointments(int doctorID)
        {
            HospitalSystemEntities1 entities = new HospitalSystemEntities1();

            return((
                       from appt in entities.Appointments
                       where
                       appt.DoctorID == doctorID
                       select appt
                       ).ToList <Appointment>());
        }
Esempio n. 7
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);
        }
Esempio n. 8
0
        /**
         * Get all the appointments for the given patient
         *
         * @param patientID id of the patient to retrieve the appointments
         *  of
         * @returns List of Appointment objects representing the scheduled
         *  appointments of the given patient
         */
        public static List <Appointment> GetPatientAppointments(int patientID)
        {
            HospitalSystemEntities1 entities = new HospitalSystemEntities1();

            return((
                       from appt in entities.Appointments
                       where
                       appt.PatientID == patientID
                       select appt
                       ).ToList());
        }
        private List <Message> getMessages()
        {
            HospitalSystemEntities1 entities = new HospitalSystemEntities1();

            Doctor doctor = getLoggedInDoctor();

            return((
                       from message in entities.Messages
                       where
                       message.MessageTO == doctor.FirstName + " " + doctor.LastName
                       select message).ToList());
        }
        private List <Message> getMessages()
        {
            HospitalSystemEntities1 entities = new HospitalSystemEntities1();

            Patient patient = getLoggedInPatient();

            return((
                       from message in entities.Messages
                       where
                       message.MessageTO == patient.FirstName + " " + patient.LastName
                       select message).ToList());
        }
Esempio n. 11
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());
        }
        private bool sendMessage(Doctor doctor, Patient patient, string content)
        {
            HospitalSystemEntities1 entities = new HospitalSystemEntities1();

            Message msg = new Message();

            msg.MessageFROM = doctor.FirstName + " " + doctor.LastName;
            msg.MessageTO   = patient.FirstName + " " + patient.LastName;
            msg.Message1    = content;
            msg.Date        = new DateTime();

            entities.Messages.Add(msg);
            entities.SaveChanges();

            return(true);
        }
Esempio n. 13
0
        /**
         * Deletes the appointment corresponding with the given Appointment
         * object, if one exists
         *
         * @param appointment Appointment object representing the information
         *  of the appointment that is desired to be deleted
         * @returns true on success, false on failure
         */
        public static bool DeleteAppointment(int appointmentID)
        {
            HospitalSystemEntities1 entities = new HospitalSystemEntities1();

            List <Appointment> matched = (from appt in entities.Appointments where appt.AppointmentID == appointmentID select appt).ToList();

            if (matched.Count < 1)
            {
                return(false);
            }

            entities.Appointments.Remove(matched.First());
            entities.SaveChanges();

            return(true);
        }
Esempio n. 14
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);
        }
Esempio n. 15
0
        public static int GetDoctorID(string firstName, string lastName)
        {
            HospitalSystemEntities1 entities = new HospitalSystemEntities1();

            List <Doctor> doctors = (
                from doctor in entities.Doctors
                where
                doctor.FirstName == firstName &&
                doctor.LastName == lastName
                select doctor
                ).ToList();

            if (doctors.Count < 1)
            {
                return(0);
            }

            return(doctors.First().DoctorID);
        }
Esempio n. 16
0
        public static int GetPatientID(string firstName, string lastName)
        {
            HospitalSystemEntities1 entities = new HospitalSystemEntities1();

            List <Patient> patients = (
                from patient in entities.Patients
                where
                patient.FirstName == firstName &&
                patient.LastName == lastName
                select patient
                ).ToList();

            if (patients.Count < 1)
            {
                return(0);
            }

            return(patients.First().PatientID);
        }
Esempio n. 17
0
        public static List <Doctor> GetDoctors()
        {
            HospitalSystemEntities1 entities = new HospitalSystemEntities1();

            return(entities.Doctors.ToList());
        }
Esempio n. 18
0
        public static List <Patient> GetPatients()
        {
            HospitalSystemEntities1 entities = new HospitalSystemEntities1();

            return(entities.Patients.ToList());
        }