private void AddPatient(Test_Patient test, Patient tempPatient, PatientHousehold household) { ThreadUtilities.RunOnUIThread(new Action(() => { test.Activate(); })); UIUtilities.TypeIntoTextbox(test.text_AgeGroup, tempPatient.PatientAgeGroup); UIUtilities.TypeIntoTextbox(test.text_Ethnicity, tempPatient.PatientEthnicity); UIUtilities.TypeIntoTextbox(test.text_FirstName, tempPatient.PatientFirstName); UIUtilities.TypeIntoTextbox(test.text_Gender, tempPatient.PatientGender); UIUtilities.TypeIntoTextbox(test.text_LastName, tempPatient.PatientLastName); UIUtilities.TypeIntoTextbox(test.text_PatientOQ, tempPatient.PatientOQ); UIUtilities.TypeIntoTextbox(test.text_RelationToHEad, tempPatient.RelationToHead); if (tempPatient.IsHead) { UIUtilities.ClickOnItem(test.check_IsHead); } if (tempPatient.HouseholdID == 0) { UIUtilities.ClickOnItem(test.check_NewHousehold); UIUtilities.TypeIntoTextbox(test.text_county, household.HouseholdCounty); UIUtilities.TypeIntoTextbox(test.text_Income, household.HouseholdIncomeBracket); UIUtilities.TypeIntoTextbox(test.text_HouseholdPop, household.HouseholdPopulation.ToString()); } else { UIUtilities.TypeIntoTextbox(test.text_HouseholdID, tempPatient.HouseholdID.ToString()); } UIUtilities.ClickOnItem(test.button_AddPatient); }
private void Add_Client(object sender, RoutedEventArgs e) { Patient tempPatient = new Patient(); Problem tempProblem = new Problem(); FCS_DBModel db = new FCS_DBModel(); Determine_AgeGroup(combobox_AgeGroup.SelectedIndex); Determine_EthnicGroup(combobox_ethnicity.SelectedIndex); Determine_Gender(combobox_Gender.SelectedIndex); var togglePatientProblems = PatientProblemsCheckBoxes.Children; try { // Check to see if there needs to be a new household made first if ((bool)check_FirstHouseholdMember.IsChecked) { Determine_Income(combobox_IncomeBracket.SelectedIndex); Determine_County(combobox_County.SelectedIndex); PatientHousehold household = new PatientHousehold(); household.HouseholdCounty = County; household.HouseholdIncomeBracket = Income; household.HouseholdPopulation = HouseholdPopulation; db.PatientHouseholds.Add(household); db.SaveChanges(); tempPatient.HouseholdID = household.HouseholdID; } else { tempPatient.HouseholdID = db.Patients.Where(x => x.PatientOQ == familyOQNumber).Select(x => x.HouseholdID).Distinct().First(); } bool isHeadOfHouse = (bool)check_HeadOfHousehold.IsChecked; tempPatient.PatientOQ = patientOQ; tempPatient.PatientFirstName = firstName; tempPatient.PatientLastName = lastName; tempPatient.PatientAgeGroup = ageGroup; tempPatient.PatientEthnicity = ethnicGroup; tempPatient.PatientGender = PatientGender; tempPatient.NewClientIntakeHour = DateTime.Now; tempPatient.IsHead = headOfHouse; tempPatient.RelationToHead = (headOfHouse) ? "Head" : relationToHead; db.Patients.Add(tempPatient); db.SaveChanges(); Determine_Problems(patientOQ, togglePatientProblems); this.Close(); } catch (Exception error) { MessageBox.Show("Something went wrong, please double check your entry values.\n\n"); MessageBox.Show("Error: " + error.ToString()); } }
public void TestAddingDuplicatePatient() { Patient tempPatient = new Patient(); tempPatient.PatientOQ = "123451"; tempPatient.PatientFirstName = "Test"; tempPatient.PatientLastName = "McGee"; tempPatient.RelationToHead = "Related"; tempPatient.PatientGender = "Female"; tempPatient.PatientEthnicity = "Pacific Islander"; tempPatient.PatientAgeGroup = "12-17"; tempPatient.IsHead = false; // Premade household PatientHousehold tempHousehold = new PatientHousehold(); tempHousehold.HouseholdCounty = "Box Elder"; tempHousehold.HouseholdIncomeBracket = "$25,000-34,999"; tempHousehold.HouseholdPopulation = 7; // Add the patient with new household Test_Patient tpat = OpenTestPatient(); DeletePatient(tpat, tempPatient.PatientOQ); AddPatient(tpat, tempPatient, tempHousehold); // Open the client window Window_Client window = OpenCreateNewPatient(); // Add the patient UIUtilities.ClickOnItem(window.check_HeadOfHousehold); UIUtilities.TypeIntoTextbox(window.textbox_ClientOQ, tempPatient.PatientOQ); UIUtilities.TypeIntoTextbox(window.textbox_FirstName, tempPatient.PatientFirstName); UIUtilities.TypeIntoTextbox(window.textbox_LastName, tempPatient.PatientLastName); UIUtilities.SelectComboboxItem(window.combobox_AgeGroup, tempPatient.PatientAgeGroup); UIUtilities.SelectComboboxItem(window.combobox_ethnicity, tempPatient.PatientEthnicity); UIUtilities.SelectComboboxItem(window.combobox_Gender, tempPatient.PatientGender); // Check that it added UIUtilities.ClickOnItemNoWait(window.button_AddUpdateClient); UIUtilities.CloseWindow(tpat); ThreadUtilities.RunOnUIThread(new Action(() => { // Is the window still open after clicking, because the error dialog should be showing if (Application.Current.Windows.Count == 0) { Assert.Fail("The window closed down when it should have stayed open after adding a duplicate Patient OQ."); } })); UIUtilities.CloseWindow(window); }
private void button_AddPatient_Click(object sender, RoutedEventArgs e) { try { Patient tempPatient = new Patient(); Problem tempProblem = new Problem(); FCS_DBModel db = new FCS_DBModel(); if ((bool)check_NewHousehold.IsChecked) { int HouseholdPopulation = int.Parse(text_HouseholdPop.Text); string Income = text_Income.Text; string County = text_county.Text; PatientHousehold household = new PatientHousehold(); household.HouseholdCounty = County; household.HouseholdIncomeBracket = Income; household.HouseholdPopulation = HouseholdPopulation; db.PatientHouseholds.Add(household); db.SaveChanges(); tempPatient.HouseholdID = household.HouseholdID; } else { tempPatient.HouseholdID = int.Parse(text_HouseholdID.Text); } tempPatient.PatientOQ = text_PatientOQ.Text; tempPatient.PatientAgeGroup = text_AgeGroup.Text; tempPatient.PatientEthnicity = text_Ethnicity.Text; tempPatient.PatientFirstName = text_FirstName.Text; tempPatient.PatientGender = text_Gender.Text; tempPatient.PatientLastName = text_LastName.Text; tempPatient.RelationToHead = text_RelationToHEad.Text; tempPatient.IsHead = (bool)check_IsHead.IsChecked; tempPatient.NewClientIntakeHour = DateTime.Now; db.Patients.Add(tempPatient); db.SaveChanges(); } catch (Exception error) { } }
private void Add_Household(object sender, RoutedEventArgs e) { Determine_County(this.HouseholdCounty.SelectedIndex); Determine_Income(this.HouseholdIncomeBracket.SelectedIndex); if (Income != null && HouseholdPopulation > 0 && County != null && County != "") { date = DateTime.Now; //MessageBox.Show(firstName + "\n" + lastName + "\n" + patientOQ + "\n" + gender + "\n" + headOfHouse + "\n" + ageGroup + "\n" + ethnicGroup // + "\n" + "\n" + date + "\n" + HouseholdPopulation + "\n" + County + "\n" + Income); FCS_DBModel db = new FCS_DBModel(); PatientHousehold p = new PatientHousehold(); p.HouseholdCounty = County; p.HouseholdPopulation = HouseholdPopulation; p.HouseholdIncomeBracket = Income; Patient pat = new Patient(); pat.PatientOQ = patientOQ; pat.HouseholdID = p.HouseholdID; pat.PatientFirstName = firstName; pat.PatientLastName = lastName; pat.PatientGender = gender; pat.PatientAgeGroup = ageGroup; pat.PatientEthnicity = ethnicGroup; pat.NewClientIntakeHour = date; pat.IsHead = headOfHouse; pat.RelationToHead = relationToHead; db.PatientHouseholds.Add(p); db.Patients.Add(pat); db.SaveChanges(); Determine_Problems(patientOQ, togglePatientProblems); MessageBox.Show("Successfully added Client and Household."); this.Close(); } //add both patient and household else { MessageBox.Show("Make sure to select an income, a household population, and input a county."); } }
private void Add_Client(object sender, RoutedEventArgs e) { Patient tempPatient = new Patient(); Problem tempProblem = new Problem(); FCS_DBModel db = new FCS_DBModel(); // Check to see if the OQ number is already taken try { string strPatientOQ = patientOQ.ToString(); string duplicateQO = db.Patients.Where(x => x.PatientOQ == patientOQ).Select(x => x.PatientOQ).Distinct().First(); if (!string.IsNullOrEmpty(duplicateQO)) { MessageBox.Show("The OQ Number is already taken, please enter a different OQ number."); return; } } catch { } ageGroup = combobox_AgeGroup.Text; ethnicGroup = combobox_ethnicity.Text; PatientGender = combobox_Gender.Text; try { // Check to see if there needs to be a new household made first if ((bool)check_FirstHouseholdMember.IsChecked) { Income = combobox_IncomeBracket.Text; County = combobox_County.Text; PatientHousehold household = new PatientHousehold(); household.HouseholdCounty = County; household.HouseholdIncomeBracket = Income; household.HouseholdPopulation = HouseholdPopulation; db.PatientHouseholds.Add(household); db.SaveChanges(); tempPatient.HouseholdID = household.HouseholdID; } else { try { tempPatient.HouseholdID = db.Patients.Where(x => x.PatientOQ == familyOQNumber).Select(x => x.HouseholdID).Distinct().First(); } catch (Exception error) { MessageBox.Show("The provided Family OQ Number does not exist. Please double-check the Family OQ Number.", "Family OQ Number Doesn't Exist", MessageBoxButton.OK, MessageBoxImage.Error); return; } } bool isHeadOfHouse = (bool)check_HeadOfHousehold.IsChecked; tempPatient.PatientOQ = patientOQ; tempPatient.PatientFirstName = firstName; tempPatient.PatientLastName = lastName; tempPatient.PatientAgeGroup = ageGroup; tempPatient.PatientEthnicity = ethnicGroup; tempPatient.PatientGender = PatientGender; DateTime ClientIntakeDateTime; bool result = DateTime.TryParse(date_ClientCreationDate.Text, out ClientIntakeDateTime); if (result == true) { tempPatient.NewClientIntakeHour = ClientIntakeDateTime; } else { MessageBox.Show("Please enter a valid Client Creation date"); return; } tempPatient.IsHead = headOfHouse; tempPatient.RelationToHead = (headOfHouse) ? "Head" : relationToHead; db.Patients.Add(tempPatient); db.SaveChanges(); Determine_Problems(patientOQ); this.Close(); } catch (Exception error) { MessageBox.Show("Something went wrong, please double check your entry values.\n\n"); MessageBox.Show("Error: " + error.ToString()); } }
public void TestAddingNewHousehold() { Patient tempPatient = new Patient(); tempPatient.PatientOQ = "123451"; tempPatient.PatientFirstName = "Test"; tempPatient.PatientLastName = "McGee"; tempPatient.RelationToHead = "Related"; tempPatient.PatientGender = "Female"; tempPatient.PatientEthnicity = "Pacific Islander"; tempPatient.PatientAgeGroup = "12-17"; tempPatient.IsHead = false; // Premade household PatientHousehold tempHousehold = new PatientHousehold(); tempHousehold.HouseholdCounty = "Box Elder"; tempHousehold.HouseholdIncomeBracket = "$25,000-34,999"; tempHousehold.HouseholdPopulation = 7; // Add the patient with new household Test_Patient tpat = OpenTestPatient(); DeletePatient(tpat, tempPatient.PatientOQ); // Open the client window Window_Client window = OpenCreateNewPatient(); // Add the patient UIUtilities.ClickOnItem(window.check_HeadOfHousehold); UIUtilities.TypeIntoTextbox(window.textbox_ClientOQ, tempPatient.PatientOQ); UIUtilities.TypeIntoTextbox(window.textbox_FirstName, tempPatient.PatientFirstName); UIUtilities.TypeIntoTextbox(window.textbox_LastName, tempPatient.PatientLastName); UIUtilities.SelectComboboxItem(window.combobox_AgeGroup, tempPatient.PatientAgeGroup); UIUtilities.SelectComboboxItem(window.combobox_ethnicity, tempPatient.PatientEthnicity); UIUtilities.SelectComboboxItem(window.combobox_Gender, tempPatient.PatientGender); // Add the household UIUtilities.ClickOnItem(window.check_FirstHouseholdMember); UIUtilities.TypeIntoTextbox(window.textbox_HouseholdPopulation, tempHousehold.HouseholdPopulation.ToString()); UIUtilities.SelectComboboxItem(window.combobox_County, tempHousehold.HouseholdCounty); UIUtilities.SelectComboboxItem(window.combobox_IncomeBracket, tempHousehold.HouseholdIncomeBracket); // Check that it added UIUtilities.ClickOnItemNoWait(window.button_AddUpdateClient); // Find the patient FindPatient(tpat, tempPatient.PatientOQ); // Check the values ThreadUtilities.RunOnUIThread(new Action(() => { Assert.AreEqual(tempHousehold.HouseholdCounty, tpat.text_county.Text); Assert.AreEqual(tempHousehold.HouseholdIncomeBracket, tpat.text_Income.Text); Assert.AreEqual(tempHousehold.HouseholdPopulation, int.Parse(tpat.text_HouseholdPop.Text)); })); UIUtilities.CloseWindow(tpat); }
public void TestUsingFamilyOQForHousehold() { // Premade Family Member Patient familyPatient = new Patient(); familyPatient.PatientOQ = "123450"; familyPatient.PatientFirstName = "Doodly"; familyPatient.PatientLastName = "Doo"; familyPatient.RelationToHead = "DA FATHER"; familyPatient.PatientGender = "Male"; familyPatient.PatientEthnicity = "Caucasian"; familyPatient.PatientAgeGroup = "24-44"; familyPatient.IsHead = true; // Premade household PatientHousehold familyHousehold = new PatientHousehold(); familyHousehold.HouseholdCounty = "Box Elder"; familyHousehold.HouseholdIncomeBracket = "$25,000-34,999"; familyHousehold.HouseholdPopulation = 7; // Patient to test with Patient tempPatient = new Patient(); tempPatient.PatientOQ = "123451"; tempPatient.PatientFirstName = "Test"; tempPatient.PatientLastName = "McGee"; tempPatient.RelationToHead = "Related"; tempPatient.PatientGender = "Female"; tempPatient.PatientEthnicity = "Pacific Islander"; tempPatient.PatientAgeGroup = "12-17"; tempPatient.IsHead = false; // Add the patient Test_Patient tpat = OpenTestPatient(); DeletePatient(tpat, tempPatient.PatientOQ); DeletePatient(tpat, familyPatient.PatientOQ); AddPatient(tpat, familyPatient, familyHousehold); // Add the temp patient manually, but link to previously-made family member Window_Client window = OpenCreateNewPatient(); UIUtilities.TypeIntoTextbox(window.textbox_FamilyMemberOQ, familyPatient.PatientOQ); UIUtilities.TypeIntoTextbox(window.textbox_ClientOQ, tempPatient.PatientOQ); UIUtilities.TypeIntoTextbox(window.textbox_FirstName, tempPatient.PatientFirstName); UIUtilities.TypeIntoTextbox(window.textbox_LastName, tempPatient.PatientLastName); UIUtilities.TypeIntoTextbox(window.textbox_RelationToHead, tempPatient.RelationToHead); UIUtilities.SelectComboboxItem(window.combobox_AgeGroup, tempPatient.PatientAgeGroup); UIUtilities.SelectComboboxItem(window.combobox_ethnicity, tempPatient.PatientEthnicity); UIUtilities.SelectComboboxItem(window.combobox_Gender, tempPatient.PatientGender); UIUtilities.ClickOnItemNoWait(window.button_AddUpdateClient); // Find the added patient FindPatient(tpat, tempPatient.PatientOQ); ThreadUtilities.RunOnUIThread(new Action(() => { Assert.AreEqual(familyHousehold.HouseholdCounty, tpat.text_county.Text); Assert.AreEqual(familyHousehold.HouseholdIncomeBracket, tpat.text_Income.Text); Assert.AreEqual(familyHousehold.HouseholdPopulation, int.Parse(tpat.text_HouseholdPop.Text)); })); // Clean up DeletePatient(tpat, tempPatient.PatientOQ); DeleteHousehold(tpat, familyPatient.PatientOQ); DeletePatient(tpat, familyPatient.PatientOQ); }