示例#1
0
        public void Functional_GetPatientbyHCN()
        {
            try
            {
                Demographics d = new Demographics();
                Patient      p = new Patient(d);
                p.FirstName   = "Divyangbhai";
                p.LastName    = "Dankhara";
                p.HCN         = "0987654321AB";
                p.MInitial    = "A";
                p.DateOfBirth = "12111997";
                p.Sex         = "M";
                p.HeadOfHouse = "1234567890AB";

                d.AddNewPatient(p);
                Patient dp = d.GetPatientByHCN(p.HCN);


                if (!(dp.HCN == p.HCN))
                {
                    Assert.Fail();
                }
            }
            catch (Exception)
            {
                Assert.Fail();
            }
        }
示例#2
0
        public void Functional_GetDependants()
        {
            try
            {
                Demographics d = new Demographics();

                Patient p = new Patient(d);
                p.FirstName   = "Divyangbhai";
                p.LastName    = "Dankhara";
                p.HCN         = "1234567890AB";
                p.MInitial    = "A";
                p.DateOfBirth = "12111997";
                p.Sex         = "M";

                d.AddNewPatient(p);

                List <Patient> dp = d.GetDependants(p);

                if (!(dp == null))
                {
                    foreach (Patient a in dp)
                    {
                        if (!(a.HeadOfHouse == p.HCN))
                        {
                            Assert.Fail();
                        }
                    }
                }
            }
            catch (Exception)
            {
                Assert.Fail();
            }
        }
示例#3
0
        public void Functional_GetPatientList()
        {
            try
            {
                Demographics d = new Demographics();

                Patient p = new Patient(d);
                p.FirstName   = "Divyangbhai";
                p.LastName    = "Dankhara";
                p.HCN         = "0987654321AB";
                p.MInitial    = "A";
                p.DateOfBirth = "12111997";
                p.Sex         = "M";
                p.HeadOfHouse = "1234567890AB";

                d.AddNewPatient(p);
                int count = d.dPatientRoster.Count;

                if (count == 0)
                {
                    Assert.Fail();
                }
            }
            catch (Exception)
            {
                Assert.Fail();
            }
        }
示例#4
0
        public void Functional_UpdatePatient()
        {
            // in this test we test that demographics class actually add the patient to database
            try
            {
                Demographics d = new Demographics();

                Patient p = new Patient(d);
                p.FirstName   = "Divyangbhai";
                p.LastName    = "Dankhara";
                p.HCN         = "0987654321AB";
                p.MInitial    = "A";
                p.DateOfBirth = "12111997";
                p.Sex         = "M";
                p.HeadOfHouse = "1234567890AB";

                d.AddNewPatient(p);
                p.LastName = "dankhara1";

                // here we are updating the patient that we have just added with new last name.
                d.UpdatePatient(p);

                Patient Dp = d.GetPatientByHCN(p.HCN);
                if (!(Dp.LastName == p.LastName))
                {
                    Assert.Fail();
                }
            }
            catch (Exception)
            {
                Assert.Fail();
            }
        }
示例#5
0
        public void Functional_GetPatientbyID()
        {
            try
            {
                Demographics d = new Demographics();

                Patient p = new Patient(d);
                p.FirstName   = "alex";
                p.LastName    = "koxak";
                p.HCN         = "0987654321GF";
                p.MInitial    = "A";
                p.DateOfBirth = "12111997";
                p.Sex         = "M";
                p.HeadOfHouse = "1234567890AB";

                d.AddNewPatient(p);
                int     count = d.GetPatientIDByHCN(p.HCN);
                Patient dp    = d.GetPatientByID(count);

                if (dp != null)
                {
                    if (!(dp.HCN == p.HCN))
                    {
                        Assert.Fail();
                    }
                }
            }
            catch (Exception)
            {
                Assert.Fail();
            }
        }
示例#6
0
        public void Null_AddNewPatient()
        {
            try
            {
                Demographics d = new Demographics();

                d.AddNewPatient(null);
            }
            catch (Exception)
            {
                Assert.Fail();
            }
        }
示例#7
0
        public void Functional_GetPatientbyName()
        {
            try
            {
                Demographics d = new Demographics();
                Patient      p = new Patient(d);
                p.FirstName   = "Divyangbhai";
                p.LastName    = "Dankhara";
                p.HCN         = "0987654321AB";
                p.MInitial    = "A";
                p.DateOfBirth = "12111997";
                p.Sex         = "M";
                p.HeadOfHouse = "1234567890AB";

                d.AddNewPatient(p);
                List <Patient> lP = d.GetPatientByName(p.FirstName, p.LastName);

                bool contains = false;
                if ((lP != null))
                {
                    foreach (Patient tp in lP)
                    {
                        if ((tp.FirstName == p.FirstName) && (tp.LastName == p.LastName))
                        {
                            contains = true;
                        }
                    }

                    if (contains == false)
                    {
                        Assert.Fail();
                    }
                }
                else
                {
                    Assert.Fail();
                }
            }
            catch (Exception)
            {
                Assert.Fail();
            }
        }
示例#8
0
 private void BtnAddNewPatient_Click(object sender, RoutedEventArgs e)
 {
     Logging.Log("Add Patient button is pressed");
     if (addingPatient.IsReadyToSave())
     {
         demographics.AddNewPatient(addingPatient);
         Logging.Log("Patient is added to database");
         refreshScreen();
         DialogHost.CloseDialogCommand.Execute(null, null);
     }
     else
     {
         Logging.Log("Could not add Patient from AddPatient pop up page");
         tbFirstName.Text      = tbFirstName.Text;
         tbLastName.Text       = tbLastName.Text;
         tbHealthCard.Text     = tbHealthCard.Text;
         tbPostalCode.Text     = tbPostalCode.Text;
         cbGender.SelectedItem = cbGender.SelectedItem;
     }
 }
示例#9
0
        /**
         * \brief <b>Brief Description</b> - MainLoop <b><i>class method</i></b> - The main logic behind the getting a patient added to the database menu
         * \details <b>Details</b>
         *
         * This takes in the demographics library and whether it needs to return the added patient
         *
         * \return <b>Patient</b> - the patient added if it was requested
         */
        private Patient MainLoop(Demographics demographics, bool returnPatient = false)
        {
            Patient newPatient = new Patient(demographics);

            const int ADDBUTTON = 13; // index of the button

            //  format the first value to look nice
            ConsoleKey                  userInput;
            Pair <int, int>             pInitialPosition = new Pair <int, int>(6, 50);
            Pair <InputRetCode, string> temp             = new Pair <InputRetCode, string>(0, "");

            do
            {
                _return = false;

                // if the user presses tab then treat it as enter
                if (temp.First == InputRetCode.TAB && _selectedInputField != ADDBUTTON)
                {
                    userInput = ConsoleKey.Enter;
                }
                else
                {
                    userInput = Console.ReadKey(true).Key;
                }

                // delay changing so content has enough time to redisplay avoiding any visual glitches
                Thread.Sleep(1);

                // get the input for the selected field if the user pressed enter and it is not the button
                if (userInput == ConsoleKey.Enter &&
                    _selectedInputField != ADDBUTTON)
                {
                    // position the cursor
                    Console.CursorTop  = _inputPosition.First;
                    Console.CursorLeft = _inputPosition.Second;

                    // get the input for the selected field
                    temp = Input.GetInput(_content[_selectedInputField - 1].Second, _contentLength[_selectedInputField - 1].First, _contentLength[_selectedInputField - 1].Second);

                    // check if the user saved their input choice
                    if ((temp.First & InputRetCode.SAVE) != 0)
                    {
                        // save the input choice into the form
                        _content[_selectedInputField - 1].Second = temp.Second;
                    }
                    // user canceled their input
                    else
                    {
                        // reset the position of the cursor
                        Console.CursorTop  = 0;
                        Console.CursorLeft = 0;

                        // re-display the form, overwriting the old one therefore not seeing the input that was just canceled
                        Container.DisplayContent(_content, 0, _selectedInputField, MenuCodes.PATIENTS, "Patients", Description);
                    }

                    // check if the user wants to change index to field above
                    if ((temp.First & InputRetCode.UP) != 0)
                    {
                        userInput = ConsoleKey.DownArrow;
                    }

                    // check if the user wants to change index to field below
                    if ((temp.First & InputRetCode.DOWN) != 0)
                    {
                        userInput = ConsoleKey.DownArrow;
                    }
                }
                // user selected to add the patient information they just entered
                else if (userInput == ConsoleKey.Enter && _selectedInputField == ADDBUTTON)
                {
                    bool validInfo = true;
                    int  errorOffset = 41, lineOffset = 6;

                    // get the value of the head of house from the form
                    newPatient.HeadOfHouse = _content[lineOffset].Second;
                    // check if it is a valid head of house number
                    if ((newPatient.HeadOfHouse != _content[lineOffset].Second) && _content[lineOffset].Second != "")
                    {
                        validInfo = PrintErrorOnLine(pInitialPosition, "Head of House error", lineOffset, errorOffset);
                    }
                    else
                    {
                        // get the patient information of the head of house
                        Patient headOfHouse = demographics.GetPatientByHCN(newPatient.HeadOfHouse);

                        // check if the head of house exists and the field was not left blank
                        if (newPatient.HeadOfHouse != "" && headOfHouse != null)
                        {
                            // the head of house is valid therefore filling in some of the fields with their information

                            // ADDRESS LINE 1
                            lineOffset++;
                            newPatient.AddressLine1     = headOfHouse.AddressLine1;
                            _content[lineOffset].Second = newPatient.AddressLine1;

                            // ADDRESS LINE 2
                            lineOffset++;
                            if (headOfHouse.AddressLine2 != null)
                            {
                                newPatient.AddressLine2     = headOfHouse.AddressLine2;
                                _content[lineOffset].Second = newPatient.AddressLine2;
                            }

                            // CITY LINE
                            lineOffset++;
                            newPatient.City             = headOfHouse.City;
                            _content[lineOffset].Second = newPatient.City;

                            // PROVINCE
                            lineOffset++;
                            newPatient.Province         = headOfHouse.Province;
                            _content[lineOffset].Second = newPatient.Province;

                            // PHONE NUMBER
                            lineOffset++;
                            newPatient.PhoneNum         = headOfHouse.PhoneNum;
                            _content[lineOffset].Second = newPatient.PhoneNum;

                            Container.DisplayContent(_content, 0, _selectedInputField, MenuCodes.PATIENTS, "Patients", Description);
                        }
                        // the head of house was either not set or doesnt exist therefore user has to enter rest of information
                        else
                        {
                            // ADDRESS LINE 1
                            lineOffset++;
                            if (newPatient.AddressLine1 == null)
                            {
                                newPatient.AddressLine1 = _content[lineOffset].Second;
                            }
                            if (newPatient.AddressLine1 != _content[lineOffset].Second.ToUpper() || newPatient.AddressLine1 == "")
                            {
                                validInfo = PrintErrorOnLine(pInitialPosition, "Address error", lineOffset, errorOffset);
                            }

                            // ADDRESS LINE 2
                            lineOffset++;
                            if (newPatient.AddressLine2 == null)
                            {
                                newPatient.AddressLine2 = _content[lineOffset].Second;
                            }
                            if ((newPatient.AddressLine2 != _content[lineOffset].Second) && _content[lineOffset].Second != "")
                            {
                                validInfo = PrintErrorOnLine(pInitialPosition, "Address error", lineOffset, errorOffset);
                            }

                            // CITY LINE
                            lineOffset++;
                            if (newPatient.City == null)
                            {
                                newPatient.City = _content[lineOffset].Second;
                            }
                            if (newPatient.City != _content[lineOffset].Second || newPatient.City == "")
                            {
                                validInfo = PrintErrorOnLine(pInitialPosition, "City error", lineOffset, errorOffset);
                            }

                            // PROVINCE
                            lineOffset++;
                            if (newPatient.Province == null)
                            {
                                newPatient.Province = _content[lineOffset].Second;
                            }
                            if (newPatient.Province != _content[lineOffset].Second || newPatient.Province == "")
                            {
                                validInfo = PrintErrorOnLine(pInitialPosition, "Province error", lineOffset, errorOffset);
                            }

                            // PHONE NUMBER
                            lineOffset++;
                            if (newPatient.PhoneNum == null)
                            {
                                newPatient.PhoneNum = _content[lineOffset].Second;
                            }
                            if (newPatient.PhoneNum != _content[lineOffset].Second || newPatient.PhoneNum == "")
                            {
                                validInfo = PrintErrorOnLine(pInitialPosition, "Phone number error", lineOffset, errorOffset);
                            }
                        }

                        lineOffset = 0;

                        // set the rest of the patient information and display any error messages if there were any
                        // FIRST NAME
                        newPatient.FirstName = _content[lineOffset].Second;
                        if (newPatient.FirstName != _content[lineOffset].Second.ToUpper() || newPatient.FirstName == "")
                        {
                            validInfo = PrintErrorOnLine(pInitialPosition, "First name error", lineOffset, errorOffset);
                        }

                        // LAST NAME
                        lineOffset++;
                        newPatient.LastName = _content[lineOffset].Second;
                        if (newPatient.LastName != _content[lineOffset].Second.ToUpper() || newPatient.LastName == "")
                        {
                            validInfo = PrintErrorOnLine(pInitialPosition, "Last name error", lineOffset, errorOffset);
                        }

                        // HCN
                        lineOffset++;
                        newPatient.HCN = _content[lineOffset].Second;
                        if (newPatient.HCN != _content[lineOffset].Second.ToUpper() || newPatient.HCN == "")
                        {
                            validInfo = PrintErrorOnLine(pInitialPosition, "Health card number error", lineOffset, errorOffset);
                        }

                        // MIDDLE INITIAL
                        lineOffset++;
                        newPatient.MInitial = _content[lineOffset].Second;
                        if (newPatient.MInitial != _content[lineOffset].Second.ToUpper() && newPatient.MInitial == "")
                        {
                            validInfo = PrintErrorOnLine(pInitialPosition, "Middle initial error", lineOffset, errorOffset);
                        }

                        //  DATE OF BIRTH
                        lineOffset++;
                        newPatient.DateOfBirth = _content[lineOffset].Second;
                        if (newPatient.DateOfBirth != _content[lineOffset].Second.ToUpper() || newPatient.DateOfBirth == "")
                        {
                            validInfo = PrintErrorOnLine(pInitialPosition, "Date of Birth error", lineOffset, errorOffset);
                        }

                        // GENDER
                        lineOffset++;
                        newPatient.Sex = _content[lineOffset].Second;
                        if (newPatient.Sex != _content[lineOffset].Second.ToUpper() || newPatient.Sex == "")
                        {
                            validInfo = PrintErrorOnLine(pInitialPosition, "Gender error", lineOffset, errorOffset);
                        }
                    }

                    // check if all the info was valid and the patient does not need to be returned
                    if (validInfo && !returnPatient)
                    {
                        // add the new patient to the database
                        demographics.AddNewPatient(newPatient);

                        // display the message the the patient was successfully added
                        Container.DisplayContent(new List <KeyValuePair <string, string> >()
                        {
                            new KeyValuePair <string, string>("Patient successfully added!", "")
                        }, 0, _selectedInputField, MenuCodes.PATIENTS, "Patients", Description);

                        // wait for the user to confirm that they have seen the message
                        Console.ReadKey();
                        break;
                    }
                    // check if all the info was valid and return the patient
                    else if (validInfo && returnPatient)
                    {
                        return(newPatient);
                    }
                }

                // change the menu based on the key pressed by the user
                if (ChangeInputField(userInput))
                {
                    // check if the user requested to return
                    if (_return)
                    {
                        break;
                    }

                    // redisplay the content with the changes that were requested
                    Container.DisplayContent(_content, 0, _selectedInputField, MenuCodes.PATIENTS, "Patients", Description);
                }
            } while (!_return);

            // clear console before returning
            Console.Clear();
            return(null);
        }