Example #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 updates staff members drop down list */
        private void updateStaffMembersList()
        {
            staffMemberList.Clear();
            staffMemberList.Add(new ListItem {
                text = "Select a doctor", id = 0
            });
            if (!doctorCheck.Checked)
            {
                return;
            }

            int           found        = -1;
            List <IModel> staffMembers = getStaffMembers();

            for (int i = 0; i < staffMembers.Count; i++)
            {
                StaffModel doctor = (StaffModel)staffMembers[i];
                staffMemberList.Add(new ListItem {
                    text = doctor.getFullStaffName(), id = doctor.getStaffId()
                });
                if (selectedDoctor == doctor.getStaffId())
                {
                    found = i + 1;
                }
            }
            staffMemberDropDown.SelectedIndex = found == -1 ? 0 : found;
        }