public void TestPulseHandler()
        {
            DBConnector dBc    = new DBConnector();
            string      result = dBc.connect();

            Assert.AreEqual("Done", result);
            PulseRateHandler prhd = new PulseRateHandler();

            PulseRate pr = new PulseRate();

            Assert.IsInstanceOfType(pr, typeof(object));
            DateTime currentDate = DateTime.Now;
            int      PatientId   = 1001;

            pr.PulseRateValue = 70.0;
            pr.PulseRateDate  = currentDate;
            pr.PulseRateTime  = currentDate;
            int resp1 = prhd.addNewPulseRate(dBc.getConn(), pr, PatientId);

            Assert.AreEqual(1, resp1);


            int resp2 = prhd.getLastIdPulseRate(dBc.getConn(), PatientId);

            Assert.IsNotNull(resp2);


            int    lastId = 101;
            double resp3  = prhd.getLastPulseRate(dBc.getConn(), PatientId, lastId);

            Assert.IsNotNull(resp3);
        }
        private async void readPulseRateData()
        {
            kayChart dataChart = new kayChart(pulseRateLineGraph, 60);

            dataChart.serieName = "Pulse Rate";
            string path = "../../../Patient-Monitoring-System/data files/pulseRateCSV.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();
                            PulseRate pulseRateData = new PulseRate();
                            pulseRateData.PulseRateValue = value;
                            pulseRateData.PulseRateDate  = currentDate;
                            pulseRateData.PulseRateTime  = currentTime;
                            PulseRateHandler pulseRateHandler = new PulseRateHandler();
                            ReadingHandler   readingHandler   = new ReadingHandler();
                            int result = pulseRateHandler.addNewPulseRate(dBConn.getConn(), pulseRateData, 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();
                                    }
                                }
                                pulseRateLineGraph.Series["Pulse Rate"].Color = Color.Red;
                                pulseRateCurrentValue.ForeColor = Color.Red;
                                BedsideHandler bedsideHandler = new BedsideHandler();
                                int            alarmResult    = bedsideHandler.updateAlarmZeroStatus(dBConn.getConn(), BedsideLoginScreen.bedsideIDPass, 1);

                                alarmZeroStatus = true;
                                AlarmHandler alarmHandler = new AlarmHandler();
                                int          specificId   = alarmHandler.getSpecificId(dBConn.getConn(), value, "pulserate");

                                if (specificId > 0)
                                {
                                    bool triggerStatus = alarmHandler.triggerAlarm(dBConn.getConn(), value, BedsideLoginScreen.bedside_patient_id, 0, specificId, "Pulse Rate");
                                    if (triggerStatus)
                                    {
                                        listPulseRate.Add(pulseRateData);
                                    }
                                }
                            }
                            else
                            if (value >= double.Parse(maxPulseRateLabel.Text) || (value <= double.Parse(minPulseRateLabel.Text)))
                            {
                                if (smsTrigger == 1)
                                {
                                    if (!backgroundWorkerSendSMS.IsBusy)
                                    {
                                        backgroundWorkerSendSMS.RunWorkerAsync();
                                    }
                                }
                                pulseRateLineGraph.Series["Pulse Rate"].Color = Color.Yellow;
                                pulseRateCurrentValue.ForeColor = Color.Yellow;
                                BedsideHandler bedsideHandler = new BedsideHandler();
                                int            alarmResult    = bedsideHandler.updateAlarmStatus(dBConn.getConn(), BedsideLoginScreen.bedsideIDPass, 1);


                                alarmReadingStatus = true;
                                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, "Pulse Rate");

                                    if (triggerStatus)
                                    {
                                        listPulseRate.Add(pulseRateData);
                                    }
                                }
                            }
                            else
                            {
                                pulseRateLineGraph.Series["Pulse Rate"].Color = Color.Green;
                                pulseRateCurrentValue.ForeColor = Color.Green;
                            }

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

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