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(); } }
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(); } }
private void TbHeadOfHouse_TextChanged(object sender, TextChangedEventArgs e) { Patient p = demographics.GetPatientByHCN(tbHeadOfHouse.Text); if (p != null) { tbAddress1.Text = p.AddressLine1; tbAddress2.Text = p.AddressLine2; tbCity.Text = p.City; tbPhoneNumber.Text = p.PhoneNumber; tbPostalCode.Text = p.PostalCode; cbProvince.SelectedValue = p.Province; } this.DataContext = addingPatient; }
public void Functional_GetPatientIDByHCN() { try { Demographics d = new Demographics(); int pID = d.GetPatientIDByHCN("1234567890AB"); Patient p = d.GetPatientByHCN("1234567890AB"); if (!(pID == p.PatientID)) { Assert.Fail(); } } catch (Exception) { Assert.Fail(); } }
/** * \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); }
/** * \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); }