Esempio n. 1
0
        private void Generator()
        {
            if (_Weight != 0)
            {
                int    User_age = DateTime.Now.Year - ((Users)BindingContext).birthdate.Year;
                Double length   = ((Users)BindingContext).length;
                //Double mass = Convert.ToDouble(WeightEntry.Text);

                BMIs BMI = new BMIs();
                BMI.time   = DateTime.UtcNow;
                BMI.UserID = ((Users)BindingContext).ID;
                BMI.BMI    = _Weight / ((length / 100) * (length / 100));
                BMI.weight = _Weight;
                if (((Users)BindingContext).Gender == 1) // Gender  = 1 means User Gender is Man
                {
                    BMI.BMR = (_Weight * 13.7) - (length * 5) + (User_age * 8.6) + 66;
                }
                else
                {
                    BMI.BMR = (_Weight * 9.7) - (length * 1.7) + (User_age * 4.7) + 655;
                }
                //Res.Text += ("  BMR =" + BMR);
                App.Database.AddBMI(BMI);
                _BMI = BMI;

                ShowBMIResult();
            }
        }
Esempio n. 2
0
 public string AddBMI(BMIs BMI)
 {
     try
     {
         _database.Insert(BMI);
         return("Sucessfully Added");
     }
     catch (Exception e)
     {
         return($"Error :{e.Message}");
     }
 }
Esempio n. 3
0
        private Double GetCalorieBMR()
        {
            List <BMIs> _BMIs = App.Database.GetBMI(App.UserID);

            if (_BMIs.Count > 0)
            {
                BMIs _BMI = _BMIs[_BMIs.Count - 1];
                return(_BMI.BMR * _BetaMultiplier);
            }
            else
            {
                return(0);// dont have BMR
            }
        }
Esempio n. 4
0
        //private int User_age=0;
        //private Double length=0;
        //private Double mass =0;
        //public float BMI;
        //public float BMR;
        //public static readonly BindableProperty UserProperty = BindableProperty.Create<Users, user>(p => p.user, new Users());
        //public Users user
        //{
        //    get => (Users)GetValue(UserProperty);
        //    set => SetValue(UserProperty, value);
        //}

        //Users user;
        //public int age
        //{
        //    //get { return (int)GetValue(length); }
        //}
        public BMIPage()
        {
            InitializeComponent();
            _BMIs = App.Database.GetBMI(App.UserID);
            if (_BMIs.Count > 0)
            {
                _BMI = _BMIs[_BMIs.Count - 1];
                ShowBMIResult();
            }
            else
            {
                ShowBMINoResult();
            }
        }
Esempio n. 5
0
        public void SetBMIClass(DataTable bmiData)
        {
            //get the last bmi observation
            if (BMIs.Count() > 0 && (Sex.ToLower() == "male" || Sex.ToLower() == "female"))
            {
                //determine the age at the last observation
                var    lastObs     = BMIs.Last();
                double ageInMonths = (lastObs.Date.Subtract(Date_Of_Birth).TotalDays / 365.25) * 12;

                //if over 20 use standard bmi
                if (ageInMonths > 20 * 12)
                {
                    if (lastObs.Measurement < (decimal)18.5)
                    {
                        BMIClass = BMIClassification.Underweight;
                    }
                    else if (lastObs.Measurement < (decimal)25.0)
                    {
                        BMIClass = BMIClassification.Normal;
                    }
                    else if (lastObs.Measurement < (decimal)25.0)
                    {
                        BMIClass = BMIClassification.Overweight;
                    }
                    else
                    {
                        BMIClass = BMIClassification.Obese;
                    }
                }
                else if (ageInMonths > 24)
                {
                    //otherwise use the childhood chart

                    //round the age in months to the nearest .5
                    ageInMonths = Math.Round(ageInMonths) + .5;

                    //select the data rows that are relevant
                    var results = from myRow in bmiData.AsEnumerable()
                                  where myRow.Field <string>("age_in_months") == ageInMonths.ToString() && Sex.ToLower() == myRow.Field <string>("gender")
                                  select myRow;

                    //if
                    var underweight = from row in results
                                      where row.Field <string>("bmi_percentile") == "0.5"
                                      select row;

                    var normal = from row in results
                                 where row.Field <string>("bmi_percentile") == "0.85"
                                 select row;

                    var overweight = from row in results
                                     where row.Field <string>("bmi_percentile") == "0.95"
                                     select row;


                    if (lastObs.Measurement < Decimal.Parse(underweight.First().Field <string>("bmi")))
                    {
                        BMIClass = BMIClassification.Underweight;
                    }
                    else if (lastObs.Measurement < Decimal.Parse(normal.First().Field <string>("bmi")))
                    {
                        BMIClass = BMIClassification.Normal;
                    }
                    else if (lastObs.Measurement < Decimal.Parse(overweight.First().Field <string>("bmi")))
                    {
                        BMIClass = BMIClassification.Overweight;
                    }
                    else
                    {
                        BMIClass = BMIClassification.Obese;
                    }
                }
                else
                {
                    BMIClass = BMIClassification.Normal;
                }
            }
            else
            {
                //if there are no observations just set it to normal
                BMIClass = BMIClassification.Normal;
            }
        }
Esempio n. 6
0
        public Patient(HL7.Patient patient)
        {
            Random rand = new Random();

            ID             = patient.Id;
            FirstName      = patient.Name.ElementAt(0).Given.ElementAt(0);
            LastName       = patient.Name.ElementAt(0).Family.ElementAt(0);
            MiddleName     = "";
            Sex            = patient.GenderElement.Value.ToString();
            Ethnicity      = ethnicities[rand.Next(0, ethnicities.Length)];
            Insurance_Type = "Unknown";
            Date_Of_Birth  = Convert.ToDateTime(patient.BirthDate);
            Add_Address(patient.Address.ElementAt(0).Line.ElementAt(0), patient.Address.ElementAt(0).City, patient.Address.ElementAt(0).State, patient.Address.ElementAt(0).PostalCode, patient.Address.ElementAt(0).District);

            //if there isn't a saved practitioner generate and add it to the list, otherwise uses the provided one
            if (patient.CareProvider.Count == 0)
            {
                PractitionerIDs.Add(rand.Next(1, 5));
            }
            else
            {
                foreach (var practitionerRef in patient.CareProvider)
                {
                    PractitionerIDs.Add(Int32.Parse(practitionerRef.Reference.Replace("Practitioner/", "")));
                }
            }

            //default hypertension
            Has_HyperTension  = false;
            HypertensionClass = HypertensionClassification.Normal;

            //default bmi
            BMIClass = BMIClassification.Normal;

            foreach (Data_Holder dh in Patient_Data.PatientInfo(ID))
            {
                switch (dh.Type)
                {
                case "BMI":
                    BMIs.Add(new BMI(dh.Date, dh.Measurement));
                    break;

                case "WEIGHT":
                    Weights.Add(new Weight(dh.Date, dh.Measurement));
                    break;

                case "HEIGHT":
                    Heights.Add(new Height(dh.Date, dh.Measurement));
                    break;

                case "HEMOGLOBIN":
                    Hemoglobins.Add(new Hemoglobin(dh.Date, dh.Measurement));
                    HemoglobinClass = (dh.Measurement < (decimal)0.057) ? HemoglobinClassification.Normal : HemoglobinClassification.High;
                    break;

                case "HYPERTENSION":
                    Has_HyperTension  = true;
                    HypertensionClass = HypertensionClassification.Diagnosed;
                    break;
                }
            }
        }