Exemplo n.º 1
0
        public async Task <MeasurementKpiresult> CalculatePcFat(FunnelMasterDto f)
        {
            var kpi    = new MeasurementKpiresult();
            var metric = await getMetric("PcFatValue");

            kpi.MetricId = metric.Id;

            var pcFat = 0m;

            if (f.MeasureDeviceTypeId == 3)
            {
                if (f.Genre == 1)
                {
                    pcFat = Convert.ToDecimal(
                        495 / (
                            1.0324 - 0.19077 * (
                                Math.Log(
                                    Convert.ToDouble(f.WaistValue - f.NeckValue)
                                    )
                                ) +
                            0.15456 * (
                                Math.Log(
                                    Convert.ToDouble(f.HeightValue)
                                    )
                                )
                            ) - 450
                        );
                }
                else
                {
                    pcFat = Convert.ToDecimal(
                        495 / (
                            1.29579 - 0.35004 * (
                                Math.Log(
                                    Convert.ToDouble(f.HipsValue + f.WaistValue - f.NeckValue)
                                    )
                                ) +
                            0.22100 * (
                                Math.Log(
                                    Convert.ToDouble(f.HeightValue)
                                    )
                                )
                            ) - 450
                        );
                }
            }
            kpi.Value             = pcFat * f.WeightValue;
            kpi.KpiValue          = pcFat;
            kpi.KpiObjectiveValue = (
                1.2M * CalcRepository.IMC_OBJETIVE +
                Convert.ToDecimal(0.23 * f.Age - 10.8 * f.Genre - 5.4)
                ) / 100;
            kpi.ObjectiveValue = kpi.KpiObjectiveValue * f.WeightValue;
            return(await getClassification(kpi));
        }
Exemplo n.º 2
0
        public async Task <MeasurementKpiresult> CalculateIMC(FunnelMasterDto f)
        {
            var kpi    = new MeasurementKpiresult();
            var metric = await getMetric("IMCValue");

            kpi.MetricId = metric.Id;
            kpi.KpiValue = Convert.ToDecimal(Convert.ToDouble(f.WeightValue) /
                                             Math.Pow(Convert.ToDouble(f.HeightValue / 100M), 2));
            kpi.Value             = f.WeightValue;
            kpi.KpiObjectiveValue = CalcRepository.IMC_OBJETIVE;
            kpi.ObjectiveValue    = Convert.ToDecimal(Math.Pow(Convert.ToDouble(f.HeightValue / 100M), 2)) * kpi.ObjectiveValue;

            return(await getClassification(kpi));
        }
Exemplo n.º 3
0
        public async Task <Measurement> CalculateMacros(FunnelMasterDto funnel)
        {
            var m = new Measurement();

            m.UpdateDate          = DateTime.Now;
            m.IsMetricSystem      = funnel.IsMetricSystem;
            m.MeasureDeviceTypeId = funnel.MeasureDeviceTypeId;
            m.CalculatorId        = funnel.CalculatorId;

            MeasurementKpiresult imc = await CalculateIMC(funnel);

            MeasurementKpiresult pcFat = await CalculatePcFat(funnel);

            m.MeasurementKpiresult.Add(imc);
            m.MeasurementKpiresult.Add(pcFat);
            return(m);
        }