示例#1
0
        /**
         * \brief <b>Brief Description</b> - Menu - Constructor <b><i>class method</i></b> - This method is used when only the selected menu, title and index of selected item are known
         * \details <b>Details</b>
         *
         * This takes in the currently selected menu, its title and what the index of the currently selected item is
         *
         * \return <b>void</b>
         */
        public Menu(MenuCodes menu, string title, int selectedItem)
        {
            _selectedItem = selectedItem;
            _selectedMenu = menu;
            _menuTitle    = title;

            CreateMenuOptionList();
        }
示例#2
0
        /**
         * \brief <b>Brief Description</b> - MainLoop <b><i>class method</i></b> - main logic behind the patient search
         * \details <b>Details</b>
         *
         * This takes in the menu that is currently selected, the title of the menu, the index of the selected menu option
         *
         * \return <b>Patient</b> - selected patient by the user
         */
        static Patient MainLoop(MenuCodes menu, string title, int selectedIndex, int blockID)
        {
            Console.CursorVisible = false;
            ConsoleKey userInput;
            Patient    patient = null;

            while (!_return)
            {
                _return   = false;
                userInput = Console.ReadKey(true).Key;
                Thread.Sleep(1);    // sleep for just a tiny bit so the menu has time to reprint. avoids visual glitches

                // check and change based on what button the user pressed
                if (ChangeInputField(userInput))
                {
                    // check if the user requested to return
                    if (_return)
                    {
                        break;
                    }

                    // check if the user requested to search
                    if (_selectedSearch != SearchOption.NOSEARCH)
                    {
                        switch (_selectedSearch)
                        {
                        // user chose to search by name
                        case SearchOption.NAMESEARCH:
                            patient = SearchNames(menu, title, selectedIndex, blockID);
                            break;

                        // user chose to search by health card number
                        case SearchOption.HCNSEARCH:
                            patient = SearchHCN(menu, title, selectedIndex, blockID);
                            break;
                        }
                        if (patient != null)
                        {
                            break;
                        }

                        // set it back to not searching
                        _selectedSearch = SearchOption.NOSEARCH;
                    }

                    // display the now changed menu
                    Container.DisplayContent(_searchMenu, selectedIndex, _selectedInputField, menu, title, Description);
                }
            }

            // clear the console and return the patient
            Console.Clear();
            return(patient);
        }
示例#3
0
        /**
         * \brief <b>Brief Description</b> - DisplayContent <b><i>class method</i></b> - Display the right menu box together with the content box and its contents
         * \details <b>Details</b>
         *
         * This takes in the content that needs to be displayed, the index of the item that is selected in the menu, the line that should be highlighted inside of the
         * container, the menu that should be displayed, the title of the menu and the title of the middle container
         *
         * \return <b>void</b>
         */
        public static void DisplayContent(List <KeyValuePair <string, string> > content, int selectedMenuItem, int selectedInput,
                                          MenuCodes menuToDisplay, string menuTitle, string actionTitle)
        {
            List <Pair <string, string> > convertedList = new List <Pair <string, string> >();

            // converts the KeyValuePair to a Pair
            foreach (KeyValuePair <string, string> line in content)
            {
                convertedList.Add(new Pair <string, string>(line.Key, line.Value));
            }

            // call the overloaded DisplayContent with the Pair instead of the KeyValuePair
            DisplayContent(convertedList, selectedMenuItem, selectedInput, menuToDisplay, menuTitle, actionTitle);
        }
示例#4
0
        /**
         * \brief <b>Brief Description</b> - BrowseRecords <b><i>class method</i></b> - the functionality to browse through the records
         * \details <b>Details</b>
         *
         * This takes in a list of patients the menu that is currently selected, the title of the menu, the index of the selected menu option
         *
         * \return <b>Patient</b> - selected patient record
         */
        static public Patient BrowseRecords(List <Patient> patients, MenuCodes menu, string title, int selectedIndex, int blockID = -1)
        {
            int        patientIndex = 1;
            ConsoleKey keyPressed   = new ConsoleKey();
            List <Pair <string, string> > patientDisplayList = new List <Pair <string, string> >();

            // insert all found patients into a list which is used to display the patients
            foreach (Patient patient in patients)
            {
                patientDisplayList.Add(new Pair <string, string>(patient.ToString(), ""));
            }

            do
            {
                // display the patient list
                Container.DisplayContent(patientDisplayList, selectedIndex, patientIndex, menu, title, Description);

                keyPressed = Console.ReadKey(true).Key;

                switch (keyPressed)
                {
                // user pressed down key therefore change index
                case ConsoleKey.DownArrow:
                    if (patientIndex < patients.Count)
                    {
                        patientIndex++;
                    }
                    break;

                // user pressed up key therefore change index
                case ConsoleKey.UpArrow:
                    if (patientIndex > 1)
                    {
                        patientIndex--;
                    }
                    break;

                // user chose a patient record
                case ConsoleKey.Enter:
                    // return the selected patient recordd
                    return(patients[patientIndex - 1]);
                }
            } while (keyPressed != ConsoleKey.Escape);

            // user canceled therefore no patient was selected
            return(null);
        }
示例#5
0
        /**
         * \brief <b>Brief Description</b> - DisplayContent <b><i>class method</i></b> - Display the right menu box together with the content box and its contents
         * \details <b>Details</b>
         *
         * This takes in the content that needs to be displayed, the index of the item that is selected in the menu, the line that should be highlighted inside of the
         * container, the menu that should be displayed, the title of the menu and the title of the middle container
         *
         * \return <b>void</b>
         */
        public static void DisplayContent(List <Pair <string, string> > content, int selectedMenuItem, int selectedInput,
                                          MenuCodes menuToDisplay, string menuTitle, string actionTitle)
        {
            // set the menu that needs to be displayed
            Menu menu = new Menu(menuToDisplay, menuTitle, selectedMenuItem);

            // generate the contents of the menu
            List <string> menuList    = menu.CreateMenuContentList();
            List <string> fullContent = new List <string>();

            // set the cursor at the top of the window
            Console.CursorTop  = 0;
            Console.CursorLeft = 0;

            // display the header with the default title
            Container.DisplayHeader("EMS System 2.0 - A system by Attila, Alex, Divyang and Tudor");

            // add the content box to the menu
            fullContent = Container.AddContentBox(actionTitle, selectedMenuItem, menuList, content);

            for (int count = 0; count < fullContent.Count; count++)
            {
                // display the menu part as grayed out
                Console.ForegroundColor = ConsoleColor.DarkGray;
                Console.Write(fullContent[count].Substring(0, 26));
                Console.ForegroundColor = ConsoleColor.White;

                // make the border of the middle container white
                if (fullContent[count].Substring(26).Contains(Container.HORIZONTAL) &&
                    !fullContent[count].Substring(26).Contains("" + Container.HORIZONTAL + Container.BRCORNER))
                {
                    Console.WriteLine(fullContent[count].Substring(26));
                }
                else
                {
                    Console.Write(fullContent[count].Substring(26, 2));
                    Console.ForegroundColor = (count == selectedInput) ? ConsoleColor.White : ConsoleColor.DarkGray;
                    Console.WriteLine(fullContent[count].Substring(28));
                }
            }

            // display the footer
            Container.DisplayFooterContent(FooterFlags.Back | FooterFlags.Quit, true);
        }
示例#6
0
        /**
         * \brief <b>Brief Description</b> - Get <b><i>class method</i></b> - the main method used to get the patient.
         * \details <b>Details</b>
         *
         * This gets the current selected menu, the title of the menu, the selected option in that menu and the block
         * selected
         *
         * \return <b>Patient</b> - the patient that was selected by the user search
         */
        public static Patient Get(MenuCodes menu, string title, int selectedIndex, int blockID = -1)
        {
            _return             = false;
            _selectedInputField = 1;
            _inputPosition      = new Pair <int, int>(6, 50);
            _selectedSearch     = SearchOption.NOSEARCH;

            // the menu that allows the user to select between searching by first and last names or HCN
            _searchMenu = new List <Pair <string, string> >()
            {
                { new Pair <string, string>(" > First & Last name", "") },
                { new Pair <string, string>(" > Health Card Number", "") }
            };

            // the menu for the searching by first and last names
            _namesSearchContent = new List <Pair <string, string> >()
            {
                { new Pair <string, string>("First Name", "") },
                { new Pair <string, string>("Last Name", "") },
                { new Pair <string, string>(" >> SEARCH PATIENT <<", "") }
            };

            // the menu for the searching by health card number
            _hcnSearchContent = new List <Pair <string, string> >()
            {
                { new Pair <string, string>("Health Card Number", "") },
                { new Pair <string, string>(" >> SEARCH PATIENT <<", "") }
            };

            //  format the input lines so they look like input lines
            FormatInputLines(_namesSearchContent);
            FormatInputLines(_hcnSearchContent);

            // display the search menu
            Container.DisplayContent(_searchMenu, selectedIndex, _selectedInputField, menu, title, Description);

            // run the main loop and return its return
            return(MainLoop(menu, title, selectedIndex, blockID));
        }
        /**
         * \brief <b>Brief Description</b> - BrowseRecords <b><i>class method</i></b> - This method allows the browsing thorugh the found appointments
         * \details <b>Details</b>
         *
         * This takes in a list of the found appointments, the menu that should be displayed, the title of the menu and the index of the selected item in the menu
         *
         * \return <b>void</b>
         */
        public Appointment BrowseRecords(List <Appointment> appointments, MenuCodes menu, string title, int selectedIndex)
        {
            int        apptIndex  = 1;
            ConsoleKey keyPressed = new ConsoleKey();
            List <Pair <string, string> > content = new List <Pair <string, string> >();

            // information to be displayed about the appointment
            string[] apptInfo = new string[4]
            {
                "Appointment ID: ",
                "Patient ID: ",
                "Dependant ID: ",
                "Recall: "
            };

            // loop through all appointments
            foreach (Appointment appt in appointments)
            {
                string line = "";

                // set appointment to empty if not set
                if (appt.AppointmentID == -1 && appt.PatientID == -1)
                {
                    line = "(EMPTY)";
                }
                else
                {   // display information of appointments that are not taken
                    for (int index = 0; index < 4; index++)
                    {
                        line += apptInfo[index] + appt.ToStringArray()[index].PadRight(5, ' ');
                    }
                }

                // add appointment information tho the content list
                content.Add(new Pair <string, string>(line, ""));
            }

            do
            {
                // display the content
                Container.DisplayContent(content, selectedIndex, apptIndex, menu, title, Description);

                keyPressed = Console.ReadKey(true).Key;

                switch (keyPressed)
                {
                // increment index if arrow up pressed
                case ConsoleKey.DownArrow:
                    if (apptIndex < appointments.Count)
                    {
                        apptIndex++;
                    }
                    break;

                // decrement index if arrow down pressed
                case ConsoleKey.UpArrow:
                    if (apptIndex > 1)
                    {
                        apptIndex--;
                    }
                    break;

                // return selected appointment if enter pressed
                case ConsoleKey.Enter:
                    return(appointments[apptIndex - 1]);
                }
            } while (keyPressed != ConsoleKey.Escape);

            return(null);
        }
示例#8
0
        /**
         * \brief <b>Brief Description</b> - SearchHCN <b><i>class method</i></b> - the functionality to search by hcn
         * \details <b>Details</b>
         *
         * This takes in the menu that is currently selected, the title of the menu, the index of the selected menu option
         *
         * \return <b>Patient</b> - selected patient by the user
         */
        static Patient SearchHCN(MenuCodes menu, string title, int selectedIndex, int blockID)
        {
            _selectedInputField   = 1;
            _inputPosition.First  = 7;
            _inputPosition.Second = 50;

            // make sure the input fields are clear
            Input.ClearInputFields(_hcnSearchContent);

            // display the contents of the menu
            Container.DisplayContent(_hcnSearchContent, selectedIndex, _selectedInputField, menu, title, Description);

            ConsoleKey keyPressed;

            do
            {
                keyPressed = Console.ReadKey(true).Key;

                // act according to the key pressed by the user
                switch (keyPressed)
                {
                // up arrow pressed therefore change index
                case ConsoleKey.UpArrow:
                    if (_selectedInputField > 1)
                    {
                        _selectedInputField--;
                    }
                    break;

                // down arrow pressed therefore change index
                case ConsoleKey.DownArrow:
                    if (_selectedInputField < _hcnSearchContent.Count)
                    {
                        _selectedInputField++;
                    }
                    break;

                // user decided to select a button
                case ConsoleKey.Enter:
                    switch (_selectedInputField)
                    {
                    // user selected to enter a health card number
                    case (int)HCNSearchFields.HCN:
                        // set the cursor to the right spot
                        Console.CursorTop  = _inputPosition.First - 1;
                        Console.CursorLeft = _inputPosition.Second;

                        // get the health card number
                        Pair <InputRetCode, string> temp = Input.GetInput(_hcnSearchContent[_selectedInputField - 1].Second, 12, InputType.Strings | InputType.Ints);

                        // check if the user saved or canceled their input
                        if ((temp.First & InputRetCode.SAVE) != 0)
                        {
                            _hcnSearchContent[_selectedInputField - 1].Second = temp.Second;
                        }
                        break;

                    // user selected to search for the health card number above
                    case (int)HCNSearchFields.SEARCH:
                        Demographics demographics = new Demographics();

                        // find a patient with a matching health card number
                        Patient        returnedPatient = demographics.GetPatientByHCN(_hcnSearchContent[0].Second);
                        List <Patient> patients        = new List <Patient>();

                        // check if there was a patient with that HCN
                        if (returnedPatient != null)
                        {
                            patients.Add(returnedPatient);
                            return(BrowseRecords(patients, menu, title, selectedIndex, blockID));
                        }
                        else
                        {
                            PrintErrorOnLine(_inputPosition, "No record found with that number.", 0, 41);
                            Console.ReadKey();
                        }

                        break;
                    }
                    break;
                }

                // re-display the menu
                Container.DisplayContent(_hcnSearchContent, selectedIndex, _selectedInputField, menu, title, Description);
            } while (keyPressed != ConsoleKey.Escape);

            // reset the selected index
            _selectedInputField = 1;

            return(null);
        }
示例#9
0
        /**
         * \brief <b>Brief Description</b> - SearchNames <b><i>class method</i></b> - the functionality to search by names
         * \details <b>Details</b>
         *
         * This takes in the menu that is currently selected, the title of the menu, the index of the selected menu option
         *
         * \return <b>Patient</b> - selected patient by the user
         */
        static Patient SearchNames(MenuCodes menu, string title, int selectedIndex, int blockID)
        {
            _selectedInputField   = 1;
            _inputPosition.First  = 6;
            _inputPosition.Second = 50;

            // make sure the input fields are clear
            Input.ClearInputFields(_namesSearchContent);

            // display the menu
            Container.DisplayContent(_namesSearchContent, selectedIndex, _selectedInputField, menu, title, Description);

            ConsoleKey keyPressed;

            do
            {
                keyPressed = Console.ReadKey(true).Key;

                // act according to what key the user pressed
                switch (keyPressed)
                {
                // up arrow was pressed therefore change indexes
                case ConsoleKey.UpArrow:
                    if (_selectedInputField > 1)
                    {
                        _selectedInputField--;
                        _inputPosition.First--;
                    }
                    break;

                // down arrow was pressed therefore change indexes
                case ConsoleKey.DownArrow:
                    if (_selectedInputField < _namesSearchContent.Count)
                    {
                        _selectedInputField++;
                        _inputPosition.First++;
                    }
                    break;

                // user decided to select one of the menu options
                case ConsoleKey.Enter:
                    switch (_selectedInputField)
                    {
                    // user picked to enter a first or last name
                    case (int)NameSearchFields.FNAME:
                    case (int)NameSearchFields.LNAME:
                        Console.CursorTop  = _inputPosition.First;
                        Console.CursorLeft = _inputPosition.Second;
                        Pair <InputRetCode, string> temp = Input.GetInput(_namesSearchContent[_selectedInputField - 1].Second, 40, MenuOptions.InputType.Strings);
                        if ((temp.First & InputRetCode.SAVE) != 0)
                        {
                            _namesSearchContent[_selectedInputField - 1].Second = temp.Second;
                        }
                        break;

                    // user decided to do a search based on the fields above
                    case (int)NameSearchFields.SEARCH:
                        Demographics demographics = new Demographics();

                        // get a list of patients that match the criteria
                        List <Patient> returnedPatients = demographics.GetPatientByName(_namesSearchContent[0].Second, _namesSearchContent[1].Second);

                        // loop through all found records if there are any
                        for (int i = 0; i < returnedPatients.Count; i++)
                        {
                            if (returnedPatients[i].PatientID == blockID)
                            {
                                returnedPatients.RemoveAt(i);
                            }
                        }

                        // some records were found
                        if (returnedPatients.Count > 0)
                        {
                            return(BrowseRecords(returnedPatients, menu, title, selectedIndex, blockID));
                        }
                        // no records were found
                        else
                        {
                            PrintErrorOnLine(_inputPosition, "No record found with those names.", 0, 41);
                            Console.ReadKey();
                        }
                        break;
                    }
                    break;
                }

                //  redisplay the menu
                Container.DisplayContent(_namesSearchContent, selectedIndex, _selectedInputField, menu, title, Description);
            } while (keyPressed != ConsoleKey.Escape);

            // reset the selected field
            _selectedInputField = 1;

            return(null);
        }
示例#10
0
        /**
         * \brief <b>Brief Description</b> - ChangeMenu <b><i>class method</i></b> - This method changes the menu based on the key pressed
         * \details <b>Details</b>
         *
         * This takes in the key the user pressed, scheduling library, demographics library, billing library
         *
         * \return <b>bool</b> - true if menu properties were changed
         */
        public bool ChangeMenu(ConsoleKey key, Scheduling scheduling, Demographics demographics, Billing billing)
        {
            // switch index to number key pressed
            if (Input.IsValidChoice(key, _listOfMenus[(int)_selectedMenu].Length) &&
                Input.KeyToNumber(key) - 1 != _selectedItem)
            {
                _selectedItem = Input.KeyToNumber(key) - 1;
                return(true);
            }

            switch (key)
            {
            // if up arrow decrement index
            case (ConsoleKey.UpArrow):
                if (_selectedItem >= 1)
                {
                    _selectedItem--;
                    return(true);
                }
                break;

            // if down arrow increment index
            case (ConsoleKey.DownArrow):
                if (_selectedItem <= (_listOfMenus[(int)_selectedMenu].Length - 2))
                {
                    _selectedItem++;
                    return(true);
                }
                break;

            // if F9 attempt to exit
            case (ConsoleKey.F9):
                ExitCommand exit = new ExitCommand();
                exit.Execute(scheduling, demographics, billing);
                return(true);

            // if escape go back to previous menu
            case (ConsoleKey.Escape):
                if ((int)_selectedMenu > 0)
                {
                    _selectedMenu = MenuCodes.MAINMENU;
                    _selectedItem = 0;
                    _menuTitle    = "main menu";
                    return(true);
                }
                break;

            // if enter select the current menu option
            case (ConsoleKey.Enter):
                _listOfMenus[(int)_selectedMenu][(int)_selectedItem].Execute(scheduling, demographics, billing);
                Console.Clear();

                // set the new menu properties
                if (_listOfMenus[(int)MenuCodes.MAINMENU].Contains(_listOfMenus[(int)_selectedMenu][(int)_selectedItem]))
                {
                    _menuTitle    = _listOfMenus[(int)_selectedMenu][(int)_selectedItem].Description;
                    _selectedMenu = (MenuCodes)_selectedItem + 1;
                    _selectedItem = 0;
                }

                return(true);
            }

            return(false);
        }
        /**
         * \brief <b>Brief Description</b> - Get <b><i>class method</i></b> - overload main method used by outside methods to get the appointment
         * \details <b>Details</b>
         *
         * This take sin the scheduling library, the demographics library, the date when an appointment should start, the selected menu, the selected option
         * in that menu and the title of the menu
         *
         * \return <b>Pair<Day, int></b> - the appointment slot
         */
        public static Pair <Day, int> Get(Scheduling scheduling, Demographics demographics, DateTime startDate, int selectedMenu, MenuCodes menu, string title)
        {
            Console.CursorVisible = true;
            Container.DisplayContent(new List <KeyValuePair <string, string> >(), selectedMenu, -1, menu, title, Description);
            DateTime date = startDate;

            // check to make sure the date passed in is a valid one
            if (date != new DateTime(0))
            {
                do
                {
                    // get a date starting at the date passed in as a parameter
                    date = DatePicker.GetDate(scheduling, date, true);

                    // check if the user canceled the date selection process
                    if (date == new DateTime(0))
                    {
                        break;
                    }

                    // get the schedule for that day
                    Day selectedDay = scheduling.GetScheduleByDay(date);

                    // get a list of appointments for that day
                    List <Appointment>            apptList    = selectedDay.GetAppointments();
                    List <Pair <string, string> > apptContent = new List <Pair <string, string> >();

                    // loop through all appointments on that day
                    foreach (Appointment appointment in apptList)
                    {
                        string line = "";

                        // if the appointment slot is not taken, sets it to be displayed as (EMPTY)
                        if (appointment.AppointmentID == -1 && appointment.PatientID == -1)
                        {
                            line = "(EMPTY)";
                        }
                        else
                        {
                            // get information about the main patient
                            Patient mainPatient = demographics.GetPatientByID(appointment.PatientID);

                            // get information about the dependant of the main patient
                            Patient dependantPatient = demographics.GetPatientByID(appointment.DependantID);

                            // format the main patient information
                            line = string.Format("{0}, {1} - {2}", mainPatient.LastName, mainPatient.FirstName, mainPatient.HCN);


                            // if the patient has a dependant, adds it to the patient information line
                            if (dependantPatient != null)
                            {
                                line += string.Format(" > {0}, {1} - {2}", dependantPatient.LastName, dependantPatient.FirstName, dependantPatient.HCN);
                            }
                        }

                        // adds the patient line to the appointment content that will be displayed
                        apptContent.Add(new Pair <string, string>(line, ""));
                    }

                    int selectedIndex = 1;

                    // display all appointments
                    Container.DisplayContent(apptContent, selectedMenu, selectedIndex, menu, title, Description);
                    ConsoleKey keyPressed = new ConsoleKey();
                    Console.CursorVisible = false;

                    // loop until user cancels
                    do
                    {
                        keyPressed = Console.ReadKey(true).Key;
                        switch (keyPressed)
                        {
                        // down arrow pressed therefore go to appt below
                        case ConsoleKey.DownArrow:
                            if (selectedIndex < apptContent.Count)
                            {
                                selectedIndex++;
                            }
                            break;

                        // up arrow pressed therefore go to appt above
                        case ConsoleKey.UpArrow:
                            if (selectedIndex > 1)
                            {
                                selectedIndex--;
                            }
                            break;

                        // enter pressed therefore return the selected appointment
                        case ConsoleKey.Enter:
                            return(new Pair <Day, int>(selectedDay, selectedIndex - 1));
                        }

                        // re-display the appointment selection
                        Container.DisplayContent(apptContent, selectedMenu, selectedIndex, menu, title, Description);
                    } while (keyPressed != ConsoleKey.Escape);
                } while (true);
            }

            // user canceled therefore return a blank selection
            return(new Pair <Day, int>(null, -1));
        }