/// <summary>
        /// The constractor of this window
        /// </summary>
        /// <param name="_currentPatient">The current patient of the session</param>
        public TreatmentMenu(Patient _currentPatient)
        {
            InitializeComponent();

            this._currentPatient = _currentPatient;
            this.Loaded += TreatmentMenu_Loaded;
        }
 public void OpenDistanceChecker(Patient _currentPatient, Training _currentTraining)
 {
     using (DistanceWindow distanceWindow = new DistanceWindow(_currentPatient, _currentTraining, null))
     {
         distanceWindow.mainWindow = this;
         this.Content = distanceWindow;
     }
 }
 public void OpenExerciseWindow(Patient _currentPatient, Training _currentTraining)
 {
     using (ExerciseView _exerciseView = new ExerciseView(_currentPatient, _currentTraining))
     {
         _exerciseView.MainWindow = this;
         _exerciseView.GoBackToTreatmentScreen += OpenTreatmentWindow;
         this.Content = _exerciseView;
     }
 }
        public UC_TrainingSelection(Patient currentPatient, Training currentTraining)
        {
            InitializeComponent();

            _currentPatient = currentPatient;
            _currentTraining = currentTraining;

            DataContext = _currentTraining;
        }
        public DistanceWindow(Patient currentPatient, Training currentTraining, VideoTherapy.TrainingMenu trainingMenu)
        {
            InitializeComponent();

            this.currentPatient = currentPatient;
            this.currentTraining = currentTraining;
            this.trainingMenu = trainingMenu;

            //SetKinectConnection();

            this.Loaded += DistanceWindow_Loaded;
        }
Example #6
0
        ////to show or not the recommended panel
        //public Boolean ShowRecommended
        //{
        //    set
        //    {
        //        if (value)
        //        {
        //            //this.ShowRecommendedBorder.Visibility = Visibility.Visible;
        //            this.ShowKinectStatus.Visibility = Visibility.Hidden;
        //            this.UserInfoStack.Children.Remove(ShowKinectStatus);
        //        }
        //        else
        //        {
        //            //this.ShowRecommendedBorder.Visibility = Visibility.Hidden;
        //            this.ShowKinectStatus.Visibility = Visibility.Visible;
        //            //this.UserInfoStack.Children.Remove(ShowRecommendedBorder);
        //            KinectConnectionStatus();
        //        }
        //    }
        //}
        public UC_UserInfo(Patient _currentPatient)
        {
            InitializeComponent();

            this._currentPatient = _currentPatient;
            this.DataContext = this._currentPatient;

            ShowCurrentTime();
            KinectConnectionStatus();

            LinktToProfile.RequestNavigate += LinktToProfile_RequestNavigate;
        }
        public TrainingMenu(Patient currentPatient, Training currentTraining)
        {
            InitializeComponent();

            _currentPatient = currentPatient;
            _currentTraining = currentTraining;

            this.Loaded += TrainingMenu_Loaded;

            splash = new VT_Splash();
            //splash.ErrorEvent+=

            worker = new BackgroundWorker();
            worker.DoWork += Worker_DoWork;
            worker.RunWorkerCompleted += Worker_RunWorkerCompleted;
        }
Example #8
0
        /// <summary>
        /// Parse from json content to current patient treatment
        /// </summary>
        /// <param name="_JSONcontent">The response json</param>
        /// <param name="_patient">The _patient object</param>
        public static void GettingPatientTreatment(Patient _patient, string _JSONcontent)
        {
            //todo - run over the treatments
            dynamic d =
                    (JsonConvert.DeserializeObject<IDictionary<string, object>>(_JSONcontent));

            bool checkError = checkForErrors((int)d["code"]);
            if (checkError)
            {
                ErrorEvent(null, new ErrorMessege(((ServerCode)d["code"]).ToString(), (int)d["code"]));
                return;
            }

            dynamic list = (JsonConvert.DeserializeObject<IDictionary<string, object>>(_JSONcontent))["data"];

            List<Treatment> treatments = new List<Treatment>();

            foreach (var item in list)
            {
                Treatment treatment = new Treatment();

                //treatment details
                treatment.TreatmentNumber = list.IndexOf(item) + 1;
                treatment.TreatmentId = item.treatmentId;
                treatment.StartDate = DateTime.Parse((string)item.treatmentStartTime["date"]);
                treatment.EndDate = DateTime.Parse((string)item.treatmentEndTime["date"]);
                treatment.TreatmentProgress = DateFormat.CalcTreatementDateProgress(treatment.StartDate, treatment.EndDate);

                //treatment scoring
                try
                {
                    Dictionary<string, float> scoringDic = JsonConvert.DeserializeObject<Dictionary<string, float>>(item.scoring.ToString());
                    treatment.TreatmentCompliance = (int)(scoringDic["num_repition_done"] / scoringDic["num_repition_total"] * 100);
                    treatment.TreatmentScore = (int)(scoringDic["motion_quality"] * 100);
                }
                catch
                {
                    treatment.TreatmentCompliance = 0;
                    treatment.TreatmentScore = 0;
                }

                //therapist details
                treatment.TreatmentTherapist = new Therapist();
                treatment.TreatmentTherapist.AccountId = item.therapistId;
                treatment.TreatmentTherapist.FirstName = item.therapistFirst;
                treatment.TreatmentTherapist.LastName = item.therapistLast;
                treatment.TreatmentTherapist.ImageThumb = item.therapistThumbnail;
                //todo - change when will be a the date of start connection between therapist and patient
                treatment.TreatmentTherapist.StartDate = treatment.StartDate;

                //trainings:
                treatment.TrainingList = CreateTrainingList(item["trainings"].ToString());

                //set recomended training to treatment
                //todo
                foreach (var training in treatment.TrainingList)
                {
                    if (training.IsRecommended)
                    {
                        treatment.RecommendedTraining = training;
                        break;
                    }
                }

                treatments.Add(treatment);
            }

            //Now there is only one treatment:
            _patient.PatientTreatment = treatments.First();
        }
Example #9
0
        /// <summary>
        /// Login by email and password
        /// </summary>
        /// <param name="emil">User email</param>
        /// <param name="password">User password</param>
        private async Task<int> LoginUserForId(string email, string password)
        {
            bool regexCheck = Regex.IsMatch(email,
                @"^(?("")("".+?(?<!\\)""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))" +
                @"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-\w]*[0-9a-z]*\.)+[a-z0-9][\-a-z0-9]{0,22}[a-z0-9]))$",
                RegexOptions.IgnoreCase, TimeSpan.FromMilliseconds(250));

            if (regexCheck)
            {
                wrongInputLbl.Visibility = Visibility.Hidden;

                //email = Uri.EscapeDataString(email);
                try
                {
                    string loginData = await ApiConnection.AppLoginApiAsync(email, password);

                    _currentPatient = JSONConvertor.CreatePatient(loginData);

                    return _currentPatient != null ? 1 : 0;
                }
                catch (HttpRequestException httpE)
                {
                    
                    return 2;
                }
                
            }

            wrongInputLbl.Visibility = Visibility.Visible;
            return 0;   
        }
Example #10
0
 private void CloseApp(Patient _currentPatient)
 {
     Environment.Exit(Environment.ExitCode);
 }
Example #11
0
 public void OpenTreatmentWindow(Patient _currentPatient)
 {
     //OpenningWindow.Background = null;
     using (TreatmentMenu _treatmentMenu = new TreatmentMenu(_currentPatient))
     {
         _treatmentMenu.CloseApp += CloseApp;
         _treatmentMenu.LogOut += LogOut;
         _treatmentMenu.MainWindow = this;
         this.Content = _treatmentMenu;
     }
 }
Example #12
0
 public void OpenTrainingWindow(Patient _currentPatient, Training _selectedTraining)
 {
     //OpenningWindow.Children.Clear();
     //OpenningWindow.Background = null;
     using (TrainingMenu _trainingMenu = new TrainingMenu(_currentPatient, _selectedTraining))
     {
         _trainingMenu.MainWindow = this;
         _trainingMenu.CloseApp += CloseApp;
         _trainingMenu.LogOut += LogOut;
         this.Content = _trainingMenu;
         //OpenningWindow.Children.Add(_trainingMenu);
     }
 }
Example #13
0
        public ExerciseView(Patient currentPatient, Training currentTraining)
        {
            InitializeComponent();

            CurrentPatient = currentPatient;
            CurrentTraining = currentTraining;


            this.Loaded += ExerciseView_Loaded;
        }
Example #14
0
        /// <summary>
        /// Parse from json content to new patient object, get his id
        /// </summary>
        /// <param name="_JSONcontent">The response json</param>
        public static Patient CreatePatient(string _JSONcontent)
        {
            dynamic o = JsonConvert.DeserializeObject<object>(_JSONcontent);

            bool checkError = checkForErrors((int)o.code);

            if (checkError)
            {
                //ErrorEvent(null, new ErrorMessege(((ServerCode)o.code).ToString(), (int)o.code));

                return null;
            }

            Patient _patient = new Patient();
            _patient.AccountId = o.data;

            return _patient;
        }
Example #15
0
        /// <summary>
        /// Saving user configuration details to file
        /// </summary>
        private void SaveUserConfig(Patient _currentPatient)
        {
            XmlTextWriter writer = new XmlTextWriter(config_path, System.Text.Encoding.UTF8);
            writer.WriteStartDocument(true);
            writer.Formatting = Formatting.Indented;
            writer.Indentation = 2;

            writer.WriteStartElement("user");

            writer.WriteStartElement("user_fullname");
            writer.WriteString(_currentPatient.FullName);
            writer.WriteEndElement();

            writer.WriteStartElement("user_name");
            writer.WriteString(_currentPatient.Email);
            writer.WriteEndElement();

#if DEBUG
            writer.WriteStartElement("pass");
            writer.WriteString(passwordTxt.Password);
            writer.WriteEndElement();
#endif

            writer.WriteStartElement("user_img");
            writer.WriteString(_currentPatient.ImageThumb);
            writer.WriteEndElement();

            writer.WriteEndElement();
            writer.WriteEndDocument();
            writer.Close();
        }
Example #16
0
        /// <summary>
        /// Parse from json content to current patient and his information from the json
        /// </summary>
        /// <param name="_JSONcontent">The response json</param>
        /// <param name="_patient">The _patient object</param>
        public static void GettingPatientData(Patient _patient, string _JSONcontent)
        {
            dynamic o = JsonConvert.DeserializeObject<object>(_JSONcontent);

            bool checkError = checkForErrors((int)o.code);

            if (checkError)
            {
                ErrorEvent(null, new ErrorMessege(((ServerCode)o.code).ToString(), (int)o.code));
                return;
            }

            _patient.FirstName = o.data.firstName;
            _patient.LastName = o.data.lastName;
            _patient.Email = o.data.email;
            _patient.Gender = o.data.gender;
            _patient.Age = Int32.Parse((string)o.data.age);
            _patient.ImageThumb = o.data.profilePhoto;
            _patient.BirthDay = Convert.ToDateTime((string)o.data.birthday);
            _patient.UserProfileLink = o.data.profileUrl;

            _patient.PatientTreatment = new Treatment();
            _patient.PatientTreatment.TreatmentId = o.data.treatmentIds[0];
        }
Example #17
0
        /// <summary>
        /// The constractor
        /// <param name="_patient">Current user patient</param>
        /// </summary>
        public DownloadCache(Patient _patient)
        {
            this._patient = _patient;

            dir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
        }
Example #18
0
 private void Close(Patient patient)
 {
     CloseApp(null);
 }