public void Given_Valid_Warning_Alert_Doctor_Subscription_When_AlertUsers_Invoked_Then_Valid_Result_Asserted()
        {
            Callbacks        callbacks = new Callbacks();
            AlertMonitorList subList   = AlertMonitorList.Instance;

            subList.Subscribe("Doctor100", callbacks.CallbackFunc);
            PatientAlert alerts = new PatientAlert
            {
                CriticalAlerts = new List <DeviceAlert>(),
                MuteAlert      = false,
                PatientId      = "Pat111",
                WarningAlerts  = new List <DeviceAlert>()
            };

            alerts.CriticalAlerts.Add(new DeviceAlert
            {
                DeviceId = "Dev111",
                Message  = "Warning",
                Value    = 86
            });
            alertManager.AlertUsers(alerts);
            Assert.AreEqual("TestPassed", alerts.PatientId);
            Assert.IsFalse(alerts.WarningAlerts.Any());
            subList.Unsubscribe("Doctor100");
        }
        public void Given_Valid_Critical_Alert_Campus_Subscription_When_AlertUsers_Invoked_Then_Valid_Result_Asserted()
        {
            Callbacks        callbacks = new Callbacks();
            string           bed       = "PIC";
            AlertMonitorList subList   = AlertMonitorList.Instance;

            subList.Subscribe(bed, callbacks.CallbackFunc);
            PatientAlert alerts = new PatientAlert
            {
                CriticalAlerts = new List <DeviceAlert>(),
                MuteAlert      = false,
                PatientId      = "Pat111",
                WarningAlerts  = new List <DeviceAlert>()
            };

            alerts.CriticalAlerts.Add(new DeviceAlert
            {
                DeviceId = "Dev111",
                Message  = "Critical",
                Value    = 56
            });
            alertManager.AlertUsers(alerts);
            Assert.AreEqual("TestPassed", alerts.PatientId);
            subList.Unsubscribe(bed);
        }
        public void Given_Invalid_Critical_Alert_Bed_Subscription_When_AlertUsers_Invoked_Then_Invalid_Result_Asserted()
        {
            Callbacks   callbacks = new Callbacks();
            HospitalBed bed       = new HospitalBed
            {
                BedNumber = 10, Campus = "PIC", Floor = "2", Occupancy = "Pat111", Wing = "2A", RoomNumber = "12"
            };
            AlertMonitorList subList = AlertMonitorList.Instance;

            subList.Subscribe(bed.ToString(), callbacks.CallbackFunc);
            PatientAlert alerts = new PatientAlert
            {
                CriticalAlerts = new List <DeviceAlert>(),
                MuteAlert      = false,
                PatientId      = "Pat111",
                WarningAlerts  = new List <DeviceAlert>()
            };

            alerts.CriticalAlerts.Add(new DeviceAlert
            {
                DeviceId = "Dev111",
                Message  = "Critical",
                Value    = 56
            });
            alertManager.AlertUsers(alerts);
            Assert.AreNotEqual("TestPassed", alerts.PatientId);
            subList.Unsubscribe(bed.ToString());
        }
예제 #4
0
        public void AlertDoctor(PatientAlert alert)
        {
            AlertManager manager       = new AlertManager(m_admissionRepo);
            var          warningAlerts = alert.WarningAlerts;

            alert.CriticalAlerts.AddRange(warningAlerts);
            alert.WarningAlerts = new List <DeviceAlert>();
            manager.AlertUsers(alert);
        }
        private bool ValidateLimits(Vitals vital, Limits limit, ref PatientAlert patientAlert)
        {
            if (CheckRange(limit.MinValue, limit.MaxValue, vital.Value))
            {
                ValidateLimitType(vital, limit, ref patientAlert);
                return(true);
            }

            return(false);
        }
 private void ValidateAllLimits(Vitals vital, Device device, ref PatientAlert patientAlert)
 {
     foreach (var limit in device.Limits)
     {
         if (ValidateLimits(vital, limit, ref patientAlert))
         {
             return;
         }
     }
 }
 private void TryValidate(PatientAdmission patient, Vitals vital, ref PatientAlert patientAlert)
 {
     foreach (var patientDevice in patient.Devices)
     {
         if (patientDevice.DeviceId == vital.DeviceId)
         {
             ValidateDeviceRange(vital, patientDevice, ref patientAlert);
         }
     }
 }
예제 #8
0
        private void AlertNurseStations(PatientAlert alert, string roomNo, AlertMonitorList subscribers)
        {
            string wingNo = roomNo.Substring(0, roomNo.LastIndexOf('-'));

            TryInvoke(alert, subscribers.TryGetValue(wingNo));
            string floorNo = wingNo.Substring(0, wingNo.LastIndexOf('-'));

            TryInvoke(alert, subscribers.TryGetValue(floorNo));
            string campus = floorNo.Substring(0, floorNo.LastIndexOf('-'));

            TryInvoke(alert, subscribers.TryGetValue(campus));
        }
예제 #9
0
 public void Process()
 {
     while (true)
     {
         if (!m_queue.IsEmpty())
         {
             var vitals = m_queue.Dequeue();
             m_vitalsManager.AlertUsers(vitals);
             PatientAlert alert = m_validator.ValidateVitalsRange(vitals);
             m_alertManager.AlertUsers(alert);
             m_vitalsRepository.WriteVitals(vitals);
         }
     }
 }
 private void ValidateDeviceRange(Vitals vital, Device device, ref PatientAlert patientAlert)
 {
     if (!CheckRange(device.MinInputValue, device.MaxInputValue, vital.Value))
     {
         patientAlert.CriticalAlerts.Add(new DeviceAlert
         {
             DeviceId = device.DeviceId,
             Value    = vital.Value,
             Message  = "Device Malfunction : Value out of valid input range."
         });
         return;
     }
     ValidateAllLimits(vital, device, ref patientAlert);
 }
        public void Given_Valid_Arguments_When_Subscribe_Invoked_Then_Valid_Result_Asserted()
        {
            Callbacks callbacks          = new Callbacks();
            AlertMonitoringFunction func = new AlertMonitoringFunction(callbacks.CallbackFunc);

            alertMonitorList.Subscribe("id", func);
            SharedResources.AlertMonitorList.AlertMonitorList list = SharedResources.AlertMonitorList.AlertMonitorList.Instance;
            AlertMonitoringFunction output;

            output = list.TryGetValue("id");
            PatientAlert alert = new PatientAlert();

            output?.Invoke(alert);
            Assert.AreEqual("TestPassed", alert.PatientId);
            alertMonitorList.Unsubscribe("id");
        }
        public void Given_Valid_Warning_Arguments_When_Validate_Vitals_Range_Invoked_Then_Valid_Result_Asserted()
        {
            PatientVitals vitals = new PatientVitals
            {
                PatientId = "Pat111",
                Vitals    = new List <Vitals>()
            };

            vitals.Vitals.Add(new Vitals
            {
                DeviceId = "Dev111",
                Value    = 76
            });
            PatientAlert alert = m_validator.ValidateVitalsRange(vitals);

            Assert.AreEqual(1, alert.WarningAlerts.Count);
        }
        public void Given_Invalid_Arguments_When_Validate_Vitals_Range_Invoked_Then_Invalid_Result_Asserted()
        {
            PatientVitals vitals = new PatientVitals
            {
                PatientId = "Pat111",
                Vitals    = new List <Vitals>()
            };

            vitals.Vitals.Add(new Vitals
            {
                DeviceId = "Dev112",
                Value    = 51
            });
            PatientAlert alert = m_validator.ValidateVitalsRange(vitals);

            Assert.IsFalse(alert.CriticalAlerts.Any());
        }
 public void ReceiveAlerts(PatientAlert alert)
 {
     Console.WriteLine(alert.PatientId);
     Console.WriteLine("*************");
     Console.WriteLine("Warning");
     foreach (var warningAlert in alert.WarningAlerts)
     {
         Console.WriteLine(warningAlert.DeviceId + " : " + warningAlert.Value + " : " + warningAlert.Message);
     }
     Console.WriteLine("*************");
     Console.WriteLine("Critical");
     foreach (var criticalAlert in alert.CriticalAlerts)
     {
         Console.WriteLine(criticalAlert.DeviceId + " : " + criticalAlert.Value + " : " + criticalAlert.Message);
     }
     Console.WriteLine("*************");
     Console.WriteLine("*************");
 }
        public PatientAlert ValidateVitalsRange(PatientVitals patientVitals)
        {
            PatientAlert patientAlert = new PatientAlert();

            patientAlert.PatientId      = patientVitals.PatientId;
            patientAlert.CriticalAlerts = new List <DeviceAlert>();
            patientAlert.WarningAlerts  = new List <DeviceAlert>();
            var patient = repository.Read(patientVitals.PatientId);

            if (!patient.MuteAlert)
            {
                foreach (Vitals vital in patientVitals.Vitals)
                {
                    TryValidate(patient, vital, ref patientAlert);
                }
            }

            return(patientAlert);
        }
예제 #16
0
        public void AlertUsers(PatientAlert alert)
        {
            AlertMonitorList subscribers = AlertMonitorList.Instance;
            PatientAdmission patient     = m_admissionRepository.Read(alert.PatientId);

            if (patient.PatientId != alert.PatientId)
            {
                return;
            }
            string bedNo  = patient.Bed.ToString();
            string roomNo = bedNo.Substring(0, bedNo.LastIndexOf('-'));

            TryInvoke(alert, subscribers.TryGetValue(roomNo));
            AlertNurseStations(alert, roomNo, subscribers);
            var func = subscribers.TryGetValue("Doctor" + patient.DoctorId);

            alert.WarningAlerts = new List <DeviceAlert>();
            TryInvoke(alert, func);
        }
예제 #17
0
        public ResultKeyValue ExecutePatientAlert(PatientAlert alert, int patientId)
        {
            ClsObject theQB = new ClsObject();

            ClsUtility.Init_Hashtable();
            ClsUtility.AddParameters("@QryString", SqlDbType.VarChar, alert.Query.QueryText);
            ClsUtility.AddExtendedParameters("@PatientId", SqlDbType.Int, patientId);

            DataSet ds = (DataSet)theQB.ReturnObject(ClsUtility.theParams, "pr_General_SQL_Parse", ClsUtility.ObjectEnum.DataSet);

            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                return(new ResultKeyValue()
                {
                    ResultName = ds.Tables[0].Rows[0][0].ToString(),
                    ResultValue = ds.Tables[0].Rows[0][1]
                });
            }
            return(null);
        }
 private static void ValidateLimitType(Vitals vital, Limits limit, ref PatientAlert patientAlert)
 {
     if (limit.Type == LimitType.Critical)
     {
         patientAlert.CriticalAlerts.Add(new DeviceAlert
         {
             DeviceId = vital.DeviceId,
             Message  = limit.Message,
             Value    = vital.Value
         });
     }
     else if (limit.Type == LimitType.Warning)
     {
         patientAlert.WarningAlerts.Add(new DeviceAlert
         {
             DeviceId = vital.DeviceId,
             Message  = limit.Message,
             Value    = vital.Value
         });
     }
 }
        public void Given_Invalid_Arguments_When_AlertUsers_Invoked_Then_Invalid_Result_Asserted()
        {
            Callbacks         callbacks = new Callbacks();
            VitalsMonitorList subList   = VitalsMonitorList.Instance;

            subList.Subscribe("Pat112", "Doc100", callbacks.VitalsCallback);
            PatientAlert alerts = new PatientAlert
            {
                CriticalAlerts = new List <DeviceAlert>(),
                MuteAlert      = false,
                PatientId      = "Pat111",
                WarningAlerts  = new List <DeviceAlert>()
            };

            alerts.WarningAlerts.Add(new DeviceAlert
            {
                DeviceId = "Dev111",
                Message  = "Warning",
                Value    = 86
            });
            alertManager.AlertUsers(alerts);
            Assert.AreNotEqual("TestPassed", alerts.PatientId);
            subList.Unsubscribe("Pat112", "Doc100");
        }
 public void AlertUsers(PatientAlert alert)
 {
     m_count++;
 }
예제 #21
0
 public void CallbackFunc1(PatientAlert alert)
 {
     alert.PatientId = "TestPassed1";
 }
 public void ReceiveAlerts(PatientAlert alert)
 {
     Console.WriteLine(alert.PatientId);
 }
예제 #23
0
 private static void TryInvoke(PatientAlert alert, AlertMonitoringFunction func)
 {
     func?.Invoke(alert);
 }