private void UpdateData()
        {
            IsBusy = true;
            Glucose_Data.Clear();
            Slices.Clear();
            Min        = null;
            Max        = null;
            Average    = 0;
            Nbr_Normal = 0;
            Nbr_Hight  = 0;
            Nbr_Low    = 0;
            if (type == "All")
            {
                foreach (var item in DataStore.GetGlucosAsync().Where(i => i.Date.Date >= Selected_MinDate & i.Date.Date <= Selected_MaxDate))
                {
                    Glucose_Data.Add(GlycemiaConverter.Convert(item, Profil.GlycemiaUnit));
                }
            }
            else
            {
                foreach (var item in DataStore.GetGlucosAsync().Where(i => i.Date.Date >= Selected_MinDate & i.Date.Date <= Selected_MaxDate).Where(i => i.Glucose_time == type))
                {
                    Glucose_Data.Add(GlycemiaConverter.Convert(item, Profil.GlycemiaUnit));
                }
            }

            if (Glucose_Data.Count > 0)
            {
                Glucose_Data = new ObservableCollection <Glucose_Model>(Glucose_Data.OrderBy(i => i.Date));
                Min          = Glucose_Data.OrderBy(i => i.Glycemia).First();
                Max          = Glucose_Data.OrderBy(i => i.Glycemia).Last();
                Average      = (Profil.GlycemiaUnit == "mg / dL") ? Math.Round((Glucose_Data.Sum(i => i.Glycemia)) / Glucose_Data.Count, 0) : Math.Round((Glucose_Data.Sum(i => i.Glycemia)) / Glucose_Data.Count, 3);
                Nbr_Normal   = (Profil.GlycemiaUnit == "mg / dL") ? Glucose_Data.Where(i => i.Glycemia >= Objectifs.Min_Glycemia & i.Glycemia <= Objectifs.Max_Glycemia).Count() : Glucose_Data.Where(i => i.Glycemia >= GlycemiaConverter.DoubleGlycemiaConvert(Objectifs.Min_Glycemia, Profil.GlycemiaUnit) & i.Glycemia <= GlycemiaConverter.DoubleGlycemiaConvert(Objectifs.Max_Glycemia, Profil.GlycemiaUnit)).Count();
                Nbr_Hight    = (Profil.GlycemiaUnit == "mg / dL") ? Glucose_Data.Where(i => i.Glycemia > Objectifs.Max_Glycemia).Count() : Glucose_Data.Where(i => i.Glycemia > GlycemiaConverter.DoubleGlycemiaConvert(Objectifs.Max_Glycemia, Profil.GlycemiaUnit)).Count();
                Nbr_Low      = (Profil.GlycemiaUnit == "mg / dL") ? Glucose_Data.Where(i => i.Glycemia < Objectifs.Min_Glycemia).Count() : Glucose_Data.Where(i => i.Glycemia < GlycemiaConverter.DoubleGlycemiaConvert(Objectifs.Min_Glycemia, Profil.GlycemiaUnit)).Count();
                MaximumChart = (Profil.GlycemiaUnit == "mg / dL") ? Convert.ToInt32(Max.Glycemia + 100) : Convert.ToInt32(Max.Glycemia + 10);
                if (Average < GlycemiaConverter.DoubleGlycemiaConvert(Objectifs.Min_Glycemia, Profil.GlycemiaUnit))
                {
                    GlucoseColor = Color.FromHex("#f1c40f");
                }
                if (Average >= GlycemiaConverter.DoubleGlycemiaConvert(Objectifs.Min_Glycemia, Profil.GlycemiaUnit) & Average <= GlycemiaConverter.DoubleGlycemiaConvert(Objectifs.Max_Glycemia, Profil.GlycemiaUnit))
                {
                    GlucoseColor = Color.FromHex("#2ecc71");
                }
                if (Average > GlycemiaConverter.DoubleGlycemiaConvert(Objectifs.Max_Glycemia, Profil.GlycemiaUnit))
                {
                    GlucoseColor = Color.FromHex("#e74c3c");
                }
                Min_Glycemia = GlycemiaConverter.DoubleGlycemiaConvert(Objectifs.Min_Glycemia, Profil.GlycemiaUnit);
                Max_Glycemia = GlycemiaConverter.DoubleGlycemiaConvert(Objectifs.Max_Glycemia, Profil.GlycemiaUnit);
                Max_Widh     = MaximumChart - Max_Glycemia;
                Good_Wigh    = Max_Glycemia - Min_Glycemia;
            }
            Slices.Add(new Slice_Model
            {
                type  = "Normal",
                value = Nbr_Normal
            });
            Slices.Add(new Slice_Model
            {
                type  = "Elevée",
                value = Nbr_Hight
            });
            Slices.Add(new Slice_Model
            {
                type  = "Basse",
                value = Nbr_Low
            });
            IsBusy = false;
        }
Пример #2
0
        private void UpdateData()
        {
            Profil    = DataStore.GetSettingsAsync().First();
            Objectifs = DataStore.GetObjectifAsync().First();
            Glucose_Data.Clear();
            Weight_Data.Clear();
            Last_Glycemia = null;
            Last_Hb1Ac    = null;
            Last_Pression = null;
            Last_Weight   = null;
            Average       = 0;
            Nbr_Hight     = 0;
            Nbr_Low       = 0;
            Nbr_Normal    = 0;
            Min           = 0;
            Max           = 0;
            foreach (var item in DataStore.GetGlucosAsync().Where(i => i.Date >= DateTime.Now.AddDays(-7)))
            {
                Glucose_Data.Add(GlycemiaConverter.Convert(item, Profil.GlycemiaUnit));
            }
            foreach (var item in DataStore.GetWeightAsync())
            {
                Weight_Data.Add(WeightConverter.Convert(item, Profil.WeightUnit));
            }
            pression_data = new ObservableCollection <Pression_Model>(DataStore.GetPressionAsync().Where(i => i.Date.Date == DateTime.Now.Date));
            Hb1Ac_Data    = new ObservableCollection <Hb1Ac_Model>(DataStore.GetHb1acAsync());

            if (Glucose_Data.Count > 0)
            {
                Last_Glycemia = Glucose_Data.OrderBy(i => i.Date).Last();
                Average       = (Profil.GlycemiaUnit == "mg / dL") ? Math.Round((Glucose_Data.Sum(i => i.Glycemia)) / Glucose_Data.Count, 0) : Math.Round((Glucose_Data.Sum(i => i.Glycemia)) / Glucose_Data.Count, 3);
                Min           = Glucose_Data.OrderBy(i => i.Glycemia).First().Glycemia;
                Max           = Glucose_Data.OrderBy(i => i.Glycemia).Last().Glycemia;
                if (Profil.GlycemiaUnit == "mg / dL")
                {
                    Nbr_Normal = Glucose_Data.Where(i => i.Glycemia >= Objectifs.Min_Glycemia & i.Glycemia <= Objectifs.Max_Glycemia).Count();
                    Nbr_Hight  = Glucose_Data.Where(i => i.Glycemia > Objectifs.Max_Glycemia).Count();
                    Nbr_Low    = Glucose_Data.Where(i => i.Glycemia < Objectifs.Min_Glycemia).Count();
                    if (Last_Glycemia.Glycemia < Objectifs.Min_Glycemia & Last_Glycemia.Glycemia != 0)
                    {
                        GlucoseColor = Color.FromHex("#f1c40f");
                    }
                    if (Last_Glycemia.Glycemia >= Objectifs.Min_Glycemia & Last_Glycemia.Glycemia <= Objectifs.Max_Glycemia)
                    {
                        GlucoseColor = Color.FromHex("#0AC774");
                    }
                    if (Last_Glycemia.Glycemia > Objectifs.Max_Glycemia)
                    {
                        GlucoseColor = Color.FromHex("#C72D14");
                    }
                }
                else
                {
                    Nbr_Normal = Glucose_Data.Where(i => i.Glycemia >= GlycemiaConverter.DoubleGlycemiaConvert(Objectifs.Min_Glycemia, Profil.GlycemiaUnit) & i.Glycemia <= GlycemiaConverter.DoubleGlycemiaConvert(Objectifs.Max_Glycemia, Profil.GlycemiaUnit)).Count();
                    Nbr_Hight  = Glucose_Data.Where(i => i.Glycemia > GlycemiaConverter.DoubleGlycemiaConvert(Objectifs.Max_Glycemia, Profil.GlycemiaUnit)).Count();
                    Nbr_Low    = Glucose_Data.Where(i => i.Glycemia < GlycemiaConverter.DoubleGlycemiaConvert(Objectifs.Min_Glycemia, Profil.GlycemiaUnit)).Count();
                    if (Last_Glycemia.Glycemia < GlycemiaConverter.DoubleGlycemiaConvert(Objectifs.Min_Glycemia, Profil.GlycemiaUnit) & Average != 0)
                    {
                        GlucoseColor = Color.FromHex("#f1c40f");
                    }
                    if (Last_Glycemia.Glycemia >= GlycemiaConverter.DoubleGlycemiaConvert(Objectifs.Min_Glycemia, Profil.GlycemiaUnit) & Average <= GlycemiaConverter.DoubleGlycemiaConvert(Objectifs.Max_Glycemia, Profil.GlycemiaUnit))
                    {
                        GlucoseColor = Color.FromHex("#2ecc71");
                    }
                    if (Last_Glycemia.Glycemia > GlycemiaConverter.DoubleGlycemiaConvert(Objectifs.Max_Glycemia, Profil.GlycemiaUnit))
                    {
                        GlucoseColor = Color.FromHex("#e74c3c");
                    }
                }
            }
            if (pression_data.Count > 0)
            {
                Last_Pression = Pression_Data.Where(i => i.Date.Date <= DateTime.Now.Date).OrderBy(i => i.Date).Last();
            }
            if (Hb1Ac_Data.Count > 0)
            {
                Last_Hb1Ac = Hb1Ac_Data.Where(i => i.Date.Date <= DateTime.Now.Date).OrderBy(i => i.Date).Last();
            }
            if (Weight_Data.Count > 0)
            {
                Last_Weight = Weight_Data.Where(i => i.Date.Date <= DateTime.Now.Date).OrderBy(i => i.Date).Last();
            }
            if (DataStore.GetStepsAsync().Count() > 0)
            {
                if (DataStore.GetStepsAsync().Where(i => i.Date.Date == DateTime.Now.Date).Count() > 0)
                {
                    Steps = DataStore.GetStepsAsync().Single(i => i.Date.Date == DateTime.Now.Date).Steps;
                }
            }
            NextMedication();
        }
Пример #3
0
        private void UpdateData()
        {
            List <LogBook_Model> _data = new List <LogBook_Model>();

            Profil = DataStore.GetSettingsAsync().First();
            foreach (var item in DataStore.GetGlucosAsync())
            {
                var glucose = new LogBook_Model
                {
                    Data            = item,
                    DataValue       = GlycemiaConverter.Convert(item, Profil.GlycemiaUnit).Glycemia.ToString(),
                    Date            = item.Date,
                    Activity        = item.Activity,
                    Take_Medication = item.Taking_Medication,
                    Type            = "Glucose",
                    Unit            = Profil.GlycemiaUnit,
                    PicturePath     = item.PicturePathe
                };
                _data.Add(glucose);
            }
            foreach (var item in DataStore.GetHb1acAsync())
            {
                var drug = new LogBook_Model
                {
                    Data        = item,
                    DataValue   = item.Hb1Ac.ToString(),
                    Date        = item.Date,
                    Type        = "Hb1Ac",
                    Unit        = "%",
                    PicturePath = item.PicturePathe
                };
                _data.Add(drug);
            }

            foreach (var item in DataStore.GetPressionAsync())
            {
                var drug = new LogBook_Model
                {
                    Data        = item,
                    DataValue   = item.Diastolique.ToString() + "/" + item.Systolique.ToString(),
                    Date        = item.Date,
                    At_Home     = (item.Where == "home") ? true : false,
                    At_Doctor   = (item.Where == "clinic") ? true : false,
                    Type        = "Pression",
                    Unit        = "mmgH",
                    PicturePath = item.PicturePathe
                };
                _data.Add(drug);
            }
            foreach (var item in DataStore.GetWeightAsync())
            {
                var drug = new LogBook_Model
                {
                    Data        = item,
                    DataValue   = WeightConverter.Convert(item, Profil.WeightUnit).Weight.ToString(),
                    Date        = item.Date,
                    Type        = "Weight",
                    Unit        = Profil.WeightUnit,
                    PicturePath = item.PicturePathe
                };
                _data.Add(drug);
            }
            private_list  = new ObservableCollection <LogBook_Model>(_data);
            Selected_item = null;
            old_selected  = null;
            var sorted = from data in _data
                         orderby data.Date descending
                         group data by data.DateSort into DataGroup
                         select new Grouping <string, LogBook_Model>(DataGroup.Key, DataGroup);

            DataGrouped = new ObservableCollection <Grouping <string, LogBook_Model> >(sorted);
        }