public void Null_GetPatientbyName() { try { Demographics d = new Demographics(); List <Patient> lP = d.GetPatientByName(null, null); } catch (Exception) { Assert.Fail(); } }
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(); } }
/** * \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); }