Exemple #1
0
        public void startWanderingDetection(string ID)
        {
            Trace.TraceInformation("Starting Detection Algo for Patient {0}", ID);
            WanderingAlgo algo = new WanderingAlgo();

            algo.wanderingDetectionAlgo(ID);
        }
Exemple #2
0
        public void RegisterCaregiver(string ID)
        {
            Trace.TraceInformation(String.Format("Attempting to register cargiver: {0}", ID));
            try
            {
                Trace.AutoFlush = true;
                string deadConnectionId;
                string ConnID = Context.ConnectionId;
                ConnectionDictionary.mapUidToConnection.TryRemove(ID, out deadConnectionId);
                ConnectionDictionary.mapUidToConnection[ID] = ConnID;
                Trace.TraceInformation(String.Format("Added caregiver: {0} connectionId {1}", ID,
                                                     ConnectionDictionary.mapUidToConnection[ID]));


                Caregiver currCaregiver = CaregiverController.GetCaregiverObject(ID);
                Patient   currPatient   = PatientController.GetPatientObjectbyGroupID(currCaregiver.GroupID);
                //send patient ID to caregiver

                SampleController sampleController = new SampleController();

                if (SampleController.GetSampleCountforPatientID(currPatient.Id) == 0)
                {
                    Trace.TraceInformation("No samples found for patient");
                    Message message = new Message()
                    {
                        ID     = currPatient.Id,
                        status = AlgoUtils.Status.Learning,
                        name   = "",
                        lat    = 32.0808800F,
                        lon    = 34.7805700F
                    };
                    Clients.Client(ConnectionDictionary.mapUidToConnection[ID]).receiveNotification(message);
                    WanderingAlgo algo = new WanderingAlgo();
                    Trace.TraceInformation("Starting Detection Algo for Patient {0} due to caregiver registration",
                                           currPatient.Id);
                    algo.wanderingDetectionAlgo(currPatient.Id);
                }
                else
                {
                    Sample latestSample = sampleController.GetLatestSampleForPatient(currPatient.Id);

                    Trace.TraceInformation("Sending message back to caregiver with patient ID");
                    Message message = new Message()
                    {
                        ID = currPatient.Id, status = AlgoUtils.Status.Safety, name = "", lat = latestSample.Latitude, lon = latestSample.Longitude
                    };
                    Clients.Client(ConnectionDictionary.mapUidToConnection[ID]).receiveNotification(message);
                    WanderingAlgo algo = new WanderingAlgo();
                    Trace.TraceInformation("Starting Detection Algo for Patient {0} due to caregiver registration", currPatient.Id);
                    algo.wanderingDetectionAlgo(currPatient.Id);
                }
            }
            catch (Exception e)
            {
                Trace.TraceError("Registration of " + ID + " failed or Exception in wandering Algo: " + e.Message);
            }
        }