/// <summary>
 /// Constructor for the form
 /// </summary>
 /// <param name="testCode">the test code associated with the conducted test (part of the key)</param>
 /// <param name="referringForm">the referring ViewVisitForm</param>
 public EnterLabTestResultForm(int testCode, ViewVisitForm referringForm)
 {
     InitializeComponent();
     this.referringForm = referringForm;
     this.testCode      = testCode;
     this.theConductedLabTestController = new ConductedLabTestController();
     this.currentConductedLabTest       = this.GetCurrentConductedLabTest();
     if (this.currentConductedLabTest.Results != null)
     {
         string boxMessage = "The lab result has already been recorded and cannot be edited.";
         string boxTitle   = "Lab Test Result Previously Recorded";
         MessageBox.Show(boxMessage, boxTitle);
         this.Close();
     }
     this.referringForm.Enabled = false;
     this.SetPrefilledValues();
 }
Exemple #2
0
        /// <summary>
        /// HAndles the enter results button click events
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void EnterResult_Click(object sender, EventArgs e)
        {
            if (this.testsListView.SelectedItems.Count == 0)
            {
                MessageBox.Show("Please select a Test, then click the button again.", "Select a Test to Enter Results");
                return;
            }
            int selectedIndex             = this.testsListView.SelectedIndices[0];
            ConductedLabTest selectedTest = this.theTests[selectedIndex];

            try
            {
                EnterLabTestResultForm enterLabTestResultForm = new EnterLabTestResultForm(selectedTest.LabTest.TestCode, this);
                enterLabTestResultForm.Show();
            }
            catch (Exception)
            {
                this.Enabled = true;
            }
        }
Exemple #3
0
        /// <summary>
        /// Method that returns all of the conducted lab tests for the specified appointment.
        /// </summary>
        /// <param name="appointmentId">The ID of the appointment.</param>
        /// <returns>A list of the conducted lab tests for the specified appointment.</returns>
        public List <ConductedLabTest> GetConductedLabTests(int appointmentId)
        {
            if (appointmentId < 0)
            {
                throw new ArgumentException("The appointment ID cannot be negative.", "appointmentId");
            }

            List <ConductedLabTest> conductedLabTests = new List <ConductedLabTest>();

            string selectStatement =
                "SELECT clt.appointmentId, clt.testCode, lt.name, clt.datePerformed, clt.results, clt.isNormal, pers.firstName, pers.lastName " +
                "FROM ConductedLabTest clt " +
                "JOIN LabTest lt ON lt.testCode = clt.testCode " +
                "JOIN Appointment a ON clt.appointmentId = a.appointmentId " +
                "JOIN Patient pat ON a.patientId = pat.patientId " +
                "JOIN Person pers ON pat.personId = pers.personId " +
                "WHERE clt.appointmentId = @AppointmentId";

            using (SqlConnection connection = ClinicDBConnection.GetConnection())
            {
                connection.Open();
                using (SqlCommand selectCommand = new SqlCommand(selectStatement, connection))
                {
                    selectCommand.Parameters.AddWithValue("@AppointmentId", appointmentId);
                    using (SqlDataReader reader = selectCommand.ExecuteReader())
                    {
                        int appointmentIdOrdinal = reader.GetOrdinal("appointmentId");
                        int testCodeOrdinal      = reader.GetOrdinal("testCode");
                        int testNameOrdinal      = reader.GetOrdinal("name");
                        int datePerformedOrdinal = reader.GetOrdinal("datePerformed");
                        int resultsOrdinal       = reader.GetOrdinal("results");
                        int isNormalOrdinal      = reader.GetOrdinal("isNormal");
                        int firstNameOrdinal     = reader.GetOrdinal("firstName");
                        int lastNameOrdinal      = reader.GetOrdinal("lastName");
                        while (reader.Read())
                        {
                            LabTest labTest = new LabTest();
                            if (!reader.IsDBNull(testCodeOrdinal))
                            {
                                labTest.TestCode = reader.GetInt32(testCodeOrdinal);
                            }
                            if (!reader.IsDBNull(testNameOrdinal))
                            {
                                labTest.Name = reader.GetString(testNameOrdinal);
                            }

                            ConductedLabTest conductedLabTest = new ConductedLabTest
                            {
                                LabTest = labTest
                            };

                            if (!reader.IsDBNull(appointmentIdOrdinal))
                            {
                                conductedLabTest.AppointmentId = reader.GetInt32(appointmentIdOrdinal);
                            }
                            if (!reader.IsDBNull(datePerformedOrdinal))
                            {
                                conductedLabTest.DatePerformed = reader.GetDateTime(datePerformedOrdinal);
                            }
                            if (!reader.IsDBNull(resultsOrdinal))
                            {
                                conductedLabTest.Results = reader.GetString(resultsOrdinal);
                            }
                            if (!reader.IsDBNull(isNormalOrdinal))
                            {
                                conductedLabTest.IsNormal = reader.GetBoolean(isNormalOrdinal);
                            }
                            if (!reader.IsDBNull(firstNameOrdinal))
                            {
                                conductedLabTest.FirstName = reader.GetString(firstNameOrdinal);
                            }
                            if (!reader.IsDBNull(lastNameOrdinal))
                            {
                                conductedLabTest.LastName = reader.GetString(lastNameOrdinal);
                            }
                            conductedLabTests.Add(conductedLabTest);
                        }
                    }
                }
            }
            return(conductedLabTests);
        }