Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
0
        public static Boolean learningStage(string patientID)
        {
            int numOfSamples = SampleController.GetSampleCountforPatientID(patientID);

            if (numOfSamples < 200)
            {
                return(true); //in learning stage
            }
            return(false);    //not in learning stage
        }