/// <summary>
        /// Treatment selection constractor
        /// </summary>
        /// <param name="_currentTreatment">the current treatment of the user</param>
        public UC_TreatmentSelection(Treatment _currentTreatment)
        {
            InitializeComponent();

            SetCurrentTreatment(_currentTreatment);

            TreatmentSelection.DataContext = _currentTreatment;
            TherapistInfo.DataContext = _currentTreatment.TreatmentTherapist;
        }
        private List<Training> _treatmentList; //for future porpuse

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Training program selection constractor
        /// </summary>
        /// <param name="currentTreatemet">The current treatement that the user have</param>
        public UC_TrainingProgramSelection(Treatment currentTreatemet)
        {
            InitializeComponent();

            CurrentTreatment = currentTreatemet;
            SetTrainingList(currentTreatemet.TrainingList);

            //if there is a recommended training, then will a panel will appear otherwise will not
            if (CurrentTreatment.RecommendedTraining != null)
            {
                ShowRecommendedBorder.DataContext = CurrentTreatment.RecommendedTraining;
            }
            else
            {
                ShowRecommendedBorder.Visibility = Visibility.Collapsed;
            }
        }
Ejemplo n.º 3
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();
        }
 public void SetCurrentTreatment(Treatment newTreatment)
 {
     _currentTreatment = newTreatment;
 }