Пример #1
0
        /**
         * Method returns full name of the most attended staff member (doctor)
         *
         * @return full name of the most often attended doctor
         */
        public string getFullNameOfTheMostOftenAttendedDoctor()
        {
            string        query    = "SELECT * from " + view + " WHERE patientId= " + ApplicationState.userId + " AND staffType = " + "\"doctor\"";
            List <IModel> bookings = this.db.Query(query, new BookingMapper());

            StaffModel            theMostAttendedDoctor = new StaffModel();
            Dictionary <int, int> statistics            = new Dictionary <int, int>();
            int theMostOftenAttended = 0;

            foreach (BookingModel booking in bookings)
            {
                if (statistics.ContainsKey(booking.getStaffModel().getStaffId()))
                {
                    statistics[booking.getStaffModel().getStaffId()]++;
                    if (statistics[booking.getStaffModel().getStaffId()] >= theMostOftenAttended)
                    {
                        theMostAttendedDoctor.setFirstName(booking.getStaffModel().getFirstName());
                        theMostAttendedDoctor.setLastName(booking.getStaffModel().getLastName());
                    }
                }
                else
                {
                    statistics.Add(booking.getStaffModel().getStaffId(), 0);
                }
            }
            return(theMostAttendedDoctor.getFullStaffName());
        }
        /**
         * Method returns a mapped (database to model) staffSchedule model
         *
         * @param reader MySqlDataReader
         * @return Model implementing IModel interface - staffschedule
         */
        public IModel map(MySqlDataReader reader)
        {
            StaffModel         staff         = new StaffModel();
            ScheduleModel      schedule      = new ScheduleModel();
            StaffScheduleModel staffSchedule = new StaffScheduleModel();

            staff.setStaffId(reader.GetInt32("staffId"));
            staff.setFirstName(reader.GetString("firstName"));
            staff.setLastName(reader.GetString("lastName"));
            if (!reader.IsDBNull(6))
            {
                staff.setPhoneNumber(reader.GetString("phoneNumber"));
            }
            staff.setStaffType(reader.GetString("staffType"));

            schedule.setScheduleId(reader.GetInt32("scheduleId"));
            schedule.setDate(Helpers.DateHelper.getDateTimeStringFromReader(reader, "date"));
            schedule.setStartTime(reader.GetString("startTime"));
            schedule.setEndTime(reader.GetString("endTime"));

            staffSchedule.setStaffScheduleId(reader.GetInt32("staffScheduleId"));
            staffSchedule.setStaffMember(staff);
            staffSchedule.setSchedule(schedule);
            return(staffSchedule);
        }
Пример #3
0
        public void validateStaffMemberTestIncorrectStaffMemberNoStaffType2()
        {
            StaffModel staffMember = new StaffModel();

            staffMember.setFirstName("");
            staffMember.setLastName("Smith");
            int expected = 1;
            int result   = Validator.validateStaffMember(staffMember).Count;

            Assert.AreEqual(expected, result);
        }
Пример #4
0
        public void validateStaffMemberTest()
        {
            StaffModel staffMember = new StaffModel();

            staffMember.setFirstName("John");
            staffMember.setLastName("Smith");
            int expected = 0;
            int result   = Validator.validateStaffMember(staffMember).Count;

            Assert.AreEqual(expected, result);
        }
Пример #5
0
        /**
         * Method returns a mapped (database to model) StaffModel
         * @param reader MySqlDataReader
         * @return Model implementing IModel interface - staff
         */
        public IModel map(MySqlDataReader reader)
        {
            StaffModel staffMember = new StaffModel();

            staffMember.setStaffId(reader.GetInt16("staffId"));
            staffMember.setFirstName(reader.GetString("firstName"));
            staffMember.setLastName(reader.GetString("lastName"));
            if (!reader.IsDBNull(3))
            {
                staffMember.setPhoneNumber(reader.GetString("phoneNumber"));
            }
            staffMember.setStaffType(reader.GetString("staffType"));
            return(staffMember);
        }
Пример #6
0
        /**
         * Method prepares staff model from data get from form
         *
         * @return staff model
         */
        private StaffModel getStaffModelFromForm()
        {
            StaffModel staffMember = new StaffModel();

            staffMember.setFirstName(doctorsFirstName.Text);
            staffMember.setLastName(doctorsLastName.Text);
            staffMember.setPhoneNumber(doctorsPhoneNumber.Text);
            if (String.IsNullOrEmpty(doctorsPhoneNumber.Text))
            {
                staffMember.setPhoneNumber("NULL");
            }
            ListItem staffType = (ListItem)staffTypes.SelectedItem;

            staffMember.setStaffType(staffType.text);
            return(staffMember);
        }
Пример #7
0
        /**
         * Method returns a mapped (database to model) BookingModel
         * @param reader MySqlDataReader
         * @return Model implementing IModel interface - booking
         */
        public IModel map(MySqlDataReader reader)
        {
            BookingModel  booking  = new BookingModel();
            UserModel     user     = new UserModel();
            StaffModel    staff    = new StaffModel();
            ScheduleModel schedule = new ScheduleModel();

            booking.setBookingId(reader.GetInt16("bookingId"));
            booking.setConfirmation(reader.GetInt16("confirmation"));
            booking.setAttendance(reader.GetInt16("attendance"));
            booking.setLackOfCancellation(reader.GetInt16("lackOfCancellation"));

            if (!reader.IsDBNull(14))
            {
                booking.setComment(reader.GetString("comment"));
            }
            else
            {
                booking.setComment("");
            }

            booking.setStartTime(reader.GetString("startTime"));
            booking.setEndTime(reader.GetString("endTime"));

            if (reader.GetSchemaTable().Columns.Contains("patientId"))
            {
                booking.setUserId(reader.GetInt16("patientId"));
            }
            if (reader.GetSchemaTable().Columns.Contains("patientFirstName"))
            {
                user.setFirstName(reader.GetString("patientFirstName"));
            }

            user.setFirstName(reader.GetString("patientFirstName"));
            user.setLastName(reader.GetString("patientLastName"));
            booking.setUserModel(user);
            staff.setStaffId(reader.GetInt16("staffId"));
            staff.setFirstName(reader.GetString("staffFirstName"));
            staff.setLastName(reader.GetString("staffLastName"));
            staff.setStaffType(reader.GetString("staffType"));
            booking.setStaffMember(staff);
            schedule.setDate(Helpers.DateHelper.getDateTimeStringFromReader(reader, "date"));
            booking.setScheduleModel(schedule);
            return(booking);
        }