Пример #1
0
    private double BmrTeeCoeff(ClientsData.NewClientData client)
    {
        double BMR = Bmr(client);
        double TEE = Tee(client);

        return(Math.Round(BMR / TEE, 2));
    }
Пример #2
0
    private WaistHip Whr(ClientsData.NewClientData client)
    {
        WaistHip x = new WaistHip();

        if (Convert.ToDouble(client.waist) > 0 && Convert.ToDouble(client.hip) > 0)
        {
            x.value = Convert.ToDouble(client.waist) / Convert.ToDouble(client.hip);
            // ***** male *****
            if (client.gender.value == 0)
            {
                x.increasedRisk = 0.95;
                x.highRisk      = 1;
                x.optimal       = 0.9;
            }
            // ***** female *****
            if (client.gender.value == 1)
            {
                x.increasedRisk = 0.80;
                x.highRisk      = 0.85;
                x.optimal       = 0.7;
            }
            if (x.value < 1)
            {
                x.title       = "gynoid fat distribution";
                x.description = "in the case of fatty tissue accumulation, it accumulates in the area of the hips";
            }
            if (x.value >= 1)
            {
                x.title       = "android fat distribution";
                x.description = "in the case of fatty tissue accumulation, it accumulates in the area of the waist";
            }
        }
        return(x);
    }
Пример #3
0
    private Goals.NewGoal RecommendedGoal(ClientsData.NewClientData client)
    {
        Goals.NewGoal        x     = new Goals.NewGoal();
        Goals                g     = new Goals();
        List <Goals.NewGoal> goals = g.GetGoals();
        double               bmi   = Bmi(client).value;

        if (bmi < 18.5)
        {
            x.code = "G3";
        }
        if (bmi >= 18.5 && bmi <= 25)
        {
            x.code = "G2";
        }
        if (bmi > 25 && bmi < 30)
        {
            x.code = "G1";
        }
        if (bmi >= 30)
        {
            x.code = "G1";
        }
        x.title      = goals.First(a => a.code == x.code).title;
        x.isDisabled = false;
        return(x);
    }
Пример #4
0
    public MyCalculation GetMyCalculation(ClientsData.NewClientData client)
    {
        MyCalculation x = new MyCalculation();

        try {
            using (SQLiteConnection connection = new SQLiteConnection("Data Source=" + db.GetDataBasePath(client.userId, userDataBase))) {
                connection.Open();
                string sql = @"SELECT myRecommendedEnergyIntake, myRecommendedEnergyExpenditure FROM clients WHERE clientId = @ClientId";
                using (SQLiteCommand command = new SQLiteCommand(sql, connection)) {
                    command.Parameters.Add(new SQLiteParameter("ClientId", client.clientId));
                    using (SQLiteDataReader reader = command.ExecuteReader()) {
                        while (reader.Read())
                        {
                            int?myRecommendedEnergyIntake      = reader.GetValue(0) == DBNull.Value ? 0 : string.IsNullOrWhiteSpace(reader.GetString(0)) ? 0 : Convert.ToInt32(reader.GetString(0));
                            int?myRecommendedEnergyExpenditure = reader.GetValue(1) == DBNull.Value ? 0 : string.IsNullOrWhiteSpace(reader.GetString(1)) ? 0 : Convert.ToInt32(reader.GetString(1));
                            if (myRecommendedEnergyIntake > 0 || myRecommendedEnergyExpenditure > 0)
                            {
                                x.recommendedEnergyIntake      = myRecommendedEnergyIntake;
                                x.recommendedEnergyExpenditure = myRecommendedEnergyExpenditure;
                            }
                            else
                            {
                                x = GetJsonFile(client.userId, client.clientId); // old sistem: data saved in json file
                            }
                        }
                    }
                }
            }
            return(x);
        } catch (Exception e) {
            L.SendErrorLog(e, client.clientId, client.userId, "Calculations", "GetMyCalculation");
            return(x);
        }
    }
Пример #5
0
 public CaliperMethod GetLastMeasurement(ClientsData.NewClientData clientData)
 {
     try {
         List <CaliperMethod> xx         = new List <CaliperMethod>();
         CaliperMethod        lastRecord = new CaliperMethod();
         string measurements             = null;
         db.CreateDataBase(clientData.userId, db.bodyfat);
         string sql = string.Format("SELECT recordDate, bodyFat, records, recordMethod FROM bodyfat WHERE clientId = '{0}'", clientData.clientId);
         using (SQLiteConnection connection = new SQLiteConnection("Data Source=" + db.GetDataBasePath(clientData.userId, dataBase))) {
             connection.Open();
             using (SQLiteCommand command = new SQLiteCommand(sql, connection)) {
                 using (SQLiteDataReader reader = command.ExecuteReader()) {
                     while (reader.Read())
                     {
                         CaliperMethod x = new CaliperMethod();
                         x.recordDate   = reader.GetValue(0) == DBNull.Value ? "" : reader.GetString(0);
                         x.bodyFat      = reader.GetValue(1) == DBNull.Value ? 0 : Convert.ToDouble(reader.GetString(1));
                         measurements   = reader.GetValue(2) == DBNull.Value ? "" : reader.GetString(2);
                         x.measurements = GetMeasurements(measurements);
                         x.code         = reader.GetValue(3) == DBNull.Value ? "" : reader.GetString(3);
                         xx.Add(x);
                     }
                 }
             }
             connection.Close();
         }
         if (xx.Count > 0)
         {
             lastRecord = xx.OrderByDescending(a => Convert.ToDateTime(a.recordDate)).FirstOrDefault();
         }
         return(lastRecord);
     } catch (Exception e) {
         return(new CaliperMethod());
     }
 }
Пример #6
0
    private ValueTitle Bmi(ClientsData.NewClientData client)
    {
        ValueTitle x = new ValueTitle();

        if (client.weight > 0 && client.height > 0)
        {
            x.value = Math.Round(client.weight * 10000 / (client.height * client.height), 2);
            if (x.value < 18.5)
            {
                x.title = "underweight";
            }
            if (x.value >= 18.5 && x.value <= 25)
            {
                x.title = "normal weight";
            }
            if (x.value > 25 && x.value < 30)
            {
                x.title = "overweight";
            }
            if (x.value >= 30)
            {
                x.title = "obese";
            }
        }
        return(x);
    }
Пример #7
0
    private WaistHip Waist(ClientsData.NewClientData client)
    {
        WaistHip x = new WaistHip();

        x.value = client.waist;

        // ***** male *****
        if (client.gender.value == 0)
        {
            x.increasedRisk = 94;
            x.highRisk      = 102;
        }

        // ***** female *****
        if (client.gender.value == 1)
        {
            x.increasedRisk = 80;
            x.highRisk      = 88;
        }

        if (x.value >= x.increasedRisk && x.value < x.highRisk)
        {
            x.title       = "increased risk of various diseases";
            x.description = string.Format("the waist circumference between {0} and {1} cm represents an increased risk of various diseases (eg diabetes and heart disease)", x.increasedRisk, x.highRisk);
        }
        if (x.value >= x.highRisk)
        {
            x.title       = "very high risk of various diseases";
            x.description = string.Format("the waist circumference above {0} cm represents a very high risk of various diseases (eg diabetes and heart disease)", x.highRisk);
        }

        return(x);
    }
Пример #8
0
    private RecommenderWeight RecommendedWeight(ClientsData.NewClientData client)
    {
        RecommenderWeight x = new RecommenderWeight();

        x.min = Math.Round((18.5 * client.height * client.height) / 10000, 1);
        x.max = Math.Round((25.0 * client.height * client.height) / 10000, 1);
        return(x);
    }
Пример #9
0
    private ValueTitle Bmi(ClientsData.NewClientData client)
    {
        ValueTitle x = new ValueTitle();

        if (client.weight > 0 && client.height > 0)
        {
            x.value = Math.Round(client.weight * 10000 / (client.height * client.height), 2);
            if (client.bmiPercentile == null)
            {
                client.bmiPercentile = new BmiPercentile();
            }
            if (client.bmiPercentile.Agemos > 0 && client.age < 20)
            {
                if (x.value < client.bmiPercentile.P5)
                {
                    x.title = "underweight";
                }
                if (x.value >= client.bmiPercentile.P5 && x.value <= client.bmiPercentile.P85)
                {
                    x.title = "normal weight";
                }
                if (x.value > client.bmiPercentile.P85 && x.value < client.bmiPercentile.P95)
                {
                    x.title = "overweight";
                }
                if (x.value >= client.bmiPercentile.P95)
                {
                    x.title = "obese";
                }
            }
            else
            {
                if (x.value < 18.5)
                {
                    x.title = "underweight";
                }
                if (x.value >= 18.5 && x.value <= 25)
                {
                    x.title = "normal weight";
                }
                if (x.value > 25 && x.value < 30)
                {
                    x.title = "overweight";
                }
                if (x.value >= 30)
                {
                    x.title = "obese";
                }
            }
            return(x);
        }
        else
        {
            return(x);
        }
    }
Пример #10
0
 public string InitMenu()
 {
     try {
         ClientsData.NewClientData x = new ClientsData.NewClientData();
         return(JsonConvert.SerializeObject(x, Formatting.None));
     } catch (Exception e) {
         L.SendErrorLog(e, null, null, "NutritionStandards", "InitMenu");
         return(JsonConvert.SerializeObject(e.Message, Formatting.None));
     }
 }
Пример #11
0
    public string GetCalculation(ClientsData.NewClientData client, int userType)
    {
        NewCalculation x = new NewCalculation();

        try {
            return(JsonConvert.SerializeObject(GetCalculationData(client, userType), Formatting.None));
        } catch (Exception e) {
            L.SendErrorLog(e, client.clientId, null, "Calculations", "GetCalculation");
            return(JsonConvert.SerializeObject(x, Formatting.None));
        }
    }
Пример #12
0
    public string InitCaliperMeasurements(ClientsData.NewClientData clientData)
    {
        CaliperData x = new CaliperData();

        try {
            x = InitCaliper(clientData);
            return(JsonConvert.SerializeObject(x, Formatting.None));
        } catch (Exception e) {
            L.SendErrorLog(e, clientData.id.ToString(), clientData.userId, "BodyFat", "InitCaliperMeasurements");
            return(JsonConvert.SerializeObject(x, Formatting.None));
        }
    }
Пример #13
0
    public CaliperData InitCaliper(ClientsData.NewClientData clientData)
    {
        CaliperData x = new CaliperData();

        x.methods = GetCaliperMethods(clientData.gender.value);
        x.data    = GetLastMeasurement(clientData);
        if (string.IsNullOrEmpty(x.data.code) || x.data.measurements == null)
        {
            x.data = x.methods[0];  // Jackson/Pollock 3 Caliper Method
        }
        x.data.clientData = clientData;
        return(x);
    }
Пример #14
0
    private Goals.NewGoal RecommendedGoal(ClientsData.NewClientData client)
    {
        Goals.NewGoal        x     = new Goals.NewGoal();
        Goals                g     = new Goals();
        List <Goals.NewGoal> goals = g.GetGoals();
        double               bmi   = Bmi(client).value;

        if (client.bmiPercentile == null)
        {
            client.bmiPercentile = new BmiPercentile();
        }
        if (client.bmiPercentile.Agemos > 0)
        {
            if (bmi < client.bmiPercentile.P5)
            {
                x.code = "G3";
            }
            if (bmi >= client.bmiPercentile.P5 && bmi <= client.bmiPercentile.P85)
            {
                x.code = "G2";
            }
            if (bmi >= client.bmiPercentile.P85)
            {
                x.code = "G1";
            }
        }
        else
        {
            if (bmi < 18.5)
            {
                x.code = "G3";
            }
            if (bmi >= 18.5 && bmi <= 25)
            {
                x.code = "G2";
            }
            if (bmi > 25 && bmi < 30)
            {
                x.code = "G1";
            }
            if (bmi >= 30)
            {
                x.code = "G1";
            }
        }
        x.title      = goals.First(a => a.code == x.code).title;
        x.isDisabled = false;
        return(x);
    }
Пример #15
0
    /***** Lean Body Mass *****/
    public NewBodyFat GetBodyFat(ClientsData.NewClientData x)
    {
        NewBodyFat bf = new NewBodyFat();

        // Lean Body Mass = (Weight(kg) x(100-(Body Fat)))/100
        if (x.bodyFat.bodyFatPerc > 0)
        {
            bf.lbm         = (x.weight * (100 - (x.bodyFat.bodyFatPerc))) / 100;
            bf.bodyFatMass = x.weight - bf.lbm;
            bf.bodyFatPerc = x.bodyFat.bodyFatPerc;
            BodyFatDesc bd = GetLmbDesc(x);
            bf.title       = bd.title;
            bf.description = bd.desc;
        }
        return(bf);
    }
Пример #16
0
    public string GetCalculation(ClientsData.NewClientData client, int userType)
    {
        NewCalculation x = new NewCalculation();

        x.bmi   = Bmi(client);
        x.whr   = Whr(client);
        x.waist = Waist(client);
        x.bmr   = Bmr(client);
        x.tee   = Tee(client);
        x.recommendedEnergyIntake      = RecommendedEnergyIntake(client);
        x.recommendedEnergyExpenditure = RecommendedEnergyExpenditure(client);
        x.recommendedWeight            = RecommendedWeight(client);
        x.goal         = RecommendedGoal(client);
        x.bmrEquations = GetBmrEquations(userType);
        x.bodyFat      = BF.GetBodyFat(client);
        return(JsonConvert.SerializeObject(x, Formatting.None));
    }
Пример #17
0
    public int RecommendedEnergyIntake(ClientsData.NewClientData client)
    {
        ValueTitle b           = Bmi(client);
        double     bmi         = b.value;
        double     tee         = Convert.ToInt32(Tee(client));
        int        expenditure = RecommendedEnergyExpenditure(client);

        int x = 0;

        if (client.bmiPercentile == null)
        {
            client.bmiPercentile = new BmiPercentile();
        }
        if (client.bmiPercentile.Agemos > 0)
        {
            if (bmi < client.bmiPercentile.P5)
            {
                x = Convert.ToInt32(tee) + 300;
            }
            if (bmi >= client.bmiPercentile.P5 && bmi <= client.bmiPercentile.P85)
            {
                x = Convert.ToInt32(tee) + expenditure;
            }
            if (bmi >= client.bmiPercentile.P85)
            {
                x = Convert.ToInt32(tee) - 300;
            }
        }
        else
        {
            if (bmi < 18.5)
            {
                x = Convert.ToInt32(tee) + 300;
            }
            if (bmi >= 18.5 && bmi <= 25)
            {
                x = Convert.ToInt32(tee) + expenditure;
            }
            if (bmi > 25)
            {
                x = Convert.ToInt32(tee) - 300;
            }
        }
        return(x);
    }
Пример #18
0
    private double Tee(ClientsData.NewClientData client)
    {
        if (client.dailyActivities.energy > 0 && client.dailyActivities.duration == 1440)
        {
            return(Math.Round(client.dailyActivities.energy, 2));
        }
        else
        {
            /*
             * The Harris–Benedict equations revised by Mifflin and St Jeor in 1990
             * Men	BMR = (10 × weight in kg) + (6.25 × height in cm) - (5 × age in years) + 5
             * Women	BMR = (10 × weight in kg) + (6.25 × height in cm) - (5 × age in years) - 161
             *
             * Little to no exercise	Daily kilocalories needed = BMR x 1.2
             * Light exercise (1–3 days per week)	Daily kilocalories needed = BMR x 1.375
             * Moderate exercise (3–5 days per week)	Daily kilocalories needed = BMR x 1.55
             * Heavy exercise (6–7 days per week)	Daily kilocalories needed = BMR x 1.725
             * Very heavy exercise (twice per day, extra heavy workouts)	Daily kilocalories needed = BMR x 1.9
             *
             * Both BMR, and RMR, estimate the number of calories you burn at rest,
             * but RMR takes additional factors into consideration when determining needs.
             * BMR measures your basal energy expenditure, or BEE.
             * The BEE is a 24 hour estimation of the number of calories you burn maintaining your most basic bodily functions,
             * such as breathing, circulating blood and growing and repairing cells.
             * RMR measures your resting energy expenditure.
             * REE determines the number of calories you burn in a 24 hour period maintaining basic bodily functions,
             * but also includes the number of calories burned eating and conducting small amounts of activity.
             */

            //int a = client.gender.value == 0 ? 5 : -161;
            //double BMR = 10 * client.weight + 6.25 * client.height - 5 * client.age + a;

            double BMR = Bmr(client);

            //(Specific dynamic action (SDA), also known as thermic effect of food (TEF) or dietary induced thermogenesis (DIT) https://en.wikipedia.org/wiki/Specific_dynamic_action
            double DIT = 0.1 * (client.pal.value * BMR);
            double TEE = client.pal.value * BMR + DIT;
            return(Math.Round(TEE, 2));
        }
    }
Пример #19
0
    public int RecommendedEnergyIntake(ClientsData.NewClientData client)
    {
        ValueTitle b           = Bmi(client);
        double     bmi         = b.value;
        double     tee         = Convert.ToInt32(Tee(client));
        int        expenditure = RecommendedEnergyExpenditure(client);

        int x = 0;

        if (bmi < 18.5)
        {
            x = Convert.ToInt32(tee) + 300;
        }
        if (bmi >= 18.5 && bmi <= 25)
        {
            x = Convert.ToInt32(tee) + expenditure;
        }
        if (bmi > 25)
        {
            x = Convert.ToInt32(tee) - 300;
        }
        return(x);
    }
Пример #20
0
    private RecommenderWeight RecommendedWeight(ClientsData.NewClientData client)
    {
        RecommenderWeight x = new RecommenderWeight();

        if (client.bmiPercentile == null)
        {
            client.bmiPercentile = new BmiPercentile();
        }
        if (client.bmiPercentile.Agemos > 0)
        {
            // ***** https://www.who.int/tools/child-growth-standards/standards/weight-for-age ***** //
            // ***** https://www.cdc.gov/growthcharts/percentile_data_files.htm ***** //
            WeightPercentile weightPercentile = GetWeightPercentile(client.agemos, client.gender.value, client.percentileSrc);
            x.min = Math.Round(weightPercentile.P5, 1);
            x.max = Math.Round(weightPercentile.P75, 1);
        }
        else
        {
            x.min = Math.Round((18.5 * client.height * client.height) / 10000, 1);
            x.max = Math.Round((25.0 * client.height * client.height) / 10000, 1);
        }
        return(x);
    }
Пример #21
0
    public NewCalculation GetCalculationData(ClientsData.NewClientData client, int userType)
    {
        NewCalculation x = new NewCalculation();

        x.bmi                          = Bmi(client);
        x.bmiPercentile                = GetBmiPercentile(client.agemos, client.gender.value, client.percentileSrc);
        client.bmiPercentile           = x.bmiPercentile;
        x.whr                          = Whr(client);
        x.waist                        = Waist(client);
        x.bmr                          = Bmr(client);
        x.tee                          = Tee(client);
        x.recommendedEnergyIntake      = RecommendedEnergyIntake(client);
        x.recommendedEnergyExpenditure = RecommendedEnergyExpenditure(client);
        x.recommendedWeight            = RecommendedWeight(client);
        x.goal                         = RecommendedGoal(client);
        x.bmrEquations                 = GetBmrEquations(userType);
        BodyFat BF = new BodyFat();

        x.bodyFat       = BF.GetBodyFat(client);
        x.percentileSrc = GetPercentileSrc();
        x.myCalculation = GetMyCalculation(client);
        return(x);
    }
Пример #22
0
 public string InitCaliperMeasurements(ClientsData.NewClientData clientData)
 {
     try {
         return(JsonConvert.SerializeObject(InitCaliper(clientData), Formatting.None));
     } catch (Exception e) { return("Error: " + e); }
 }
Пример #23
0
    public BodyFatDesc GetLmbDesc(ClientsData.NewClientData x)
    {
        /*** depending of ages: https://www.thecalculator.co/health/Body-Fat-4-Site-Skinfold-Measurement-Calculator-1114.html ***/
        BodyFatDesc bd           = new BodyFatDesc();
        double      val          = x.bodyFat.bodyFatPerc;
        int         gender       = x.gender.value;
        int         age          = x.age;
        string      veryLow      = "very low";
        string      essentialFat = "essential fat";
        string      low          = "low";
        string      athletes     = "athletes";
        string      average      = "average_";
        string      fitness      = "fitness";
        string      veryHigh     = "very high";
        string      acceptable   = "acceptable value";
        string      OverFat      = "overFat";
        string      obese        = "obese value";

        //Fat level
        if (gender == 0)
        {
            if (age >= 20 && age < 30)
            {
                if (val < 9)
                {
                    bd.title = veryLow;
                    bd.desc  = essentialFat;
                }
                if (val >= 9 && val < 13)
                {
                    bd.title = low;
                    bd.desc  = athletes;
                }
                if (val >= 13 && val < 17)
                {
                    bd.title = average;
                    bd.desc  = fitness;
                }
                if (val >= 17 && val < 20)
                {
                    bd.title = veryHigh;
                    bd.desc  = acceptable;
                }
                if (val >= 20)
                {
                    bd.title = OverFat;
                    bd.desc  = obese;
                }
            }
            if (age >= 30 && age < 40)
            {
                if (val < 11)
                {
                    bd.title = veryLow;
                    bd.desc  = essentialFat;
                }
                if (val >= 11 && val < 14)
                {
                    bd.title = low;
                    bd.desc  = athletes;
                }
                if (val >= 14 && val < 18)
                {
                    bd.title = average;
                    bd.desc  = fitness;
                }
                if (val >= 18 && val < 23)
                {
                    bd.title = veryHigh;
                    bd.desc  = acceptable;
                }
                if (val >= 23)
                {
                    bd.title = OverFat;
                    bd.desc  = obese;
                }
            }
            if (age >= 40 && age < 50)
            {
                if (val < 12)
                {
                    bd.title = veryLow;
                    bd.desc  = essentialFat;
                }
                if (val >= 12 && val < 16)
                {
                    bd.title = low;
                    bd.desc  = athletes;
                }
                if (val >= 16 && val < 21)
                {
                    bd.title = average;
                    bd.desc  = fitness;
                }
                if (val >= 21 && val < 26)
                {
                    bd.title = veryHigh;
                    bd.desc  = acceptable;
                }
                if (val >= 26)
                {
                    bd.title = OverFat;
                    bd.desc  = obese;
                }
            }
            if (age >= 50)
            {
                if (val < 13)
                {
                    bd.title = veryLow;
                    bd.desc  = essentialFat;
                }
                if (val >= 13 && val < 17)
                {
                    bd.title = low;
                    bd.desc  = athletes;
                }
                if (val >= 17 && val < 22)
                {
                    bd.title = average;
                    bd.desc  = fitness;
                }
                if (val >= 22 && val < 28)
                {
                    bd.title = veryHigh;
                    bd.desc  = acceptable;
                }
                if (val >= 28)
                {
                    bd.title = OverFat;
                    bd.desc  = obese;
                }
            }
        }
        else
        {
            if (age >= 20 && age < 30)
            {
                if (val < 17)
                {
                    bd.title = veryLow;
                    bd.desc  = essentialFat;
                }
                if (val >= 17 && val < 21)
                {
                    bd.title = low;
                    bd.desc  = athletes;
                }
                if (val >= 21 && val < 24)
                {
                    bd.title = average;
                    bd.desc  = fitness;
                }
                if (val >= 24 && val < 28)
                {
                    bd.title = veryHigh;
                    bd.desc  = acceptable;
                }
                if (val >= 28)
                {
                    bd.title = OverFat;
                }
            }
            if (age >= 30 && age < 40)
            {
                if (val < 18)
                {
                    bd.title = veryLow;
                    bd.desc  = essentialFat;
                }
                if (val >= 18 && val < 22)
                {
                    bd.title = low;
                    bd.desc  = athletes;
                }
                if (val >= 22 && val < 25)
                {
                    bd.title = average;
                    bd.desc  = fitness;
                }
                if (val >= 25 && val < 30)
                {
                    bd.title = veryHigh;
                    bd.desc  = acceptable;
                }
                if (val >= 30)
                {
                    bd.title = OverFat;
                    bd.desc  = obese;
                }
            }
            if (age >= 40 && age < 50)
            {
                if (val < 20)
                {
                    bd.title = veryLow;
                    bd.desc  = essentialFat;
                }
                if (val >= 20 && val < 24)
                {
                    bd.title = low;
                    bd.desc  = athletes;
                }
                if (val >= 24 && val < 28)
                {
                    bd.title = average;
                    bd.desc  = fitness;
                }
                if (val >= 28 && val < 32)
                {
                    bd.title = veryHigh;
                    bd.desc  = acceptable;
                }
                if (val >= 32)
                {
                    bd.title = OverFat;
                    bd.desc  = obese;
                }
            }
            if (age >= 50)
            {
                if (val < 21)
                {
                    bd.title = veryLow;
                    bd.desc  = essentialFat;
                }
                if (val >= 21 && val < 24)
                {
                    bd.title = low;
                    bd.desc  = athletes;
                }
                if (val >= 24 && val < 32)
                {
                    bd.title = average;
                    bd.desc  = fitness;
                }
                if (val >= 32 && val < 36)
                {
                    bd.title = veryHigh;
                    bd.desc  = acceptable;
                }
                if (val >= 36)
                {
                    bd.title = OverFat;
                    bd.desc  = obese;
                }
            }
        }
        return(bd);
    }
Пример #24
0
    /*********  https://completehumanperformance.com/2013/10/08/calorie-needs/  ************/

    public double Bmr(ClientsData.NewClientData x)
    {
        double BMR  = 0;
        string type = x.bmrEquation;

        if (type == HarrisBenedicts)
        {
            /***** The original Harris–Benedict equations published in 1918 and 1919 *****/
            if (x.gender.value == 0)
            {
                BMR = 66.5 + 13.75 * x.weight + 5.003 * x.height - 6.755 * x.age;      // Men
            }
            else
            {
                BMR = 655.1 + 9.563 * x.weight + 1.85 * x.height - 4.676 * x.age;      // Women
            }
        }
        else if (type == HarrisBenedictsRozaAndShizgal)
        {
            /***** The Harris–Benedict equations revised by Roza and Shizgal in 1984 *****/
            //Men BMR = 88.362 + (13.397 × weight in kg) +(4.799 × height in cm) -(5.677 × age in years)
            //Women BMR = 447.593 + (9.247 × weight in kg) +(3.098 × height in cm) -(4.330 × age in years)
            if (x.gender.value == 0)
            {
                BMR = 88.362 + (13.397 * x.weight) + (4.799 * x.height) - (5.677 * x.age);      // Men
            }
            else
            {
                BMR = 447.593 + (9.247 * x.weight) + (3.098 * x.height) - (4.330 * x.age);      // Women
            }
        }
        else if (type == MifflinStJeor)
        {
            //BMR (Men) = (10 × weight in kg) +(6.25 × height in cm) − (5 × age in years) +5
            //BMR (Women) = (10 × weight in kg) + (6.25 × height in cm) − (5 × age in years) − 161
            int a = x.gender.value == 0 ? 5 : -161;
            BMR = 10 * x.weight + 6.25 * x.height - 5 * x.age + a;
        }
        else if (type == KatchMcArdle)
        {
            //TODO:
            //        Katch-Mcardle BMR Formula:
            //BMR = 370 + (21.6 x Lean Body Mass(kg) )
            //Lean Body Mass = (Weight(kg) x(100-(Body Fat)))/100
            BodyFat bf = new BodyFat();
            BMR = 370 + 21.6 * bf.GetBodyFat(x).lbm;
        }
        else if (type == Cunningham)
        {
            //TODO:
            /****** Cunninghams = 500 + 22(lean body mass[LBM] in kg) ******/
        }
        else if (type == Owen)
        {
            //Men: RMR = 879 + 10.2 X weight
            //Women: RMR = 795 + 7.18 X weight
            if (x.gender.value == 0)
            {
                BMR = 879 + 10.2 * x.weight;      // Men
            }
            else
            {
                BMR = 795 + 7.18 * x.weight;      // Women
            }
        }
        else
        {
            /****** DEFAULT:  Mifflin - St.Jeor = 5 + 10(weight in kg) + 6.25(height in cm) − 5(age) ******/
            int a = x.gender.value == 0 ? 5 : -161;
            BMR = 10 * x.weight + 6.25 * x.height - 5 * x.age + a;
        }
        return(BMR);
    }
Пример #25
0
    private int RecommendedEnergyExpenditure(ClientsData.NewClientData client)
    {
        int    x   = 0;
        double bmi = Bmi(client).value;

        if (client.dailyActivities.energy > 0 && client.dailyActivities.duration == 1440)
        {
            double coeff = BmrTeeCoeff(client);
            if (coeff > 0.45)
            {
                x = 200;
            }
            if (coeff > 0.45 && bmi <= 25)
            {
                x = 200;
            }
            if (coeff <= 0.45 && coeff > 0.35 && bmi > 25)
            {
                x = 100;
            }
            if (coeff <= 0.45 && coeff > 0.35 && bmi <= 25)
            {
                x = 100;
            }
            if (coeff <= 0.35 && bmi <= 25)
            {
                x = 0;
            }
            if (coeff <= 0.35 && bmi > 25)
            {
                x = 0;
            }
        }
        else
        {
            double pal = client.pal.value;
            if (pal < 1.55)
            {
                x = 200;
            }
            if (pal < 1.55 && bmi <= 25)
            {
                x = 200;
            }
            if (pal >= 1.55 && pal < 1.8 && bmi > 25)
            {
                x = 100;
            }
            if (pal >= 1.55 && pal < 1.8 && bmi <= 25)
            {
                x = 100;
            }
            if (pal >= 1.8 && bmi <= 25)
            {
                x = 0;
            }
            if (pal >= 1.8 && bmi > 25)
            {
                x = 0;
            }
        }
        return(x);
    }