//insert new breathing rate items to the patient
        public int addNewBreathingRate(MySqlConnection conn, BreathingRate breathingRate, int patientId)
        {
            string       sql     = "INSERT into breathingrate( patient_id, breathingRateValue, breathingRateTime, breathingRateDate)" + "VALUES('" + patientId + "', '" + breathingRate.BreathingRateValue + "', '" + breathingRate.BreathingRateTime.ToString("HH:mm:ss") + "', '" + breathingRate.BreathingRateDate.ToString("yyyy-MM-dd") + "')";
            MySqlCommand sqlComm = new MySqlCommand(sql, conn);

            return(sqlComm.ExecuteNonQuery());
        }
Пример #2
0
        public void TestBreathingRateHandler()
        {
            //connect database
            DBConnector dBc    = new DBConnector();
            string      result = dBc.connect();

            Assert.AreEqual("Done", result);
            BreathingRateHandler brhd        = new BreathingRateHandler();
            DateTime             currentDate = DateTime.Now;
            BreathingRate        br          = new BreathingRate();

            Assert.IsInstanceOfType(br, typeof(object));

            int patientId = 1001;

            br.BreathingRateValue = 14;
            br.BreathingRateTime  = currentDate;
            br.BreathingRateDate  = currentDate;
            int resp1 = brhd.addNewBreathingRate(dBc.getConn(), br, patientId);

            Assert.AreEqual(1, resp1);

            int resp2 = brhd.getLastIdBreathingRate(dBc.getConn(), patientId);

            Assert.IsNotNull(resp2);

            int    lastId = 8;
            double resp3  = brhd.getLastBreathingRate(dBc.getConn(), patientId, lastId);

            Assert.IsNotNull(resp3);
        }
        void CreateBreathingRateValues()
        {
            icon.BreathingRate = new BreathingRate();

            var list = BreathingRate.GetActivityLevelList();

            BreathingRateList = new ObservableCollection <string>();
            foreach (var elem in list)
            {
                BreathingRateList.Add(elem);
            }

            BreathingRateSelected = icon.BreathingRate.BreathingRateActivityLevel;
        }
        private async void readBreathingRateData()
        {
            kayChart dataChart = new kayChart(breathingRateLineGraph, 60);

            dataChart.serieName = "Breathing Rate";
            string path = "../../../Patient-Monitoring-System/data files/breathingRateCSV.csv";
            string line;

            try
            {
                StreamReader sr = new StreamReader(path);
                line = sr.ReadLine();
                while (line != null)
                {
                    string[] columns = line.Split(',');
                    foreach (string column in columns)
                    {
                        if (run)
                        {
                            double value = double.Parse(column);
                            //add each value to database *DONT Delete*
                            DateTime    currentDate = DateTime.Now;
                            DateTime    currentTime = DateTime.Now;
                            DBConnector dBConn      = new DBConnector();
                            dBConn.connect();
                            BreathingRate newBreathingRate = new BreathingRate();
                            newBreathingRate.BreathingRateValue = value;
                            newBreathingRate.BreathingRateDate  = currentDate;
                            newBreathingRate.BreathingRateTime  = currentTime;
                            BreathingRateHandler breathingRateHandler = new BreathingRateHandler();
                            ReadingHandler       readingHandler       = new ReadingHandler();
                            int result = breathingRateHandler.addNewBreathingRate(dBConn.getConn(), newBreathingRate, BedsideLoginScreen.bedside_patient_id);

                            if (result != 1)
                            {
                                MessageBox.Show("Insert Data failed");
                            }
                            await Task.Delay(1500);

                            await Task.Factory.StartNew(() =>
                            {
                                dataChart.TriggeredUpdate(value);
                            });



                            if (value == 0)
                            {
                                if (smsTrigger == 1)
                                {
                                    if (!backgroundWorkerSendSMS.IsBusy)
                                    {
                                        backgroundWorkerSendSMS.RunWorkerAsync();
                                    }
                                }

                                breathingRateLineGraph.Series["Breathing Rate"].Color = Color.Red;
                                breathingRateCurrentValue.ForeColor = Color.Red;

                                alarmZeroStatus = true;
                                BedsideHandler bedsideHandler = new BedsideHandler();
                                int            alarmResult    = bedsideHandler.updateAlarmZeroStatus(dBConn.getConn(), BedsideLoginScreen.bedsideIDPass, 1);

                                if (alarmResult == 1)
                                {
                                    AlarmHandler alarmHandler = new AlarmHandler();
                                    int          specificId   = alarmHandler.getSpecificId(dBConn.getConn(), value, "breathingrate");

                                    if (specificId > 0)
                                    {
                                        bool triggerStatus = alarmHandler.triggerAlarm(dBConn.getConn(), value, BedsideLoginScreen.bedside_patient_id, 0, specificId, "Breathing Rate");
                                        if (triggerStatus)
                                        {
                                            listbreathingRate.Add(newBreathingRate);
                                        }
                                    }
                                }
                            }
                            else
                            if (value >= double.Parse(maxBreathingRateLabel.Text) || value <= double.Parse(minBreathingRateLabel.Text))
                            {
                                if (smsTrigger == 1)
                                {
                                    if (!backgroundWorkerSendSMS.IsBusy)
                                    {
                                        backgroundWorkerSendSMS.RunWorkerAsync();
                                    }
                                }
                                breathingRateLineGraph.Series["Breathing Rate"].Color = Color.Yellow;
                                breathingRateCurrentValue.ForeColor = Color.Yellow;

                                alarmReadingStatus = true;
                                BedsideHandler bedsideHandler = new BedsideHandler();
                                int            alarmResult    = bedsideHandler.updateAlarmStatus(dBConn.getConn(), BedsideLoginScreen.bedsideIDPass, 1);

                                if (alarmResult == 1)
                                {
                                    int id = readingHandler.getIdAlarmTrigger(dBConn.getConn(), value);

                                    if (id > 0)
                                    {
                                        AlarmHandler alarmHandler  = new AlarmHandler();
                                        bool         triggerStatus = alarmHandler.triggerAlarm(dBConn.getConn(), value, BedsideLoginScreen.bedside_patient_id, id, 0, "Breathing Rate");

                                        if (triggerStatus)
                                        {
                                            listbreathingRate.Add(newBreathingRate);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                breathingRateLineGraph.Series["Breathing Rate"].Color = Color.Green;
                                breathingRateCurrentValue.ForeColor = Color.Green;
                            }

                            breathingRateCurrentValue.Text = value.ToString() + "/min";
                        }
                        else
                        {
                            break;
                        }
                    }

                    line = sr.ReadLine();
                }
            }
            catch (FileNotFoundException e)
            {
                MessageBox.Show(e.ToString());
                Console.WriteLine(e.ToString());
            }
        }