示例#1
0
        public static void static_sendSMS(string ID, string phoneNumber, AlgoUtils.Status type)
        {
            SMSMessage message = new SMSMessage();

            message.number = phoneNumber;
            message.status = type;


            if (ConnectionDictionary.mapUidToConnection.ContainsKey(ID))
            {
                Trace.TraceInformation(String.Format("Sending SMS {0} message to user: {1}. ConnectionId {2}",
                                                     type.ToString(), phoneNumber, ConnectionDictionary.mapUidToConnection[ID]));
                try
                {
                    hubContext.Clients.Client(ConnectionDictionary.mapUidToConnection[ID]).receiveSMS(message);
                }
                catch (Exception e)
                {
                    Trace.TraceError(e.Message);
                }
            }
            else
            {
                Trace.TraceError(String.Format("User {0} doesn't exist", ID));
            }
        }
示例#2
0
        /// **notice: T1>T2>T3**

        public void wanderingDetectionAlgo(string currentPatientID)
        {
            preprocessAlgoData(currentPatientID);                                             //update latest sample for our patient & his caregiversArr
            AlgoUtils.Status patientStatus = monitorAndAlert(currentPatientID, latestSample); //main business logic
            switch (patientStatus)
            {
            case AlgoUtils.Status.Safety:
            {
                //TODO:SAFETY stuff
                break;
            }

            case AlgoUtils.Status.Wandering:
            {
                //TODO:WANDERING stuff
                /// Step C - POSSIBLE_WANDERING_MODE
                /// 1. send PUSH to caregiver - "Do you know your beloved John is currently at (sample.location)?
                ///                              It's a strange time for him to be there"
                ///     1.1 if caregiver knows then
                ///         1.1.1 add sample.time to sample.location (if it's not happening automatically)
                ///         1.1.2 enter MONITORING_MODE
                ///     1.2 else if caregiver marks patient as wandering then enter POSSIBLE_RISK_MODE
                break;
            }

            case AlgoUtils.Status.Distress:
            {
                //TODO:DISTRESS stuff
                /// Step D - POSSIBLE_DISTRESS_MODE
                /// 1. send PUSH to caregiver - "Your beloved John is currently at (sample.location)?
                ///                              His heartrate is a bit abnormal - please contact him"
                /// 2. after 2 minutes send PUSH to caregiver - "Is your beloved John okay?"
                ///     1.1 if caregiver says he's okay, enter MONITORING_MODE
                ///     1.2 else enter POSSIBLE_RISK_MODE
                break;
            }

            case AlgoUtils.Status.Risk:
            {
                //TODO:RISK stuff
                /// Step E - POSSIBLE_RISK_MODE
                /// 1. Speed up sample rate (?) - every 1-3 minutes
                /// 2. Notify all patient's caregivers
                /// 3. Speak to patient (?)
                /// 4. Open patient's microphone and transmit to caregivers
                /// 5. Make alarm sounds - "I need help" - so passbyers can quickly assist (?)
                /// 6. When caregiver hits "I'm safe" button - enter MONITORING_MODE (can also mark I'm safe remotely?)
                break;
            }
            }
        }
示例#3
0
        public static void static_send(string patientID, string patientName, IEnumerable <Caregiver> caregiversArr,
                                       AlgoUtils.Status status)
        {
            Trace.TraceInformation(String.Format("Sending Patient {0} status: {1} to all caregivers", patientID,
                                                 status.ToString()));
            ConnectionDictionary.mapUidToStatus[patientID] = status; //update patient status

            SampleController sampleController = new SampleController();
            Sample           latestSample     = sampleController.GetLatestSampleForPatient(patientID);

            Message message = new Message()
            {
                ID = patientID, status = status, name = patientName, lat = latestSample.Latitude, lon = latestSample.Longitude
            };

            foreach (var caregiver in caregiversArr)
            {
                try
                {
                    ConnectionDictionary.mapUidToStatus[caregiver.Id] = status;
                    hubContext.Clients.Client(ConnectionDictionary.mapUidToConnection[caregiver.Id]).receiveNotification(message);
                    Trace.TraceInformation(String.Format("Sent message to caregiver {0}", caregiver.Id));
                }
                catch (Exception e)
                {
                    Trace.TraceError(e.Message);
                }
            }
            //Trace.TraceInformation(String.Format("Sending message to patient for testing"));
            //try
            //{
            //    hubContext.Clients.Client(ConnectionDictionary.mapUidToConnection[patientID]).receiveNotification(message);
            //    Trace.TraceInformation(String.Format("Sent message back to patient {0}", patientName));
            //}
            //catch (Exception e)
            //{
            //    Trace.TraceError(e.Message);
            //}
        }
示例#4
0
        /// **notice: T1>T2>T3**



        ///////////////TO BE CALLED FROM SERVER//////////////
        public void wanderingDetectionAlgo(string currentPatientID)
        {
            Trace.AutoFlush = true;
            patientID       = currentPatientID;
            if (AlgoUtils.learningStage(currentPatientID)) //if less than 200 samples
            {
                //case Learning
                Trace.TraceInformation(String.Format("Patient status is {0}", AlgoUtils.Status.Learning.ToString()));

                PatientController   patientController   = new PatientController();
                CaregiverController caregiverController = new CaregiverController();
                caregiversArr = caregiverController.GetCaregiversforPatientID(currentPatientID);
                patientName   = patientController.GetPatientName(currentPatientID);

                NotificationHub.static_send(patientID, patientName, caregiversArr, AlgoUtils.Status.Learning);
                return;
            }

            preprocessAlgoData(currentPatientID); //update latest sample for our patient & his caregiversArr
            Trace.TraceInformation(String.Format("Preprocess stage is finished"));

            AlgoUtils.Status patientStatus = monitorAndAlert(currentPatientID); //main business logic
            Trace.TraceInformation(String.Format("Monitor and alert stage is done"));
            Trace.TraceInformation(String.Format("Patient status is {0}", patientStatus));


            //Call2Action
            switch (patientStatus)
            {
            case AlgoUtils.Status.Safety:
            {
                NotificationHub.static_send(patientID, patientName, caregiversArr, patientStatus);
                //AlgoUtils.sendSMS(caregiversArr, patientStatus);

                //TODO:SAFETY stuff
                break;
            }

            case AlgoUtils.Status.Wandering:
            {
                NotificationHub.static_send(patientID, patientName, caregiversArr, patientStatus);
                //AlgoUtils.sendSMS(caregiversArr, patientStatus);

                //TODO:WANDERING stuff
                /// Step C - POSSIBLE_WANDERING_MODE
                /// 1. send PUSH to caregiver - "Do you know your beloved John is currently at (sample.location)?
                ///                              It's a strange time for him to be there"
                ///     1.1 if caregiver knows then
                ///         1.1.1 add sample.time to sample.location (if it's not happening automatically)
                ///         1.1.2 enter MONITORING_MODE
                ///     1.2 else if caregiver marks patient as wandering then enter POSSIBLE_RISK_MODE
                break;
            }

            case AlgoUtils.Status.Distress:
            {
                NotificationHub.static_send(patientID, patientName, caregiversArr, patientStatus);
                //AlgoUtils.sendSMS(caregiversArr, patientStatus);


                //TODO:DISTRESS stuff
                /// Step D - POSSIBLE_DISTRESS_MODE
                /// 1. send PUSH to caregiver - "Your beloved John is currently at (sample.location)?
                ///                              His heartrate is a bit abnormal - please contact him"
                /// 2. after 2 minutes send PUSH to caregiver - "Is your beloved John okay?"
                ///     1.1 if caregiver says he's okay, enter MONITORING_MODE
                ///     1.2 else enter POSSIBLE_RISK_MODE
                break;
            }

            case AlgoUtils.Status.Risk:
            {
                NotificationHub.static_send(patientID, patientName, caregiversArr, patientStatus);
                //AlgoUtils.sendSMS(caregiversArr, patientStatus);

                //TODO:RISK stuff
                /// Step E - POSSIBLE_RISK_MODE
                /// 1. Speed up sample rate (?) - every 1-3 minutes
                /// 2. Notify all patient's caregivers
                /// 3. Speak to patient (?)
                /// 4. Open patient's microphone and transmit to caregivers
                /// 5. Make alarm sounds - "I need help" - so passbyers can quickly assist (?)
                /// 6. When caregiver hits "I'm safe" button - enter MONITORING_MODE (can also mark I'm safe remotely?)
                break;
            }

            case AlgoUtils.Status.ConnectionLost:
            {
                NotificationHub.static_send(patientID, patientName, caregiversArr, patientStatus);

                //TODO: connectionLost stuff
                break;
            }
            }
        }