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); }
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()); } }