Beispiel #1
0
        /// <summary>
        /// General search that returns the average of the most recent HgA1C and HDL test for all patients.
        /// </summary>
        /// <returns>
        /// Returns a ListViewItem with the first slot being HDL and second being HgA1C.
        /// </returns>
        private ListViewItem DiabeticSearch()
        {
            connection.Open();
            string testSearch = "Select * FROM " + HgA1C.getTestType() + " where (PatientID, DateOfTest) in (select PatientID, max(DateOfTest) as date from " + HgA1C.getTestType() + " group by PatientID )";

            Console.WriteLine(testSearch);
            MySqlCommand    cmd        = new MySqlCommand(testSearch, connection);
            MySqlDataReader reader     = cmd.ExecuteReader();
            int             i          = 0;
            double          HDLCount   = 0;
            double          HgA1cCount = 0;

            while (reader.Read())
            {
                HDLCount   += reader.GetDouble(HDL.getDouble());
                HgA1cCount += reader.GetDouble(HgA1C.getDouble());
                i++;
            }
            HDLCount /= i;
            ListViewItem lv = new ListViewItem(HDLCount.ToString());

            HgA1cCount /= i;
            lv.SubItems.Add(HgA1cCount.ToString());
            connection.Close();
            reader.Close();
            return(lv);
        }
Beispiel #2
0
        /// <summary>
        /// Search that returns the average BMI for all male patients based on the most recent height and weight measurements
        /// </summary>
        /// <param name="lv">
        /// Needs to be the ListViewItem returned by MaleDiabeticSearch()
        /// </param>
        /// <returns>
        /// Returns a ListViewItem with the thrid slot being BMI, First and Second slot should be set by earlier MaleDiabeticSearch.
        /// </returns>
        private ListViewItem MaleBMISearch(ListViewItem lv)
        {
            connection.Open();
            string testSearch = "Select* FROM " + Patient_Height.getTestType() + " where(PatientID, DateOfTest) in (select PatientID, max(DateOfTest) as date from " + Patient_Height.getTestType() + " Where PatientID in (Select PatientID from Demographics where Gender = \"m\") group by PatientID )";

            Console.WriteLine(testSearch);
            MySqlCommand    cmd    = new MySqlCommand(testSearch, connection);
            MySqlDataReader reader = cmd.ExecuteReader();
            int             i      = 0;
            List <double>   w      = new List <double>();

            while (reader.Read())
            {
                w.Add(reader.GetDouble(Weight.getDouble()));
                Console.WriteLine(w[i]);
                i++;
            }
            i = 0;

            testSearch = "Select * FROM " + Weight.getTestType() + " where (PatientID, DateOfTest) in (select PatientID , max(DateOfTest) as date from " + Weight.getTestType() + " Where PatientID in (Select PatientID from Demographics where Gender = \"m\") group by PatientID )";

            cmd = new MySqlCommand(testSearch, connection);
            reader.Close();
            reader = cmd.ExecuteReader();
            List <double> h = new List <double>();

            while (reader.Read())
            {
                h.Add(reader.GetDouble(Patient_Height.getDouble()));
                Console.WriteLine(h[i]);
                i++;
            }

            int    k        = 0;
            double totalBMI = 0;

            for (int j = 0; j < i; j++)
            {
                totalBMI += ((w[j] * .45) / ((h[j] * .025) * (h[j] * .025)));
                Console.WriteLine((w[j] * .45) + " / " + ((h[j] * .025) * (h[j] * .025)));
                Console.WriteLine(totalBMI);
                k++;
            }
            totalBMI /= k;
            lv.SubItems.Add(totalBMI.ToString());
            lv.SubItems.Add("Males");
            reader.Close();
            connection.Close();
            return(lv);
        }
Beispiel #3
0
        void BMIDatabaseSearch()// (weight *.45)/((height*.025)^2)
        {
            if (id != null)
            {
                //graphName = test.toString();
                //chart1.Series.Add(graphName);//not working, cannot add a same series twice
                connection.Open();
                string testSearch = "Select * FROM " + Weight.getTestType() + " Where PatientID =" + id + " ORDER BY DateOfTest;";
                Console.WriteLine(testSearch);
                MySqlCommand    cmd    = new MySqlCommand(testSearch, connection);
                MySqlDataReader reader = cmd.ExecuteReader();



                chart1.Series[graphName].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
                int           i = 0;
                List <double> w = new List <double>();
                while (reader.Read())
                {
                    w.Add(reader.GetDouble(Weight.getDouble()));
                    i++;
                }
                i = 0;

                testSearch = "Select * FROM " + Patient_Height.getTestType() + " Where PatientID =" + id + " ORDER BY DateOfTest;";

                cmd = new MySqlCommand(testSearch, connection);
                reader.Close();
                reader = cmd.ExecuteReader();
                List <double> h = new List <double>();
                while (reader.Read())
                {
                    h.Add(reader.GetDouble(Patient_Height.getDouble()));
                    i++;
                }

                for (int j = 0; j < i; j++)
                {
                    Console.WriteLine(w[j] * .45 / ((h[j] * .025) * (h[j] * .025)));
                    chart1.Series[graphName].Points.AddY(w[j] * .45 / ((h[j] * .025) * (h[j] * .025)));
                }

                reader.Close();
                connection.Close();
                chart1.Series[graphName].ChartArea = "ChartArea1";
            }
        }
Beispiel #4
0
 /*
  * Searches the database based on which test is selected in the drop down boxes
  * Parameter Test: this should be one of the predefined test types, (I.E. 'HgA1C')
  * */
 void databaseSearch(TestNum test)
 {
     if (id != null)
     {
         //graphName = test.toString();
         //chart1.Series.Add(graphName);//not working, cannot add a same series twice
         connection.Open();
         string testSearch = "Select * FROM " + test.getTestType() + " Where PatientID =" + id + " ORDER BY DateOfTest;";
         Console.WriteLine(testSearch);
         MySqlCommand    cmd    = new MySqlCommand(testSearch, connection);
         MySqlDataReader reader = cmd.ExecuteReader();
         chart1.Series[graphName].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
         while (reader.Read())
         {
             chart1.Series[graphName].Points.AddY(reader.GetDouble(test.getDouble()));
         }
         chart1.Series[graphName].ChartArea = "ChartArea1";
         reader.Close();
         connection.Close();
     }
 }