示例#1
0
        private void myProcessedMethod(string message)
        {
            var values = message.Split(';');

            ServiceRefHealth.ServiceHealthClient web = new ServiceHealthClient();
            BPs     b = new ServiceRefHealth.BPs();
            SPOes   s = new ServiceRefHealth.SPOes();
            HRs     h = new ServiceRefHealth.HRs();
            Alertas a = new ServiceRefHealth.Alertas();

            //comunicar entre threads
            this.BeginInvoke(new MethodInvoker(delegate
            {
                if (values[0].Equals("BP"))
                {
                    var valuesBP = values[1].Split('-');
                    label3.Text  = values[1];

                    b.Value1    = Convert.ToInt32(valuesBP[0]);
                    b.Value2    = Convert.ToInt32(valuesBP[1]);
                    b.Date      = Convert.ToDateTime(values[2]);
                    b.SNS       = Properties.Settings.Default.snsH;
                    label6.Text = values[2];


                    //alertas para hiper e hipotensão
                    if (b.Value1 > 180 || b.Value1 < 100 || b.Value2 < 60)
                    {
                        b.Alert          = true;
                        label3.ForeColor = System.Drawing.Color.Red;
                        sSynth.Speak("Blood Pressure Alert!");

                        // fora da gama normal e dos limites criticos
                        if (b.Value2 >= 30 && b.Value2 < 60 || b.Value1 > 180)
                        {
                            if (stopwatchBW.IsRunning)
                            {
                                if (stopwatchBW.ElapsedMilliseconds > 600000)
                                {
                                    a.Date  = Convert.ToDateTime(values[2]);
                                    a.SNS   = Properties.Settings.Default.snsH;
                                    a.Bp    = b;
                                    a.Alert = "BP";
                                    a.Tipo  = "WarningContinuous";
                                    web.AddAlerts(a);
                                    stopwatchBW.Restart();
                                }
                            }
                            else
                            {
                                stopwatchBW.Start();
                            }

                            if (stopwatchBC.IsRunning)
                            {
                                if (stopwatchBC.ElapsedMilliseconds > 3600000)
                                {
                                    a.Date  = Convert.ToDateTime(values[2]);
                                    a.SNS   = Properties.Settings.Default.snsH;
                                    a.Bp    = b;
                                    a.Alert = "BP";
                                    a.Tipo  = "CriticalContinous";
                                    web.AddAlerts(a);
                                    stopwatchBC.Restart();
                                }
                            }
                            else
                            {
                                stopwatchBC.Start();
                            }

                            if (stopwatchBW2.IsRunning)
                            {
                                if (stopwatchBW2.ElapsedMilliseconds > 1800000 && NB >= 600000)
                                {
                                    a.Date  = Convert.ToDateTime(values[2]);
                                    a.SNS   = Properties.Settings.Default.snsH;
                                    a.Bp    = b;
                                    a.Alert = "BP";
                                    a.Tipo  = "WarningIntermitente";
                                    web.AddAlerts(a);
                                    stopwatchBW2.Restart();
                                    NB = 0;
                                }
                                if (stopwatchBW2.ElapsedMilliseconds > 1800000 && NB < 600000)
                                {
                                    NB = 0;
                                    stopwatchBW2.Restart();
                                }
                                else
                                {
                                    NB += MyHealth.Properties.Settings.Default.ndelay * 3;
                                }
                            }
                            else
                            {
                                stopwatchBW2.Start();
                                NB += MyHealth.Properties.Settings.Default.ndelay * 3;
                            }
                        }
                    }
                    else
                    {
                        b.Alert          = false;
                        label3.ForeColor = System.Drawing.Color.Green;
                    }
                    web.AddValuesBP(b);
                }

                if (values[0].Equals("SPO2"))
                {
                    label4.Text = values[1];

                    s.Value     = Convert.ToInt32(values[1]);
                    s.Date      = Convert.ToDateTime(values[2]);// + "-" + values[3] + "-" + values[4]);
                    s.SNS       = Properties.Settings.Default.snsH;
                    label7.Text = values[2];
                    if (s.Value < 90)
                    {
                        s.Alert          = true;
                        label4.ForeColor = System.Drawing.Color.Red;
                        sSynth.Speak("Oxygen Saturation Alert!");

                        if (s.Value > 80 && s.Value < 90)
                        {
                            if (stopwatchSW.IsRunning)
                            {
                                if (stopwatchSW.ElapsedMilliseconds > 600000)
                                {
                                    a.Date  = Convert.ToDateTime(values[2]);
                                    a.SNS   = Properties.Settings.Default.snsH;
                                    a.Spoe  = s;
                                    a.Alert = "SPO";
                                    a.Tipo  = "WarningContinuous";
                                    web.AddAlerts(a);
                                    stopwatchSW.Restart();
                                }
                            }
                            else
                            {
                                stopwatchSW.Start();
                            }

                            if (stopwatchSC.IsRunning)
                            {
                                if (stopwatchSC.ElapsedMilliseconds > 3600000)
                                {
                                    a.Date  = Convert.ToDateTime(values[2]);
                                    a.SNS   = Properties.Settings.Default.snsH;
                                    a.Spoe  = s;
                                    a.Alert = "SPO";
                                    a.Tipo  = "CriticalContinous";
                                    web.AddAlerts(a);
                                    stopwatchSC.Restart();
                                }
                            }
                            else
                            {
                                stopwatchSC.Start();
                            }

                            if (stopwatchSW2.IsRunning)
                            {
                                if (stopwatchSW2.ElapsedMilliseconds > 1800000 && NS >= 600000)
                                {
                                    a.Date  = Convert.ToDateTime(values[2]);
                                    a.SNS   = Properties.Settings.Default.snsH;
                                    a.Spoe  = s;
                                    a.Alert = "SPO";
                                    a.Tipo  = "WarningIntermitente";
                                    web.AddAlerts(a);
                                    stopwatchSW2.Restart();
                                    NS = 0;
                                }
                                if (stopwatchSW2.ElapsedMilliseconds > 1800000 && NS < 600000)
                                {
                                    NS = 0;
                                    stopwatchSW2.Restart();
                                }
                                else
                                {
                                    NS += MyHealth.Properties.Settings.Default.ndelay * 3;
                                }
                            }
                            else
                            {
                                stopwatchSW2.Start();
                                NS += MyHealth.Properties.Settings.Default.ndelay * 3;
                            }
                        }
                    }

                    else
                    {
                        s.Alert          = false;
                        label4.ForeColor = System.Drawing.Color.Green;
                    }
                    web.AddValuesSPO(s);
                }



                if (values[0].Equals("HR"))
                {
                    label5.Text = values[1];

                    h.Value     = Convert.ToInt32(values[1]);
                    h.Date      = Convert.ToDateTime(values[2]);// + "-" + values[3] + "-" + values[4]);
                    h.SNS       = Properties.Settings.Default.snsH;
                    label8.Text = values[2];
                    if (h.Value < 60 || h.Value > 120)
                    {
                        h.Alert          = true;
                        label5.ForeColor = System.Drawing.Color.Red;
                        sSynth.Speak("Heart Rate Alert!");

                        if (h.Value < 60 && h.Value >= 30 || h.Value > 120 && h.Value <= 180)
                        {
                            if (stopwatchHW.IsRunning)
                            {
                                if (stopwatchHW.ElapsedMilliseconds > 600000)
                                {
                                    a.Date  = Convert.ToDateTime(values[2]);
                                    a.SNS   = Properties.Settings.Default.snsH;
                                    a.Hr    = h;
                                    a.Alert = "HR";
                                    a.Tipo  = "WarningContinuous";
                                    web.AddAlerts(a);
                                    stopwatchHW.Restart();
                                }
                            }
                            else
                            {
                                stopwatchHW.Start();
                            }

                            if (stopwatchHC.IsRunning)
                            {
                                if (stopwatchHC.ElapsedMilliseconds > 3600000)
                                {
                                    a.Date  = Convert.ToDateTime(values[2]);
                                    a.SNS   = Properties.Settings.Default.snsH;
                                    a.Hr    = h;
                                    a.Alert = "HR";
                                    a.Tipo  = "CriticalContinous";
                                    web.AddAlerts(a);
                                    stopwatchHC.Restart();
                                }
                            }
                            else
                            {
                                stopwatchHC.Start();
                            }

                            if (stopwatchHW2.IsRunning)
                            {
                                if (stopwatchHW2.ElapsedMilliseconds > 1800000 && NH >= 600000)
                                {
                                    a.Date  = Convert.ToDateTime(values[2]);
                                    a.SNS   = Properties.Settings.Default.snsH;
                                    a.Hr    = h;
                                    a.Alert = "HR";
                                    a.Tipo  = "WarningIntermitente";
                                    web.AddAlerts(a);
                                    stopwatchSW2.Restart();
                                    NH = 0;
                                }
                                if (stopwatchHW2.ElapsedMilliseconds > 1800000 && NH < 600000)
                                {
                                    NH = 0;
                                    stopwatchHW2.Restart();
                                }
                                else
                                {
                                    NH += MyHealth.Properties.Settings.Default.ndelay * 3;
                                }
                            }
                            else
                            {
                                stopwatchHW2.Start();
                                NH += MyHealth.Properties.Settings.Default.ndelay * 3;
                            }
                        }
                    }
                    else
                    {
                        h.Alert          = false;
                        label5.ForeColor = System.Drawing.Color.Green;
                    }
                    web.AddValuesHR(h);
                }
            }

                                               ));
        }