Пример #1
0
        public void IntegrationTest_EnsureDatabaseIsReadable_TestSearchById_ReturnsExpectedPatientName()
        {
            var expected = patientForQueries[NAME_COLUMN].ToString();

            var            resultsSet = PatientController.FindPatient(300);
            List <DataRow> tableList  = resultsSet.AsEnumerable().ToList();

            var actual = tableList[0].ItemArray[NAME_COLUMN];

            Assert.That(actual, Is.EqualTo(expected));
        }
Пример #2
0
        public void IntegrationTest_EnsureDatabaseIsReadable_TestSearchByNameAndDateOfBirth_ReturnsExpectedPatientId()
        {
            var      expected    = 300;
            var      patientName = patientForQueries[NAME_COLUMN].ToString();
            DateTime patientDob  = Convert.ToDateTime(patientForQueries[DOB_COLUMN]);

            var            resultsSet = PatientController.FindPatient(patientName, patientDob);
            List <DataRow> tableList  = resultsSet.AsEnumerable().ToList();

            var actual = tableList[0].ItemArray[ID_COLUMN];

            Assert.That(actual, Is.EqualTo(expected));
        }
Пример #3
0
        private void btn_SearchPatients_Click(object sender, EventArgs e)
        {
            const int DATE_TODAY = 0;

            var id        = txtbx_SearchIdField.Text;
            var name      = txtbx_SearchNameField.Text.ToLower();
            var dob       = dtp_SearchDobSelector.Value;
            var address   = txtbx_SearchAddressField.Text.ToLower();
            var dateMatch = dob.CompareTo(DateTime.Today);

            // Protect against no data entered at all
            if (String.IsNullOrEmpty(id) && String.IsNullOrEmpty(name) && dateMatch == DATE_TODAY && String.IsNullOrEmpty(address))
            {
                MessageBox.Show("Please enter an ID, Name and Address, or Name and Date of Birth to search by.", "Error!",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            // If the ID field is populated, only search with that
            if (!String.IsNullOrWhiteSpace(id))
            {
                if (int.TryParse(id, out int tmp))
                {
                    var res = PatientController.FindPatient(tmp);

                    // Check data came back
                    if (res.Rows.Count > 0)
                    {
                        dGrid_SearchPatientResults.DataSource = res; return;
                    }
                    else
                    {
                        MessageBox.Show("No records found matching that criteria.",
                                        "No data found!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                }
                else
                {
                    // Inform the user the search criteria may be invalid
                    MessageBox.Show("The ID provided was invalid. Ensure you enter a number (Eg. 101)",
                                    "Incorrect input format", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }

            // If the ID isn't populated, but both name and address are
            if (!String.IsNullOrWhiteSpace(name) && !String.IsNullOrWhiteSpace(address))
            {
                var res = PatientController.FindPatient(name, address);

                if (res.Rows.Count > 0)
                {
                    dGrid_SearchPatientResults.DataSource = res; return;
                }
                else
                {
                    MessageBox.Show("No records found matching that criteria.",
                                    "No data found!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }


            // If either the ID or name and address aren't populated, attempt to search by name and date (if the date has changed)
            if (!String.IsNullOrWhiteSpace(name) && dateMatch != DATE_TODAY)
            {
                var res = PatientController.FindPatient(name, dob);

                if (res.Rows.Count > 0)
                {
                    dGrid_SearchPatientResults.DataSource = res;  return;
                }
                else
                {
                    MessageBox.Show("No records found matching that criteria.",
                                    "No data found!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }

            dtp_SearchDobSelector.Value = DateTime.Today;
        }