Exemple #1
0
        public List <PatientReadings> showReadings(MySqlConnection conn, string patientId)
        {
            List <PatientReadings> listOfTheReadings = new List <PatientReadings>();

            string sql = "SELECT pulseRate, breathingRate, systolic, diastolic, temperature FROM `patientreadings` WHERE patientId=" + patientId + " ORDER BY patientReadingId DESC LIMIT 1";

            MySqlCommand sqlComm = new MySqlCommand(sql, conn);

            using (MySqlDataReader sqlReader = sqlComm.ExecuteReader())
            {
                while (sqlReader.Read())
                {
                    PatientReadings mReadings = new PatientReadings();

                    mReadings.PulseRate     = (int)sqlReader.GetValue(0);
                    mReadings.BreathingRate = (int)sqlReader.GetValue(1);
                    mReadings.Systolic      = (int)sqlReader.GetValue(2);
                    mReadings.Diastolic     = (int)sqlReader.GetValue(3);
                    mReadings.Temperature   = (float)sqlReader.GetValue(4);

                    listOfTheReadings.Add(mReadings);
                }
            }

            return(listOfTheReadings);
        }
Exemple #2
0
        //Add normal data
        public void addPatientReading(MySqlConnection conn, PatientReadings pRead)
        {
            string sql = "INSERT INTO patientreadings (patientId, pulseRate, breathingRate, systolic, diastolic, " +
                         "temperature, dateAndTime) VALUES (" + pRead.PatientId + ", " + pRead.PulseRate + " , " + pRead.BreathingRate + ", " +
                         pRead.Systolic + ", " + pRead.Diastolic + ", " + pRead.Temperature + ", '" + pRead.DateTime + "')";

            MySqlCommand sqlComm = new MySqlCommand(sql, conn);

            sqlComm.ExecuteNonQuery();
        }
Exemple #3
0
        public List <PatientReadings> getReadings(MySqlConnection conn, int patientId, string readingNeeded)
        {
            List <PatientReadings> listOfReadings = new List <PatientReadings>();

            string sql = "";

            if (readingNeeded == "pulseRate" || readingNeeded == "breathingRate" || readingNeeded == "temperature")
            {
                sql = "SELECT " + readingNeeded + ", dateAndTime FROM patientreadings WHERE patientId=" + patientId;
            }
            else
            {
                sql = "SELECT systolic, diastolic, dateAndTime FROM patientreadings WHERE patientId=" + patientId;
            }

            MySqlCommand sqlComm = new MySqlCommand(sql, conn);

            using (MySqlDataReader sqlReader = sqlComm.ExecuteReader())
            {
                while (sqlReader.Read())
                {
                    PatientReadings mReadings = new PatientReadings();

                    if (readingNeeded == "pulseRate" || readingNeeded == "breathingRate")
                    {
                        mReadings.IntRate  = (int)sqlReader.GetValue(0);
                        mReadings.DateTime = (string)sqlReader.GetValue(1);
                    }
                    else if (readingNeeded == "temperature")
                    {
                        mReadings.FloatRate = (float)sqlReader.GetValue(0);
                        mReadings.DateTime  = (string)sqlReader.GetValue(1);
                    }
                    else
                    {
                        mReadings.IntRate  = (int)sqlReader.GetValue(0);
                        mReadings.IntRate2 = (int)sqlReader.GetValue(1);
                        mReadings.DateTime = (string)sqlReader.GetValue(2);
                    }

                    listOfReadings.Add(mReadings);
                }
            }

            return(listOfReadings);
        }
Exemple #4
0
        //Show on the central station one
        public string displayModuleReadings(MySqlConnection conn, PatientReadings pRead, string readingNeeded)
        {
            string reading = "";
            string sql     = "SELECT " + readingNeeded + " FROM patientreadings WHERE patientId=" + pRead.PatientId;

            MySqlCommand sqlComm = new MySqlCommand(sql, conn);

            sqlComm.ExecuteNonQuery();

            using (MySqlDataReader sqlReader = sqlComm.ExecuteReader())
            {
                while (sqlReader.Read())
                {
                    reading = (string)(sqlReader.GetValue(0)).ToString();
                }
            }

            return(reading);
        }
Exemple #5
0
        //Start or Halt button for module readings monitor
        public void button2_Click(object sender, EventArgs e)
        {
            if (button2.Text == "Halt")
            {
                DialogResult result = MessageBox.Show("Are you sure to terminate the module readings ?", "Alert !", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);

                if (result == DialogResult.Yes)
                {
                    haltMonitor();

                    if (label1.Text != "No Record Found")
                    {
                        MessageBox.Show("Closed running process");

                        DbConnector dbConn = new DbConnector();
                        dbConn.connect();

                        PatientReadings        pRead    = new PatientReadings();
                        PatientReadingsHandler pReadHnd = new PatientReadingsHandler();

                        pRead.PatientId     = Int32.Parse((label1.Text).ToString());
                        pRead.PulseRate     = 999;
                        pRead.BreathingRate = 999;
                        pRead.Systolic      = 999;
                        pRead.Diastolic     = 999;
                        pRead.Temperature   = 999;
                        pRead.DateTime      = DateTime.Now.ToString();

                        pReadHnd.addPatientReading(dbConn.getConn(), pRead);
                    }
                }
            }
            else if (button2.Text == "Start")
            {
                startMonitor();
            }
        }
Exemple #6
0
        //Stop beep sound and monitor while closing
        public void Bedside_System_FormClosed(object sender, FormClosedEventArgs e)
        {
            run_Monitor.Stop();
            player.Stop();

            if (button2.Text == "Halt" && label1.Text != "No Record Found")
            {
                DbConnector dbConn = new DbConnector();
                dbConn.connect();

                PatientReadings        pRead    = new PatientReadings();
                PatientReadingsHandler pReadHnd = new PatientReadingsHandler();

                pRead.PatientId     = Int32.Parse((label1.Text).ToString());
                pRead.PulseRate     = 999;
                pRead.BreathingRate = 999;
                pRead.Systolic      = 999;
                pRead.Diastolic     = 999;
                pRead.Temperature   = 999;
                pRead.DateTime      = DateTime.Now.ToString();

                pReadHnd.addPatientReading(dbConn.getConn(), pRead);
            }
        }
Exemple #7
0
        public void runMonitor(object sender, EventArgs e)
        {
            var pulseRate     = checkBox1.Checked;
            var breathingRate = checkBox2.Checked;
            var bloodPressure = checkBox3.Checked;
            var temperature   = checkBox4.Checked;

            var criticalColor = Color.FromArgb(255, 8, 8);
            var inRiskColor   = Color.FromArgb(255, 214, 8);
            var normalColor   = Color.FromArgb(8, 255, 86);

            line = sr.ReadLine();

            if (line == null)
            {
                sr   = new StreamReader("CSV/ModuleReadingsA.csv");
                line = sr.ReadLine();
            }

            DbConnector dbConn = new DbConnector();

            dbConn.connect();

            Patient        ptient = new Patient();
            PatientHandler patHnd = new PatientHandler();

            ptient.Wing  = (comboBox1.SelectedItem).ToString();
            ptient.Floor = (comboBox2.SelectedItem).ToString();
            ptient.Bay   = (comboBox3.SelectedItem).ToString();
            ptient.Bed   = (comboBox4.SelectedItem).ToString();

            string getPatientId = patHnd.getPatientDetails(dbConn.getConn(), ptient, "patientId");

            int   minPulse     = 60;
            int   maxPulse     = 100;
            int   minBreath    = 12;
            int   maxBreath    = 20;
            int   minSystolic  = 80;
            int   maxSystolic  = 120;
            int   minDiastolic = 60;
            int   maxDiastolic = 80;
            float minTemp      = 35.2F;
            float maxTemp      = 36.1F;

            int pulseIntervalTime         = 1;
            int breathIntervalTime        = 1;
            int bloodPressureIntervalTime = 1;
            int temperatureIntervalTime   = 1;

            if (getPatientId != "No record found")
            {
                ModuleReadingsHandler mRHand = new ModuleReadingsHandler();
                minPulse          = Int32.Parse(mRHand.getModuleReading(dbConn.getConn(), "pulseRMin", getPatientId));
                maxPulse          = Int32.Parse(mRHand.getModuleReading(dbConn.getConn(), "pulseRMax", getPatientId));
                pulseIntervalTime = Int32.Parse(mRHand.getModuleReading(dbConn.getConn(), "pulseRIntTime", getPatientId));

                minBreath          = Int32.Parse(mRHand.getModuleReading(dbConn.getConn(), "breathRMin", getPatientId));
                maxBreath          = Int32.Parse(mRHand.getModuleReading(dbConn.getConn(), "breathRMax", getPatientId));
                breathIntervalTime = Int32.Parse(mRHand.getModuleReading(dbConn.getConn(), "breathRIntTime", getPatientId));

                minSystolic  = Int32.Parse(mRHand.getModuleReading(dbConn.getConn(), "systolicMin", getPatientId));
                maxSystolic  = Int32.Parse(mRHand.getModuleReading(dbConn.getConn(), "systolicMax", getPatientId));
                minDiastolic = Int32.Parse(mRHand.getModuleReading(dbConn.getConn(), "diastolicMin", getPatientId));
                maxDiastolic = Int32.Parse(mRHand.getModuleReading(dbConn.getConn(), "diastolicMax", getPatientId));
                bloodPressureIntervalTime = Int32.Parse(mRHand.getModuleReading(dbConn.getConn(), "bloodPIntTime", getPatientId));

                minTemp = float.Parse(mRHand.getModuleReading(dbConn.getConn(), "tempMin", getPatientId));
                maxTemp = float.Parse(mRHand.getModuleReading(dbConn.getConn(), "tempMax", getPatientId));
                temperatureIntervalTime = Int32.Parse(mRHand.getModuleReading(dbConn.getConn(), "tempIntTime", getPatientId));
            }

            PatientReadings        pRead    = new PatientReadings();
            PatientReadingsHandler pReadHnd = new PatientReadingsHandler();

            try
            {
                string[] data = line.Split(',');

                readingsList.Add(Int32.Parse(data[0]));

                //Pulse Rate Readings
                if (counter == pulseRateCounter && pulseRate != false)
                {
                    label10.Text = data[0];
                    label14.Text = (maxPulse).ToString();
                    label15.Text = (minPulse).ToString();

                    if (Int32.Parse(data[0]) == 0)
                    {
                        labelBorder(10, "Critical");
                        label14.ForeColor = criticalColor;
                        label15.ForeColor = criticalColor;
                    }
                    else if (Int32.Parse(data[0]) > maxPulse || Int32.Parse(data[0]) < minPulse)
                    {
                        labelBorder(10, "Risky");

                        if (Int32.Parse(data[0]) > maxPulse)
                        {
                            label14.ForeColor = inRiskColor;
                            label15.ForeColor = normalColor;
                        }
                        else
                        {
                            label14.ForeColor = normalColor;
                            label15.ForeColor = inRiskColor;
                        }
                    }
                    else if (Int32.Parse(data[0]) >= minPulse && Int32.Parse(data[0]) <= maxPulse)
                    {
                        labelBorder(10, "Normal");
                        label14.ForeColor = normalColor;
                        label15.ForeColor = normalColor;
                    }

                    pulseRateCounter = pulseRateCounter + pulseIntervalTime;
                }

                //Breathing Rate Readings
                if (counter == breathingRateCounter && breathingRate != false)
                {
                    label11.Text = data[1];
                    label16.Text = (maxBreath).ToString();
                    label17.Text = (minBreath).ToString();

                    if (Int32.Parse(data[1]) == 0)
                    {
                        labelBorder(11, "Critical");
                        label16.ForeColor = criticalColor;
                        label17.ForeColor = criticalColor;
                    }
                    else if ((Int32.Parse(data[1]) > maxBreath || Int32.Parse(data[1]) < minBreath))
                    {
                        labelBorder(11, "Risky");

                        if (Int32.Parse(data[1]) > maxBreath)
                        {
                            label16.ForeColor = inRiskColor;
                            label17.ForeColor = normalColor;
                        }
                        else
                        {
                            label16.ForeColor = normalColor;
                            label17.ForeColor = inRiskColor;
                        }
                    }
                    else if (Int32.Parse(data[1]) >= minBreath && Int32.Parse(data[1]) <= maxBreath)
                    {
                        labelBorder(11, "Normal");
                        label16.ForeColor = normalColor;
                        label17.ForeColor = normalColor;
                    }

                    breathingRateCounter = breathingRateCounter + breathIntervalTime;
                }

                //Blood Pressure  Readings
                if (counter == bloodPressureCounter && bloodPressure != false)
                {
                    label12.Text = data[2] + "/" + data[3];
                    label18.Text = (maxSystolic).ToString();
                    label19.Text = (minSystolic).ToString();
                    label20.Text = (maxDiastolic).ToString();
                    label21.Text = (minDiastolic).ToString();

                    if (Int32.Parse(data[2]) == 0 || (Int32.Parse(data[3]) == 0))
                    {
                        labelBorder(12, "Critical");
                        label18.ForeColor = criticalColor;
                        label19.ForeColor = criticalColor;
                        label20.ForeColor = criticalColor;
                        label21.ForeColor = criticalColor;
                    }
                    else if ((Int32.Parse(data[2]) > maxSystolic || Int32.Parse(data[2]) < minSystolic) || (Int32.Parse(data[3]) > maxDiastolic || Int32.Parse(data[3]) < minDiastolic))
                    {
                        labelBorder(12, "Risky");

                        if (Int32.Parse(data[2]) > maxSystolic)
                        {
                            label18.ForeColor = inRiskColor;
                            label19.ForeColor = normalColor;
                        }
                        else if (Int32.Parse(data[2]) < minSystolic)
                        {
                            label18.ForeColor = normalColor;
                            label19.ForeColor = inRiskColor;
                        }

                        if (Int32.Parse(data[3]) > maxDiastolic)
                        {
                            label20.ForeColor = inRiskColor;
                            label21.ForeColor = normalColor;
                        }
                        else if (Int32.Parse(data[3]) < minDiastolic)
                        {
                            label20.ForeColor = normalColor;
                            label21.ForeColor = inRiskColor;
                        }
                    }
                    else if (Int32.Parse(data[2]) >= minSystolic && Int32.Parse(data[2]) <= maxSystolic && Int32.Parse(data[3]) >= minSystolic && Int32.Parse(data[3]) <= maxSystolic)
                    {
                        labelBorder(12, "Normal");
                        label18.ForeColor = normalColor;
                        label19.ForeColor = normalColor;
                        label20.ForeColor = normalColor;
                        label21.ForeColor = normalColor;
                    }

                    bloodPressureCounter = bloodPressureCounter + bloodPressureIntervalTime;
                }

                //Temperature Readings
                if (counter == temperatureCounter && temperature != false)
                {
                    label13.Text = data[4] + "°C";
                    label22.Text = (maxTemp).ToString();
                    label23.Text = (minTemp).ToString();

                    if (float.Parse(data[4]) == 0)
                    {
                        labelBorder(13, "Critical");
                        label22.ForeColor = criticalColor;
                        label23.ForeColor = criticalColor;
                    }
                    else if (float.Parse(data[4]) > maxTemp || float.Parse(data[4]) < minTemp)
                    {
                        labelBorder(13, "Risky");

                        if (float.Parse(data[4]) > maxTemp)
                        {
                            label22.ForeColor = inRiskColor;
                            label23.ForeColor = normalColor;
                        }
                        else
                        {
                            label22.ForeColor = normalColor;
                            label23.ForeColor = inRiskColor;
                        }
                    }
                    else if (float.Parse(data[4]) >= minTemp && float.Parse(data[4]) <= maxTemp)
                    {
                        labelBorder(13, "Normal");
                        label22.ForeColor = normalColor;
                        label23.ForeColor = normalColor;
                    }

                    temperatureCounter = temperatureCounter + temperatureIntervalTime;
                }

                if (getPatientId != "No record found")
                {
                    pRead.PatientId     = Int32.Parse(getPatientId);
                    pRead.PulseRate     = Int32.Parse(data[0]);
                    pRead.BreathingRate = Int32.Parse(data[1]);
                    pRead.Systolic      = Int32.Parse(data[2]);
                    pRead.Diastolic     = Int32.Parse(data[3]);
                    pRead.Temperature   = float.Parse(data[4]);
                    pRead.DateTime      = DateTime.Now.ToString();

                    pReadHnd.addPatientReading(dbConn.getConn(), pRead);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("DID NOT RECEIVE ANY DETECTION OF THE READING : " + ex);
                run_Monitor.Stop();
            }

            if (counter == 5)
            {
                counter              = 0;
                pulseRateCounter     = 0;
                bloodPressureCounter = 0;
                breathingRateCounter = 0;
                temperatureCounter   = 0;
            }
            else
            {
                counter++;
            }

            realCounter++;
        }