using Furion;
using Furion.DependencyInjection;
using Nirvana.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using YBDevice.Core;
using YBDevice.Entity;

namespace YBDevice.CommonService.BodyFatHelper
{
    /// <summary>
    /// 体脂计算算法
    /// </summary>
    public class BodyFatHelperService : IBodyFatHelperService, ITransient
    {
        private readonly IHttpClientFactory _clientFactory;
        private readonly IHttp _http;
        private static string RequestUrl = App.Configuration["BodyApiSettings:ApiUrl"];
        private static string RequestaccessSecret = App.Configuration["BodyApiSettings:AccessSecret"];
        private static string RequestaccessKey = App.Configuration["BodyApiSettings:AccessKey"];
        public BodyFatHelperService(IHttpClientFactory clientFactory, IHttp http)
        {
            _clientFactory = clientFactory;
            _http = http;
        }

        /// <summary>
        /// BMI值计算
        /// </summary>
        /// <param name="height">身高,厘米</param>
        /// <param name="weight">体重,公斤</param>
        /// <returns></returns>
        public decimal CalcBMi(decimal height, decimal weight)
        {
            if (height == 0 || weight == 0)
            {
                return 0;
            }
            decimal mheight = height / (100 * 1.0m);//转换为米
            return (((weight / (mheight * mheight)) * 10.0m) / 10.0m).ToDecimal(1);
        }

        /// <summary>
        /// 结果计算
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public UserMeasureModel CalcBodyFat(MeasureCalcDto model)
        {
            //算法使用的性别为0-女,1-男
            int sex = model.sex == 2 ? 0 : 1;
            int age = model.age;
            double weight = model.weight.ToDouble();
            int height = model.height.ToInt();
            decimal dweight = weight.ToDecimal();
            model.StandardWeight = standweight(height, sex).ToDecimal(2);
            model.fat_w = (model.fat_r.ToDouble() * weight / 100).ToDecimal(2);
            model.lbm = ((1 - model.fat_r.ToDouble() / 100) * weight).ToDecimal(2);
            model.muscleval = (weight * (model.muscle.ToDouble() / 100)).ToDecimal(2);
            model.proteinval = (weight * (model.protein.ToDouble() / 100)).ToDecimal(2);
            if (model.imp <= 0)
            {
                decimal mheight = (height.ToDecimal()) / (100 * 1.0m);
                var returndata = new UserMeasureModel
                {
                    weight = model.height,
                    bmi = (((dweight / (mheight * mheight)) * 10.0m) / 10.0m).ToDecimal(1),
                    standardWeight = standweight(height, sex).ToString("f2"),
                };
                returndata.bmiLevel = bmi(model.bmi.ToFloat());
                returndata.cmi = score(returndata.bmi.ToFloat()).ToDecimal(1);
                double levels = (weight - returndata.standardWeight.ToDouble()) / returndata.standardWeight.ToDouble();
                returndata.fatLevel = fatlevel(levels);
                returndata.fatlevlval = levels.ToString("f2");
                return returndata;
            }
            var data = new UserMeasureModel
            {
                bmi = model.bmi,
                bmiLevel = bmi(model.bmi.ToFloat()),
                fat_r = model.fat_r,
                fat_rLevel = Fat_r(model.fat_r.ToFloat(), sex, age),
                bodyage = model.bodyage,
                bodyageLevel = bodyage(model.bodyage, age),
                fat_w = model.fat_w,
                fat_wLevel = Fat_r(model.fat_r.ToFloat(), sex, age),
                bone = model.bone,
                boneLevel = bone(model.bone.ToFloat(), weight, sex),
                kcal = model.kcal < 0 ? 0 : model.kcal,
                kcalLevel = kcal(model.kcal.ToFloat(), weight, age, sex),
                muscle = model.muscle,
                muscleLevel = muscle(model.muscle.ToFloat(), weight, age, sex),
                protein = model.protein,
                proteinLevel = protein(model.protein.ToFloat(), weight, age, sex),
                visceral = model.visceral,
                visceralLevel = visceral(model.visceral.ToFloat(), weight, age, sex),
                water = model.water,
                waterLevel = water(model.water.ToFloat(), weight, age, sex),
                cmi = score(model.bmi.ToFloat()).ToDecimal(1),
                muscleval = model.muscleval,
                proteinval = model.proteinval,
                lbm = model.lbm,
                standardWeight = model.StandardWeight.ToString(),
                sfr = model.sfr.ToDecimal(2),
                sfrLevel = sfr(model.sfr.ToFloat(), weight, age, sex),
                body = "0",
                standardfat_r = fa_r_value(sex, age).ToJson(),
                standardbmi = bmi_value(sex, age).ToJson(),
                standardmuscle = muscle_value(sex, age).ToJson(),
                standardmuscleval = muscleval_value(sex, age, dweight).ToJson(),
                standardwater = water_value(sex, age).ToJson(),
                standardbone = bone_value(sex, age, dweight).ToJson(),
                standardkcal = kcal_value(sex, age, dweight).ToJson(),
                standardfat_w = fat_w_value(sex, age, dweight).ToJson(),
                standardviscera = visceral_value(sex, age).ToJson(),
                standardprotein = protein_value(sex, age).ToJson(),
                standardproteinval = proteinval_value(sex, age, dweight).ToJson(),
                standardbodyage = "",
                standardsfr = sfr_value(sex, age).ToJson(),
                weight = model.weight.ToDecimal(),
                fatlevlval = model.fatlevlval
            };
            data.bodylevel = body(data.fat_rLevel, data.muscleLevel);
            data.musulevalLevel = data.muscleLevel;
            data.proteinvalLevel = data.proteinLevel;
            //   double level = (weight - data.standardWeight.ToDouble()) / data.standardWeight.ToDouble();
            data.fatLevel = model.IsCalc == 1 ? model.fatlevlval : fatlevel(model.fatlevlval.ToDouble());
            //   data.fatlevlval = level.ToString("f2");
            return data;
        }

        /// <summary>
        /// 二、四电极计算体脂
        /// </summary>
        /// <param name="weight">体重,单位为kg</param>
        /// <param name="height">身高,单位为厘米</param>
        /// <param name="age">年龄</param>
        /// <param name="adc">阻抗</param>
        /// <param name="sex">性别,1-男，2-女,0-未知</param>
        /// <returns></returns>
        public UserMeasureModel CalcBodyFat(double weight, double height, int age, int adc, int sex)
        {
            //算法使用的性别为0-女,1-男
            sex = sex == 2 ? 0 : 1;
            var result = GetBodyfatResults(weight, height, age, adc, sex);
            decimal dwegiht = weight.ToDecimal();
            var data = new UserMeasureModel
            {
                bmi = result.bmi.ToDecimal(),
                bmiLevel = bmi(result.bmi.ToFloat()),
                fat_r = result.bfr.ToDecimal(),
                fat_rLevel = Fat_r(result.bfr.ToFloat(), sex, age),
                bodyage = result.physicAge.ToInt(),
                bodyageLevel = bodyage(result.physicAge.ToInt(), age),
                fat_w = (result.bfr.ToDouble() * weight / 100).ToDecimal(2),
                fat_wLevel = Fat_r(result.bfr.ToFloat(), sex, age),
                bone = result.bm.ToDecimal(),
                boneLevel = bone(result.bm.ToFloat(), weight, sex),
                kcal = result.bmr.ToDecimal() < 0 ? 0 : result.bmr.ToDecimal(),
                kcalLevel = kcal(result.bmr.ToFloat(), weight, age, sex),
                muscle = result.rom.ToDecimal(),
                muscleLevel = muscle(result.rom.ToFloat(), weight, age, sex),
                protein = result.pp.ToDecimal(),
                proteinLevel = protein(result.pp.ToFloat(), weight, age, sex),
                visceral = result.uvi.ToDecimal(),
                visceralLevel = visceral(result.uvi.ToFloat(), weight, age, sex),
                water = result.moi.ToDecimal(),
                waterLevel = water(result.moi.ToFloat(), weight, age, sex),
                cmi = score(result.bmi.ToFloat()).ToDecimal(1),
                muscleval = (weight * (result.rom.ToDouble() / 100)).ToDecimal(2),
                proteinval = (weight * (result.pp.ToDouble() / 100)).ToDecimal(2),
                lbm = ((1 - result.bfr.ToDouble() / 100) * weight).ToDecimal(2),
                standardWeight = standweight(height.ToInt(), sex).ToString("f2"),
                sfr = result.sfr.ToDecimal(2),
                sfrLevel = sfr(result.sfr.ToFloat(), weight, age, sex),
                body = "0",
                standardfat_r = fa_r_value(sex, age).ToJson(),
                standardbmi = bmi_value(sex, age).ToJson(),
                standardmuscle = muscle_value(sex, age).ToJson(),
                standardmuscleval = muscleval_value(sex, age, dwegiht).ToJson(),
                standardwater = water_value(sex, age).ToJson(),
                standardbone = bone_value(sex, age, dwegiht).ToJson(),
                standardkcal = kcal_value(sex, age, dwegiht).ToJson(),
                standardfat_w = fat_w_value(sex, age, dwegiht).ToJson(),
                standardviscera = visceral_value(sex, age).ToJson(),
                standardprotein = protein_value(sex, age).ToJson(),
                standardproteinval = proteinval_value(sex, age, dwegiht).ToJson(),
                standardbodyage = "",
                standardsfr = sfr_value(sex, age).ToJson(),
                weight = weight.ToDecimal(2),
                height = height.ToDecimal(2)
            };
            data.bodylevel = body(data.fat_rLevel, data.muscleLevel);
            data.musulevalLevel = data.muscleLevel;
            data.proteinvalLevel = data.proteinLevel;
            double level = (weight - data.standardWeight.ToDouble()) / data.standardWeight.ToDouble();
            data.fatLevel = fatlevel(level);
            data.fatlevlval = level.ToString("f2");
            return data;
        }
        /// <summary>
        /// 八电极计算体脂
        /// </summary>
        /// <param name="weight">体重,单位为kg</param>
        /// <param name="height">身高,单位为厘米</param>
        /// <param name="age">年龄</param>
        /// <param name="sex">性别,1-男，2-女,0-未知</param>
        /// <param name="body">全身阻抗</param>
        /// <param name="leftfoot">左脚阻抗</param>
        /// <param name="lefthand">左手阻抗</param>
        /// <param name="rightfoot">右脚阻抗</param>
        /// <param name="righthand">右手阻抗</param>
        public async Task<UserMeasureDto> CalcBody120FatAsync(decimal weight, decimal height, int age, int sex, decimal lefthand, decimal righthand, decimal leftfoot, decimal rightfoot, decimal body)
        {
            var mheight = height / 100;
            //阻抗测量失败
            if (body <= 0 || body == 4294967295)
            {
                var returndata = new UserMeasureDto
                {
                    weight = weight,
                    bmi = (((weight / (mheight * mheight)) * 10.0m) / 10.0m).ToDecimal(1),
                    idealweight = CalcStandWeight(height, sex),
                    height = height
                };
                returndata.bmiLevel = bmi(returndata.bmi.ToFloat());
                returndata.cmi = score(returndata.bmi.ToFloat()).ToDecimal(1);
                decimal levels = (weight - returndata.idealweight) / returndata.idealweight;
                returndata.fatLevel = fatlevel(levels.ToDouble());
                return returndata;
            }
            //算法使用的是0-男,1-女
            sex = sex == 2 ? 0 : 1;

            var requestdata = new HetaiBodyRequestS2SDto
            {
                age = age,
                heightCm = height,
                peopleType = 0,
                sex = sex,
                weightKg = weight,
                zLeftBodyEnCode = body,
                zLeftArmEnCode = lefthand,
                zLeftLegEnCode = leftfoot,
                zRightArmEnCode = righthand,
                zRightLegEnCode = rightfoot
            };
            var hashtable = HashTableHelper.Object2Hashtable(requestdata);
            var strA = Common.SortRequestParam(hashtable);
            var accessSecret = RequestaccessSecret;
            var accessKey = RequestaccessKey;
            var timestamp = Common.GetTimestamps();
            strA = $"{strA}&timestamp={timestamp}&accessSecret={accessSecret}";
            var sign = Md5.md5(strA, 32).ToUpper();
            var url = RequestUrl;
            var loggerService = App.GetService<ILoggerService>();
            string errmsg = String.Empty;
            var response = await _http.PostBodyAsync(requestdata, accessKey, timestamp, sign, (res, erros) =>
            {
                errmsg = erros;
            });
            if (!string.IsNullOrEmpty(errmsg))
            {
                loggerService.AddLogger($"八电极算法请求失败,参数:{requestdata.ToJson()},错误信息:{errmsg}");
                var returndata = new UserMeasureDto
                {
                    weight = weight,
                    bmi = (((weight / (mheight * mheight)) * 10.0m) / 10.0m).ToDecimal(1),
                    idealweight = standweight(height.ToInt(), sex).ToDecimal(2),
                    height = height
                };
                returndata.bmiLevel = bmi(returndata.bmi.ToFloat());
                returndata.cmi = score(returndata.bmi.ToFloat()).ToDecimal(1);
                decimal levels = (weight - returndata.idealweight) / returndata.idealweight;
                returndata.fatLevel = fatlevel(levels.ToDouble());
                return returndata;
            }
            var returnstr = await response.Content.ReadAsStringAsync();
            if (response.IsSuccessStatusCode)
            {
                var codedata = returnstr.ToObject<BodyReponseInfo>();
                if (codedata.code != 1000)
                {
                    loggerService.AddLogger($"八电极算法请求失败,参数:{requestdata.ToJson()},错误信息:{returnstr}");
                    var returndata = new UserMeasureDto
                    {
                        weight = weight,
                        bmi = (((weight / (mheight * mheight)) * 10.0m) / 10.0m).ToDecimal(1),
                        idealweight = standweight(height.ToInt(), sex).ToDecimal(2),
                        height = height
                    };
                    returndata.bmiLevel = bmi(returndata.bmi.ToFloat());
                    returndata.cmi = score(returndata.bmi.ToFloat()).ToDecimal(1);
                    decimal levels = (weight - returndata.idealweight) / returndata.idealweight;
                    returndata.fatLevel = fatlevel(levels.ToDouble());
                    return returndata;
                }
                else
                {
                    var responsedata = returnstr.ToObject<BodyReponseInfo<BodyResponseData>>();
                    var returndata = new UserMeasureDto()
                    {
                        weight = weight,
                        height = height
                    };
                    double dweight = weight.ToDouble();
                    foreach (var item in responsedata.data)
                    {
                        var name = item.name.ToLower();
                        if (name == "bmi")
                        {
                            returndata.bmi = (((weight / (mheight * mheight)) * 10.0m) / 10.0m).ToDecimal(1);
                            returndata.bmiLevel = GetBodyValueLevel(name, item);
                        }
                        if (name == "bodyfatrate")
                        {
                            returndata.fat_r = GetBodyValue(name, item).ToDecimal();
                            //returndata.fat_rLevel = GetBodyValueLevel(name, item);
                            returndata.fat_rLevel = Fat_r((float)returndata.fat_r, sex, age);
                            returndata.fat_wLevel = returndata.fat_rLevel;
                        }
                        if (name == "bonekg")
                        {
                            returndata.bone = GetBodyValue(name, item).ToDecimal();
                            //returndata.boneLevel = GetBodyValueLevel(name, item);
                            returndata.boneLevel = bone((float)returndata.bone, dweight, sex);
                        }
                        if (name == "waterrate")
                        {
                            returndata.water = GetBodyValue(name, item).ToDecimal();
                            //returndata.waterLevel = GetBodyValueLevel(name, item);
                            returndata.waterLevel = water((float)returndata.water, dweight, age, sex);
                        }
                        if (name == "musclekg")
                        {
                            returndata.muscleval = GetBodyValue(name, item).ToDecimal();
                            //returndata.muscleLevel = GetBodyValueLevel(name, item);
                        }
                        if (name == "proteinrate")
                        {
                            returndata.protein = GetBodyValue(name, item).ToDecimal();
                            returndata.proteinval = (returndata.protein * weight / 100).ToDecimal(2);
                            //returndata.proteinLevel = GetBodyValueLevel(name, item);
                            returndata.proteinLevel = protein((float)returndata.protein, dweight, age, sex);
                            returndata.proteinvalLevel = returndata.proteinLevel;
                        }
                        if (name == "skeletalmusclekg")
                        {
                            returndata.SkeletalMuscle = GetBodyValue(name, item).ToDecimal();
                            returndata.SkeletalMuscleLevel = GetBodyValueLevel(name, item);
                        }
                        if (name == "bodyfatsubcutrate")
                        {
                            returndata.sfr = GetBodyValue(name, item).ToDecimal();
                            //returndata.sfrLevel = GetBodyValueLevel(name, item);
                            returndata.sfrLevel = sfr((float)returndata.sfr, dweight, age, sex);
                        }
                        if (name == "bmr")
                        {
                            returndata.kcal = GetBodyValue(name, item).ToDecimal();
                            //returndata.kcalLevel = GetBodyValueLevel(name, item);
                            returndata.kcalLevel = kcal((float)returndata.kcal, dweight, age, sex);
                        }
                        if (name == "vfal")
                        {
                            returndata.visceral = GetBodyValue(name, item).ToDecimal();
                            //returndata.visceralLevel = GetBodyValueLevel(name, item);
                            returndata.visceralLevel = visceral((float)returndata.visceral, dweight, age, sex);
                        }
                        if (name == "bodyage")
                            returndata.bodyage = GetBodyValue(name, item).ToInt();
                        if (name == "bodyscore")
                            returndata.cmi = GetBodyValue(name, item).ToDecimal();
                        if (name == "bodytype")
                        {
                            returndata.body = GetBodyValue(name, item);
                            returndata.bodylevel = returndata.body;
                        }
                        if (name == "idealweightkg")
                            returndata.idealweight = GetBodyValue(name, item).ToDecimal();
                        if (name == "bodyfatkg")
                            returndata.fat_w = GetBodyValue(name, item).ToDecimal();
                        if (name == "bodyfatfreemasskg")
                            returndata.lbm = GetBodyValue(name, item).ToDecimal();
                        if (name == "musclerate")
                        {
                            returndata.muscle = GetBodyValue(name, item).ToDecimal();
                            returndata.muscleLevel = muscle((float)returndata.muscle, (double)weight, age, sex);
                            returndata.musulevalLevel = returndata.muscleLevel;
                        }
                        if (name == "bodyfatsubcutkg")
                            returndata.sfrval = GetBodyValue(name, item).ToDecimal();
                        if (name == "muscleratetrunk")
                            returndata.muscleratetrunk = GetBodyValue(name, item).ToDecimal();
                        if (name == "musclerateleftleg")
                            returndata.musclerateleftleg = GetBodyValue(name, item).ToDecimal();
                        if (name == "muscleraterightleg")
                            returndata.muscleraterightleg = GetBodyValue(name, item).ToDecimal();
                        if (name == "musclerateleftarm")
                            returndata.musclerateleftarm = GetBodyValue(name, item).ToDecimal();
                        if (name == "muscleraterightarm")
                            returndata.muscleraterightarm = GetBodyValue(name, item).ToDecimal();
                        if (name == "bodyfatratetrunk")
                            returndata.bodyfatraterunk = GetBodyValue(name, item).ToDecimal();
                        if (name == "bodyfatrateleftleg")
                            returndata.bodyfatrateleftleg = GetBodyValue(name, item).ToDecimal();
                        if (name == "bodyfatraterightleg")
                            returndata.bodyfatraterightleg = GetBodyValue(name, item).ToDecimal();
                        if (name == "bodyfatrateleftarm")
                            returndata.bodyfatrateleftarm = GetBodyValue(name, item).ToDecimal();
                        if (name == "bodyfatraterightarm")
                            returndata.bodyfatraterightarm = GetBodyValue(name, item).ToDecimal();
                        if (name == "musclekgtrunk")
                            returndata.musclekgtrunk = GetBodyValue(name, item).ToDecimal();
                        if (name == "musclekgleftleg")
                            returndata.musclekgleftleg = GetBodyValue(name, item).ToDecimal();
                        if (name == "musclekgrightleg")
                            returndata.musclekgrightleg = GetBodyValue(name, item).ToDecimal();
                        if (name == "musclekgleftarm")
                            returndata.musclekgleftarm = GetBodyValue(name, item).ToDecimal();
                        if (name == "musclekgrightarm")
                            returndata.musclekgrightarm = GetBodyValue(name, item).ToDecimal();
                        if (name == "bodyfatkgtrunk")
                            returndata.bodyfatkgtrunk = GetBodyValue(name, item).ToDecimal();
                        if (name == "bodyfatkgleftleg")
                            returndata.bodyfatkgleftleg = GetBodyValue(name, item).ToDecimal();
                        if (name == "bodyfatkgrightleg")
                            returndata.bodyfatkgrightleg = GetBodyValue(name, item).ToDecimal();
                        if (name == "bodyfatkgleftarm")
                            returndata.bodyfatkgleftarm = GetBodyValue(name, item).ToDecimal();
                        if (name == "bodyfatkgrightarm")
                            returndata.bodyfatkgrightarm = GetBodyValue(name, item).ToDecimal();
                    }
                    //returndata.bmiLevel = bmi(returndata.bmi.ToFloat());
                    //returndata.muscleLevel = muscle(returndata.muscle.ToFloat(), returndata.weight.ToFloat(), age, sex);
                    //returndata.fat_rLevel = Fat_r(returndata.fat_r.ToFloat(), sex, age);
                    //returndata.fat_wLevel = Fat_r(returndata.fat_r.ToFloat(), sex, age);
                    //returndata.waterLevel = water(returndata.water.ToFloat(), returndata.weight.ToFloat(), age, sex);
                    //returndata.proteinLevel = protein(returndata.protein.ToFloat(), returndata.weight.ToFloat(), age, sex);
                    //returndata.boneLevel = bone(returndata.bone.ToFloat(), returndata.weight.ToFloat(), sex);
                    returndata.bodyageLevel = bodyage(returndata.bodyage.ToInt(), age);
                    //returndata.kcalLevel = kcal(returndata.kcal.ToFloat(), returndata.weight.ToFloat(), age, sex);
                    //returndata.visceralLevel = visceral(returndata.visceral.ToFloat(), returndata.weight.ToFloat(), age, sex);
                    //returndata.sfrLevel = sfr(returndata.sfr.ToFloat(), returndata.weight.ToFloat(), age, sex, height.ToInt());
                    var level = (weight - returndata.idealweight) / returndata.idealweight;
                    returndata.fatLevel = fatlevel(level.ToDouble());
                    return returndata;
                }
            }
            else
            {
                //记录日志
                loggerService.AddLogger($"八电极算法请求失败,参数:{requestdata.ToJson()},错误信息:{returnstr}");
                var returndata = new UserMeasureDto
                {
                    weight = weight,
                    bmi = (((weight / (mheight * mheight)) * 10.0m) / 10.0m).ToDecimal(1),
                    idealweight = standweight(height.ToInt(), sex).ToDecimal(2),
                    height = height
                };
                returndata.bmiLevel = bmi(returndata.bmi.ToFloat());
                returndata.cmi = score(returndata.bmi.ToFloat()).ToDecimal(1);
                decimal levels = (weight - returndata.idealweight) / returndata.idealweight;
                returndata.fatLevel = fatlevel(levels.ToDouble());
                return returndata;
            }
        }
        /// <summary>
        /// 获取八电极每项值
        /// </summary>
        /// <param name="name"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        private static string GetBodyValue(string name, BodyResponseData data)
            => (name, data) switch
            {
                _ when name == "exerciseplanner" => data.value == null ? "" : data.value.ToString(), //训练计划
                _ => data.value == null?"": data.value.ToString()
            };
        /// <summary>
        /// 获取八电极每项值的标准
        /// </summary>
        /// <param name="name"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        private static string GetBodyValueLevel(string name, BodyResponseData data)
           => (name, data) switch
           {
               _ when name == "exerciseplanner" => "", //训练计划
               _ => data.level.value.ToString().Length == 1 ? $"偏{data.level.value}" : data.level.value.ToString()
           };

        /// <summary>
        /// 身体得分
        /// </summary>
        /// <param name="bmi"></param>
        /// <returns></returns>
        public static double score(float bmi)
            => bmi switch
            {
                _ when bmi < 21.6 => bmi / 21.6 * 100,
                _ when bmi >= 21.6 => 21.6 / bmi * 100,
                _ => 60
            };


        /// <summary>
        /// 体型
        /// </summary>
        /// <param name="fat_r">体脂率</param>
        /// <param name="muscle">肌肉率</param>
        /// <returns></returns>
        public static string body(string fat_r, string muscle)
          => (fat_r, muscle) switch
          {
              _ when fat_r == NewLevelModel.Error || muscle == NewLevelModel.Error => NewLevelModel.Error,
              _ when (fat_r == NewLevelModel.high || fat_r == NewLevelModel.mhigh) && muscle == NewLevelModel.notenu => NewLevelModel.hidefat,
              _ when (fat_r == NewLevelModel.high || fat_r == NewLevelModel.mhigh) && muscle == NewLevelModel.normal => NewLevelModel.fat,
              _ when (fat_r == NewLevelModel.high || fat_r == NewLevelModel.mhigh) && muscle == NewLevelModel.fine => NewLevelModel.strongfat,
              _ when (fat_r == NewLevelModel.normal) && muscle == NewLevelModel.notenu => NewLevelModel.notenumuscle,
              _ when (fat_r == NewLevelModel.normal) && muscle == NewLevelModel.normal => NewLevelModel.normalfat,
              _ when (fat_r == NewLevelModel.normal) && muscle == NewLevelModel.fine => NewLevelModel.normalmuscle,
              _ when (fat_r == NewLevelModel.flat) && muscle == NewLevelModel.notenu => NewLevelModel.thin,
              _ when (fat_r == NewLevelModel.flat) && muscle == NewLevelModel.normal => NewLevelModel.thinmuscle,
              _ when (fat_r == NewLevelModel.flat) && muscle == NewLevelModel.fine => NewLevelModel.perfetmuscle,
              _ => NewLevelModel.hidefat
          };

        /// <summary>
        /// 肥胖等级
        /// </summary>
        /// <param name="level">level=(体重-标准体重)/标准体重</param>
        /// <returns></returns>
        public string fatlevel(double level)
            => level switch
            {
                _ when level < -0.2 => NewLevelModel.weightnotenu,
                _ when level >= -0.2 && level < -0.1 => NewLevelModel.thin,
                _ when level >= -0.1 && level <= 0.1 => NewLevelModel.normal,
                _ when level > 0.1 && level <= 0.2 => NewLevelModel.weight,
                _ when level > 0.2 => NewLevelModel.mweight,
                _ => NewLevelModel.weightnotenu
            };

        /// <summary>
        /// 皮下脂肪标准
        /// </summary>
        /// <param name="sfr"></param>
        /// <param name="weight"></param>
        /// <param name="age"></param>
        /// <param name="sex"></param>
        /// <returns></returns>
        public static string sfr(float sfr, double weight, int age, int sex)
           => (weight, age, sex) switch
           {
               _ when sfr <= 0 => NewLevelModel.Error,
               _ when sex == 1 && sfr < 7 => NewLevelModel.notenu,
               _ when sex == 0 && sfr < 11 => NewLevelModel.notenu,
               _ when sex == 1 && sfr >= 7 && sfr < 15 => NewLevelModel.normal,
               _ when sex == 0 && sfr >= 11 && sfr < 17 => NewLevelModel.normal,
               _ when sex == 1 && sfr >= 15 => NewLevelModel.high,
               _ when sex == 0 && sfr >= 17 => NewLevelModel.high,
               _ => NewLevelModel.notenu
           };


        /// <summary>
        /// 标准体重
        /// </summary>
        /// <param name="height"></param>
        /// <param name="sex">性别,0-女,1-男</param>
        /// <returns></returns>
        public double standweight(int height, int sex)
            => (height, sex) switch
            {
                _ when sex == 1 => (height - 80) * 0.7,
                _ => (height - 70) * 0.6
            };
        /// <summary>
        /// 标准体重计算
        /// </summary>
        /// <param name="height">身高,厘米</param>
        /// <param name="sex">性别,1-男,2-女</param>
        /// <returns></returns>
        public decimal CalcStandWeight(decimal height, int sex)
        {
            decimal standheight = 0;
            if (sex == 1)
            {
                standheight = (height - 80.0m) * 0.7m;
            }
            else
            {
                standheight = (height - 70.0m) * 0.6m;
            }
            return standheight < 0 ? 0 : standheight.ToDecimal(1);
        }

        /// <summary>
        /// 体重标准
        /// </summary>
        /// <param name="weight"></param>
        /// <param name="age"></param>
        /// <param name="sex"></param>
        /// <param name="height"></param>
        /// <returns></returns>
        public static string weight(double weight, int age, int sex, int height)
         => (weight, age, sex, height) switch
         {
             _ when weight < 18.5 * Math.Pow(height / 100, 2) => NewLevelModel.thin,
             _ when weight >= 18.5 * Math.Pow(height / 100, 2) && weight < 25 * Math.Pow(height / 100, 2) => NewLevelModel.normal,
             _ when weight >= 25 * Math.Pow(height / 100, 2) && weight < 30 * Math.Pow(height / 100, 2) => NewLevelModel.fat,
             _ when weight >= 30 * Math.Pow(height / 100, 2) => NewLevelModel.mfat,
             _ => NewLevelModel.thin
         };

        /// <summary>
        /// bmi标准
        /// </summary>
        /// <param name="bmi"></param>
        /// <param name="weight"></param>
        /// <param name="age"></param>
        /// <param name="sex"></param>
        /// <param name="height"></param>
        /// <returns></returns>
        public static string bmi(float bmi, double weight, int age, int sex, int height)
          => (weight, age, sex) switch
          {
              _ when bmi < 18.5 => NewLevelModel.thin,
              _ when bmi >= 18.5 && bmi < 25 => NewLevelModel.normal,
              _ when bmi >= 25 && bmi < 30 => NewLevelModel.fat,
              _ when bmi >= 30 => NewLevelModel.mfat,
              _ => NewLevelModel.thin
          };

        /// <summary>
        /// 水份标准
        /// </summary>
        /// <param name="water"></param>
        /// <param name="weight"></param>
        /// <param name="age"></param>
        /// <param name="sex"></param>
        /// <returns></returns>
        public static string water(float water, double weight, int age, int sex)
         => (water, weight, age, sex) switch
         {
             _ when water <= 0 => NewLevelModel.Error,
             _ when sex == 1 && water < 55 => NewLevelModel.notenu,
             _ when sex == 0 && water < 45 => NewLevelModel.notenu,
             _ when sex == 1 && water < 65 && water >= 55 => NewLevelModel.normal,
             _ when sex == 0 && water < 60 && water >= 45 => NewLevelModel.normal,
             _ when sex == 1 && water >= 65 => NewLevelModel.fine,
             _ when sex == 0 && water >= 60 => NewLevelModel.fine,
             _ => NewLevelModel.notenu
         };


        /// <summary>
        /// 内脂标准
        /// </summary>
        /// <param name="visceral"></param>
        /// <param name="weight"></param>
        /// <param name="age"></param>
        /// <param name="sex"></param>
        /// <returns></returns>

        public static string visceral(float visceral, double weight, int age, int sex)
         => (visceral, weight, age, sex) switch
         {
             _ when visceral <= 0 => NewLevelModel.Error,
             _ when visceral < 9 && visceral > 0 => NewLevelModel.normal,
             _ when visceral < 14 && visceral >= 9 => NewLevelModel.alert,
             _ when visceral >= 14 => NewLevelModel.danger,
             _ => NewLevelModel.Error
         };

        /// <summary>
        /// 蛋白质标准
        /// </summary>
        /// <param name="protein"></param>
        /// <param name="weight"></param>
        /// <param name="age"></param>
        /// <param name="sex"></param>
        /// <returns></returns>

        public static string protein(float protein, double weight, int age, int sex)
          => (protein, weight, age, sex) switch
          {
              _ when protein <= 0 => NewLevelModel.Error,
              _ when sex == 1 && protein < 16 => NewLevelModel.notenu,
              _ when sex == 0 && protein < 14 => NewLevelModel.notenu,
              _ when sex == 1 && protein >= 16 && protein < 18 => NewLevelModel.normal,
              _ when sex == 0 && protein >= 14 && protein < 16 => NewLevelModel.normal,
              _ when sex == 1 && protein >= 18 => NewLevelModel.fine,
              _ when sex == 0 && protein >= 16 => NewLevelModel.fine,
              _ => NewLevelModel.notenu
          };

        /// <summary>
        /// 肌肉率标准
        /// </summary>
        /// <param name="muscle"></param>
        /// <param name="weight"></param>
        /// <param name="age"></param>
        /// <param name="sex"></param>
        /// <returns></returns>
        public static string muscle(float muscle, double weight, int age, int sex)
           => (muscle, weight, age, sex) switch
           {
               _ when muscle <= 0 => NewLevelModel.Error,
               _ when sex == 1 && muscle < 40 => NewLevelModel.notenu,
               _ when sex == 0 && muscle < 30 => NewLevelModel.notenu,
               _ when sex == 1 && muscle >= 40 && muscle < 60 => NewLevelModel.normal,
               _ when sex == 0 && muscle >= 30 && muscle < 50 => NewLevelModel.normal,
               _ when sex == 1 && muscle >= 60 => NewLevelModel.fine,
               _ when sex == 0 && muscle >= 50 => NewLevelModel.fine,
               _ => NewLevelModel.notenu
           };

        /// <summary>
        /// 基础代谢计算标准
        /// </summary>
        /// <param name="kcal"></param>
        /// <param name="weight"></param>
        /// <param name="age"></param>
        /// <param name="sex"></param>
        /// <returns></returns>
        public static string kcal(float kcal, double weight, int age, int sex)
            => (kcal, weight, age, sex) switch
            {
                _ when kcal <= 0 => NewLevelModel.Error,
                _ when age > 0 && age < 3 && ((kcal < (60.9 * weight - 54) && sex == 1) || (kcal < (61.0 * weight - 51) && sex == 0)) => NewLevelModel.flat,
                _ when age > 0 && age < 3 && ((kcal >= (60.9 * weight - 54) && sex == 1) || (kcal >= (61.0 * weight - 51) && sex == 0)) => NewLevelModel.fine,
                _ when age >= 3 && age < 10 && ((kcal < (22.7 * weight + 495) && sex == 1) || (kcal < (22.5 * weight + 499) && sex == 0)) => NewLevelModel.flat,
                _ when age >= 3 && age < 10 && ((kcal >= (22.7 * weight + 495) && sex == 1) || (kcal >= (22.5 * weight + 499) && sex == 0)) => NewLevelModel.fine,
                _ when age >= 10 && age < 18 && ((kcal < (17.5 * weight + 651) && sex == 1) || (kcal < (12.2 * weight + 746) && sex == 0)) => NewLevelModel.flat,
                _ when age >= 10 && age < 18 && ((kcal >= (17.5 * weight + 651) && sex == 1) || (kcal >= (12.2 * weight + 746) && sex == 0)) => NewLevelModel.fine,
                _ when age >= 18 && age < 30 && ((kcal < (15.3 * weight + 679) && sex == 1) || (kcal < (14.7 * weight + 496) && sex == 0)) => NewLevelModel.flat,
                _ when age >= 18 && age < 30 && ((kcal >= (15.3 * weight + 679) && sex == 1) || (kcal >= (14.7 * weight + 496) && sex == 0)) => NewLevelModel.fine,
                _ when age >= 30 && ((kcal < (11.6 * weight + 879) && sex == 1) || (kcal < (8.7 * weight + 820) && sex == 0)) => NewLevelModel.flat,
                _ when age >= 30 && ((kcal >= (11.6 * weight + 879) && sex == 1) || (kcal >= (8.7 * weight + 820) && sex == 0)) => NewLevelModel.fine,
                _ => NewLevelModel.flat
            };

        /// <summary>
        /// 骨重标准
        /// </summary>
        /// <param name="bone">骨重</param>
        /// <param name="weight"></param>
        /// <param name="sex"></param>
        /// <returns></returns>
        public static string bone(float bone, double weight, int sex)
            => (bone, weight, sex) switch
            {
                _ when bone <= 0 => NewLevelModel.Error,
                _ when sex == 1 && ((weight < 60 && bone < 2.4) || (weight >= 60 && weight < 75 && bone < 2.8) || (weight >= 75 && bone < 3.1)) => NewLevelModel.notenu,
                _ when sex == 0 && ((weight < 45 && bone < 1.7) || (weight >= 45 && weight < 60 && bone < 2.1) || (weight >= 60 && bone < 2.4)) => NewLevelModel.notenu,
                _ when sex == 1 && ((weight < 60 && bone >= 2.4 && bone <= 2.6) || (weight >= 60 && weight < 75 && bone >= 2.8 && bone <= 30) || (weight >= 75 && bone >= 3.1 && bone <= 3.3)) => NewLevelModel.normal,
                _ when sex == 0 && ((weight < 45 && bone >= 1.7 && bone <= 1.9) || (weight >= 45 && weight < 60 && bone <= 2.3 && bone >= 2.1) || (weight >= 60 && bone <= 2.6 && bone >= 2.4)) => NewLevelModel.normal,
                _ when sex == 1 && ((weight < 60 && bone > 2.6) || (weight >= 60 && weight < 75 && bone > 3.0) || (weight >= 75 && bone > 3.3)) => NewLevelModel.fine,
                _ when sex == 0 && ((weight < 45 && bone > 1.9) || (weight >= 45 && weight < 60 && bone > 2.3) || (weight >= 60 && bone > 2.6)) => NewLevelModel.fine,
                _ => NewLevelModel.notenu
            };

        /// <summary>
        /// 体龄计算方法
        /// </summary>
        /// <param name="bodyage"></param>
        /// <param name="age"></param>
        /// <returns></returns>
        public static string bodyage(int bodyage, int age)
            => (bodyage, age) switch
            {
                _ when bodyage > age => NewLevelModel.big,
                _ when bodyage == age => NewLevelModel.normal,
                _ when bodyage <= 0 => NewLevelModel.Error,
                _ => NewLevelModel.fine
            };

        /// <summary>
        /// bmi 计算标准
        /// </summary>
        /// <param name="bmi">BMI</param>
        /// <returns></returns>
        public static string bmi(float bmi)
            => bmi switch
            {
                _ when bmi < 18.5 && bmi > 0 => BMILevelConst.Thin,
                _ when bmi >= 18.5 && bmi < 25 => BMILevelConst.Normal,
                _ when bmi >= 25 && bmi < 30 => BMILevelConst.OverWeight,
                _ when bmi >= 30 && bmi <= 50 => BMILevelConst.Fat,
                _ => LevelConst.Error
            };

        /// <summary>
        /// 脂肪率标准计算
        /// </summary>
        /// <param name="fat_r">脂肪率</param>
        /// <param name="sex">0-女,1-男</param>
        /// <param name="age">年龄</param>
        /// <returns></returns>
        public static string Fat_r(float fat_r, int sex, int age)
            => (fat_r, sex, age) switch
            {
                _ when sex == 1 && age < 30 && fat_r < 10 && fat_r > 0 => NewLevelModel.flat,
                _ when sex == 1 && age >= 30 && fat_r < 11 && fat_r > 0 => NewLevelModel.flat,
                _ when sex == 0 && age < 30 && fat_r < 20 && fat_r > 0 => NewLevelModel.flat,
                _ when sex == 0 && age >= 30 && fat_r < 21 && fat_r > 0 => NewLevelModel.flat,
                _ when sex == 1 && age < 30 && fat_r >= 10 && fat_r < 21 => NewLevelModel.normal,
                _ when sex == 1 && age >= 30 && fat_r >= 11 && fat_r < 22 => NewLevelModel.normal,
                _ when sex == 0 && age < 30 && fat_r >= 20 && fat_r < 31 => NewLevelModel.normal,
                _ when sex == 0 && age >= 30 && fat_r >= 21 && fat_r < 32 => NewLevelModel.normal,
                _ when sex == 1 && age < 30 && fat_r > 21 && fat_r < 26 => NewLevelModel.high,
                _ when sex == 1 && age >= 30 && fat_r >= 22 && fat_r < 27 => NewLevelModel.high,
                _ when sex == 0 && age < 30 && fat_r >= 31 && fat_r < 38 => NewLevelModel.high,
                _ when sex == 0 && age >= 30 && fat_r >= 32 && fat_r < 39 => NewLevelModel.high,
                _ when sex == 1 && age < 30 && fat_r >= 26 && fat_r <= 80 => NewLevelModel.mhigh,
                _ when sex == 1 && age >= 30 && fat_r >= 27 && fat_r <= 80 => NewLevelModel.mhigh,
                _ when sex == 0 && age < 30 && fat_r >= 38 && fat_r <= 80 => NewLevelModel.mhigh,
                _ when sex == 0 && age >= 30 && fat_r >= 39 && fat_r <= 80 => NewLevelModel.mhigh,
                _ => NewLevelModel.Error
            };
        /// <summary>
        /// 儿童BMI标准
        /// </summary>
        /// <param name="sex">性别,1-男,2-女</param>
        /// <param name="month">月龄</param>
        /// <param name="bmivalue">BMI值</param>
        /// <returns></returns>
        public string ChildBmiLevel(int sex, int month, decimal bmivalue)
            => (sex, month, bmivalue) switch
            {
                (1, >= 36 and < 42, <= 13.7m)
 or (2, >= 36 and < 42, <= 13.4m)
 or (1, >= 42 and < 48, <= 13.6m)
 or (2, >= 42 and < 48, <= 13.3m)
 or (1, >= 48 and < 54, <= 13.5m)
 or (2, >= 48 and < 54, <= 13.2m)
 or (1, >= 54 and < 60, <= 13.4m)
 or (2, >= 54 and < 60, <= 13.1m)
 or (1, >= 60 and < 66, <= 13.5m)
 or (2, >= 60 and < 66, <= 13.2m)
 or (1, >= 66 and < 72, <= 13.4m)
 or (2, >= 66 and < 72, <= 13.1m)
 or (1, >= 72 and < 78, <= 13.4m)
 or (2, >= 72 and < 78, <= 13.1m)
 or (1, >= 78 and < 84, <= 13.7m)
 or (2, >= 78 and < 84, <= 13.3m)
 or (1, >= 84 and < 90, <= 13.9m)
 or (2, >= 84 and < 90, <= 13.4m)
 or (1, >= 90 and < 96, <= 13.9m)
 or (2, >= 90 and < 96, <= 13.5m)
 or (1, >= 96 and < 102, <= 14m)
 or (2, >= 96 and < 102, <= 13.6m)
 or (1, >= 102 and < 108, <= 14m)
 or (2, >= 102 and < 108, <= 13.7m)
 or (1, >= 108 and < 114, <= 14.1m)
 or (2, >= 108 and < 114, <= 13.8m)
 or (1, >= 114 and < 120, <= 14.2m)
 or (2, >= 114 and < 120, <= 13.9m)
 or (1, >= 120 and < 126, <= 14.4m)
 or (2, >= 120 and < 126, <= 14m)
 or (1, >= 126 and < 132, <= 14.8m)
 or (2, >= 126 and < 132, <= 14.2m)
 or (1, >= 132 and < 138, <= 14.9m)
 or (2, >= 132 and < 138, <= 14.3m)
 or (1, >= 138 and < 144, <= 15.3m)
 or (2, >= 138 and < 144, <= 14.6m)
 or (1, >= 144 and < 150, <= 15.4m)
 or (2, >= 144 and < 150, <= 14.7m)
 or (1, >= 150 and < 156, <= 15.7m)
 or (2, >= 150 and < 156, <= 15.1m)
 or (1, >= 156 and < 162, <= 15.9m)
 or (2, >= 156 and < 162, <= 15.3m)
 or (1, >= 162 and < 168, <= 16.3m)
 or (2, >= 162 and < 168, <= 15.5m)
 or (1, >= 168 and < 174, <= 16.4m)
 or (2, >= 168 and < 174, <= 16m)
 or (1, >= 174 and < 180, <= 16.7m)
 or (2, >= 174 and < 180, <= 16.2m)
 or (1, >= 180 and < 186, <= 16.9m)
 or (2, >= 180 and < 186, <= 16.6m)
 or (1, >= 186 and < 192, <= 17.1m)
 or (2, >= 186 and < 192, <= 16.8m)
 or (1, >= 192 and < 198, <= 17.3m)
 or (2, >= 192 and < 198, <= 17m)
  => BMILevel.Thin,
                (1, >= 36 and < 42, > 13.7m and <= 16.8m)
                or (2, >= 36 and < 42, > 13.4m and <= 16.5m)
                or (1, >= 42 and < 48, > 13.6m and <= 16.6m)
                or (2, >= 42 and < 48, > 13.3m and <= 16.4m)
                or (1, >= 48 and < 54, > 13.5m and <= 16.5m)
                or (2, >= 48 and < 54, > 13.2m and <= 16.3m)
                or (1, >= 54 and < 60, > 13.4m and <= 16.4m)
                or (2, >= 54 and < 60, > 13.1m and <= 16.2m)
                or (1, >= 60 and < 66, > 13.5m and <= 16.5m)
                or (2, >= 60 and < 66, > 13.2m and <= 16.3m)
                or (1, >= 66 and < 72, > 13.4m and <= 16.4m)
                or (2, >= 66 and < 72, > 13.1m and <= 16.2m)
                or (1, >= 72 and < 78, > 13.4m and <= 16.4m)
                or (2, >= 72 and < 78, > 13.1m and <= 16.2m)
                or (1, >= 78 and < 84, > 13.7m and <= 16.7m)
                or (2, >= 78 and < 84, > 13.3m and <= 16.5m)
                or (1, >= 84 and < 90, > 13.9m and <= 17m)
                or (2, >= 84 and < 90, > 13.4m and <= 16.8m)
                or (1, >= 90 and < 96, > 13.9m and <= 17.4m)
                or (2, >= 90 and < 96, > 13.5m and <= 17.2m)
                or (1, >= 96 and < 102, > 14m and <= 17.8m)
                or (2, >= 96 and < 102, > 13.6m and <= 17.6m)
                or (1, >= 102 and < 108, > 14m and <= 18.1m)
                or (2, >= 102 and < 108, > 13.7m and <= 18.1m)
                or (1, >= 108 and < 114, > 14.1m and <= 18.5m)
                or (2, >= 108 and < 114, > 13.8m and <= 18.5m)
                or (1, >= 114 and < 120, > 14.2m and <= 18.9m)
                or (2, >= 114 and < 120, > 13.9m and <= 19m)
                or (1, >= 120 and < 126, > 14.4m and <= 19.2m)
                or (2, >= 120 and < 126, > 14m and <= 19.5m)
                or (1, >= 126 and < 132, > 14.8m and <= 19.6m)
                or (2, >= 126 and < 132, > 14.2m and <= 20m)
                or (1, >= 132 and < 138, > 14.9m and <= 19.9m)
                or (2, >= 132 and < 138, > 14.3m and <= 20.5m)
                or (1, >= 138 and < 144, > 15.3m and <= 20.3m)
                or (2, >= 138 and < 144, > 14.6m and <= 21.1m)
                or (1, >= 144 and < 150, > 15.4m and <= 20.7m)
                or (2, >= 144 and < 150, > 14.7m and <= 21.5m)
                or (1, >= 150 and < 156, > 15.7m and <= 21m)
                or (2, >= 150 and < 156, > 15.1m and <= 21.9m)
                or (1, >= 156 and < 162, > 15.9m and <= 21.4m)
                or (2, >= 156 and < 162, > 15.3m and <= 22.2m)
                or (1, >= 162 and < 168, > 16.3m and <= 21.9m)
                or (2, >= 162 and < 168, > 15.5m and <= 22.6m)
                or (1, >= 168 and < 174, > 16.4m and <= 22.3m)
                or (2, >= 168 and < 174, > 16m and <= 22.8m)
                or (1, >= 174 and < 180, > 16.7m and <= 22.6m)
                or (2, >= 174 and < 180, > 16.2m and <= 23m)
                or (1, >= 180 and < 186, > 16.9m and <= 22.9m)
                or (2, >= 180 and < 186, > 16.6m and <= 23.2m)
                or (1, >= 186 and < 192, > 17.1m and <= 23.1m)
                or (2, >= 186 and < 192, > 16.8m and <= 23.4m)
                or (1, >= 192 and < 198, > 17.3m and <= 23.3m)
                or (2, >= 192 and < 198, > 17m and <= 23.6m)
                 => BMILevel.Normal,
                (1, >= 36 and < 42, > 16.8m and <= 18.1m)
                or (2, >= 36 and < 42, > 16.5m and <= 18m)
                or (1, >= 42 and < 48, > 16.6m and <= 17.9m)
                or (2, >= 42 and < 48, > 16.4m and <= 17.7m)
                or (1, >= 48 and < 54, > 16.5m and <= 17.8m)
                or (2, >= 48 and < 54, > 16.3m and <= 17.6m)
                or (1, >= 54 and < 60, > 16.4m and <= 17.7m)
                or (2, >= 54 and < 60, > 16.2m and <= 17.5m)
                or (1, >= 60 and < 66, > 16.5m and <= 17.8m)
                or (2, >= 60 and < 66, > 16.3m and <= 17.6m)
                or (1, >= 66 and < 72, > 16.4m and <= 17.7m)
                or (2, >= 66 and < 72, > 16.2m and <= 17.5m)
                or (1, >= 72 and < 78, > 16.4m and <= 17.7m)
                or (2, >= 72 and < 78, > 16.2m and <= 17.5m)
                or (1, >= 78 and < 84, > 16.7m and <= 18.1m)
                or (2, >= 78 and < 84, > 16.5m and <= 18m)
                or (1, >= 84 and < 90, > 17m and <= 18.7m)
                or (2, >= 84 and < 90, > 16.8m and <= 18.5m)
                or (1, >= 90 and < 96, > 17.4m and <= 19.2m)
                or (2, >= 90 and < 96, > 17.2m and <= 19m)
                or (1, >= 96 and < 102, > 17.8m and <= 19.7m)
                or (2, >= 96 and < 102, > 17.6m and <= 19.4m)
                or (1, >= 102 and < 108, > 18.1m and <= 20.3m)
                or (2, >= 102 and < 108, > 18.1m and <= 19.9m)
                or (1, >= 108 and < 114, > 18.5m and <= 20.8m)
                or (2, >= 108 and < 114, > 18.5m and <= 20.4m)
                or (1, >= 114 and < 120, > 18.9m and <= 21.4m)
                or (2, >= 114 and < 120, > 19m and <= 21m)
                or (1, >= 120 and < 126, > 19.2m and <= 21.9m)
                or (2, >= 120 and < 126, > 19.5m and <= 21.5m)
                or (1, >= 126 and < 132, > 19.6m and <= 22.5m)
                or (2, >= 126 and < 132, > 20m and <= 22.1m)
                or (1, >= 132 and < 138, > 19.9m and <= 23m)
                or (2, >= 132 and < 138, > 20.5m and <= 22.7m)
                or (1, >= 138 and < 144, > 20.3m and <= 23.6m)
                or (2, >= 138 and < 144, > 21.1m and <= 23.3m)
                or (1, >= 144 and < 150, > 20.7m and <= 24.1m)
                or (2, >= 144 and < 150, > 21.5m and <= 23.9m)
                or (1, >= 150 and < 156, > 21m and <= 24.7m)
                or (2, >= 150 and < 156, > 21.9m and <= 24.5m)
                or (1, >= 156 and < 162, > 21.4m and <= 25.2m)
                or (2, >= 156 and < 162, > 22.2m and <= 25m)
                or (1, >= 162 and < 168, > 21.9m and <= 25.7m)
                or (2, >= 162 and < 168, > 22.6m and <= 25.6m)
                or (1, >= 168 and < 174, > 22.3m and <= 26.1m)
                or (2, >= 168 and < 174, > 22.8m and <= 25.9m)
                or (1, >= 174 and < 180, > 22.6m and <= 26.4m)
                or (2, >= 174 and < 180, > 23m and <= 26.3m)
                or (1, >= 180 and < 186, > 22.9m and <= 26.6m)
                or (2, >= 180 and < 186, > 23.2m and <= 26.6m)
                or (1, >= 186 and < 192, > 23.1m and <= 26.9m)
                or (2, >= 186 and < 192, > 23.4m and <= 26.9m)
                or (1, >= 192 and < 198, > 23.3m and <= 27.1m)
                or (2, >= 192 and < 198, > 23.6m and <= 27.1m)
                 => BMILevel.OverWeight,
                (1, >= 36 and < 42, > 18.1m and <= 50m)
                or (2, >= 36 and < 42, > 18m and <= 50m)
                or (1, >= 42 and < 48, > 17.9m and <= 50m)
                or (2, >= 42 and < 48, > 17.7m and <= 50m)
                or (1, >= 48 and < 54, > 17.8m and <= 50m)
                or (2, >= 48 and < 54, > 17.6m and <= 50m)
                or (1, >= 54 and < 60, > 17.7m and <= 50m)
                or (2, >= 54 and < 60, > 17.5m and <= 50m)
                or (1, >= 60 and < 66, > 17.8m and <= 50m)
                or (2, >= 60 and < 66, > 17.6m and <= 50m)
                or (1, >= 66 and < 72, > 17.7m and <= 50m)
                or (2, >= 66 and < 72, > 17.5m and <= 50m)
                or (1, >= 72 and < 78, > 17.7m and <= 50m)
                or (2, >= 72 and < 78, > 17.5m and <= 50m)
                or (1, >= 78 and < 84, > 18.1m and <= 50m)
                or (2, >= 78 and < 84, > 18m and <= 50m)
                or (1, >= 84 and < 90, > 18.7m and <= 50m)
                or (2, >= 84 and < 90, > 18.5m and <= 50m)
                or (1, >= 90 and < 96, > 19.2m and <= 50m)
                or (2, >= 90 and < 96, > 19m and <= 50m)
                or (1, >= 96 and < 102, > 19.7m and <= 50m)
                or (2, >= 96 and < 102, > 19.4m and <= 50m)
                or (1, >= 102 and < 108, > 20.3m and <= 50m)
                or (2, >= 102 and < 108, > 19.9m and <= 50m)
                or (1, >= 108 and < 114, > 20.8m and <= 50m)
                or (2, >= 108 and < 114, > 20.4m and <= 50m)
                or (1, >= 114 and < 120, > 21.4m and <= 50m)
                or (2, >= 114 and < 120, > 21m and <= 50m)
                or (1, >= 120 and < 126, > 21.9m and <= 50m)
                or (2, >= 120 and < 126, > 21.5m and <= 50m)
                or (1, >= 126 and < 132, > 22.5m and <= 50m)
                or (2, >= 126 and < 132, > 22.1m and <= 50m)
                or (1, >= 132 and < 138, > 23m and <= 50m)
                or (2, >= 132 and < 138, > 22.7m and <= 50m)
                or (1, >= 138 and < 144, > 23.6m and <= 50m)
                or (2, >= 138 and < 144, > 23.3m and <= 50m)
                or (1, >= 144 and < 150, > 24.1m and <= 50m)
                or (2, >= 144 and < 150, > 23.9m and <= 50m)
                or (1, >= 150 and < 156, > 24.7m and <= 50m)
                or (2, >= 150 and < 156, > 24.5m and <= 50m)
                or (1, >= 156 and < 162, > 25.2m and <= 50m)
                or (2, >= 156 and < 162, > 25m and <= 50m)
                or (1, >= 162 and < 168, > 25.7m and <= 50m)
                or (2, >= 162 and < 168, > 25.6m and <= 50m)
                or (1, >= 168 and < 174, > 26.1m and <= 50m)
                or (2, >= 168 and < 174, > 25.9m and <= 50m)
                or (1, >= 174 and < 180, > 26.4m and <= 50m)
                or (2, >= 174 and < 180, > 26.3m and <= 50m)
                or (1, >= 180 and < 186, > 26.6m and <= 50m)
                or (2, >= 180 and < 186, > 26.6m and <= 50m)
                or (1, >= 186 and < 192, > 26.9m and <= 50m)
                or (2, >= 186 and < 192, > 26.9m and <= 50m)
                or (1, >= 192 and < 198, > 27.1m and <= 50m)
                or (2, >= 192 and < 198, > 27.1m and <= 50m)
                 => BMILevel.Fat,
                _ => bmi((float)bmivalue, 0, 0, 0, 0)
            };
        /// <summary>
        /// 儿童身高标准
        /// </summary>
        /// <param name="sex">性别,1-男,2-女</param>
        /// <param name="month">月龄</param>
        /// <param name="height">身高,cm</param>
        /// <returns></returns>
        public string ChildHeightLevel(int sex, int month, decimal height)
            => (sex, month, height) switch
            {
                _ => HeightLevel.Normal
            };
        /// <summary>
        /// 儿童体重标准
        /// </summary>
        /// <param name="sex">性别,1-男,2-女</param>
        /// <param name="month">月龄</param>
        /// <param name="weight">体重,kg</param>
        /// <returns></returns>
        public string ChildWeightLevel(int sex, int month, decimal weight)
                => (sex, month, weight) switch
                {
                    _ => WeightLevel.Normal
                };

        /// <summary>
        /// 根据等级获取标准颜色
        /// </summary>
        /// <param name="level"></param>
        /// <returns></returns>
        public string GetLevelColor(string level)
            => level switch
            {
                BMILevel.Thin or NewLevelModel.thin or NewLevelModel.notenu or NewLevelModel.flat or HeightLevel.LittleLow or WeightLevel.LittleLow => LevelColor.Thin,
                BMILevel.Normal or NewLevelModel.normal or NewLevelModel.reach or HeightLevel.Normal or WeightLevel.Normal => LevelColor.Normal,
                BMILevel.OverWeight or NewLevelModel.fat or NewLevelModel.high or NewLevelModel.alert or HeightLevel.Low or WeightLevel.Height => LevelColor.OverWeight,
                NewLevelModel.fine or HeightLevel.Height => LevelColor.Fine,
                BMILevel.Fat or NewLevelModel.mfat or NewLevelModel.danger or HeightLevel.MoreLow => LevelColor.Fat,
                _ => LevelColor.Error
            };

        /// <summary>
        /// 获取儿童BMI范围
        /// </summary>
        /// <param name="sex"></param>
        /// <param name="month"></param>
        /// <returns></returns>
        public List<MeasureInfoItemValue> ChildBmiStand(int sex, int month)
            => (sex, month) switch
            {
                (1, >= 36 and < 42) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 13.7m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 16.8m, minvalue = 13.8m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 18.1m, minvalue = 16.8m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 18.1m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (2, >= 36 and < 42) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 13.4m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 16.5m, minvalue = 13.5m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 18m, minvalue = 16.5m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 18m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (1, >= 42 and < 48) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 13.6m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 16.6m, minvalue = 13.7m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 17.9m, minvalue = 16.6m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 17.9m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (2, >= 42 and < 48) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 13.3m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 16.4m, minvalue = 13.4m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 17.7m, minvalue = 16.4m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 17.7m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (1, >= 48 and < 54) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 13.5m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 16.5m, minvalue = 13.6m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 17.8m, minvalue = 16.5m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 17.8m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (2, >= 48 and < 54) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 13.2m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 16.3m, minvalue = 13.3m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 17.6m, minvalue = 16.3m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 17.6m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (1, >= 54 and < 60) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 13.4m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 16.4m, minvalue = 13.5m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 17.7m, minvalue = 16.4m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 17.7m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (2, >= 54 and < 60) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 13.1m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 16.2m, minvalue = 13.2m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 17.5m, minvalue = 16.2m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 17.5m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (1, >= 60 and < 66) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 13.5m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 16.5m, minvalue = 13.6m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 17.8m, minvalue = 16.5m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 17.8m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (2, >= 60 and < 66) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 13.2m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 16.3m, minvalue = 13.3m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 17.6m, minvalue = 16.3m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 17.6m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (1, >= 66 and < 72) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 13.4m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 16.4m, minvalue = 13.5m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 17.7m, minvalue = 16.4m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 17.7m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (2, >= 66 and < 72) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 13.1m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 16.2m, minvalue = 13.2m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 17.5m, minvalue = 16.2m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 17.5m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (1, >= 72 and < 78) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 13.4m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 16.4m, minvalue = 13.5m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 17.7m, minvalue = 16.4m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 17.7m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (2, >= 72 and < 78) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 13.1m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 16.2m, minvalue = 13.2m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 17.5m, minvalue = 16.2m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 17.5m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (1, >= 78 and < 84) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 13.7m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 16.7m, minvalue = 13.8m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 18.1m, minvalue = 16.7m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 18.1m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (2, >= 78 and < 84) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 13.3m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 16.5m, minvalue = 13.4m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 18m, minvalue = 16.5m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 18m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (1, >= 84 and < 90) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 13.9m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 17m, minvalue = 14m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 18.7m, minvalue = 17m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 18.7m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (2, >= 84 and < 90) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 13.4m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 16.8m, minvalue = 13.5m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 18.5m, minvalue = 16.8m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 18.5m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (1, >= 90 and < 96) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 13.9m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 17.4m, minvalue = 14m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 19.2m, minvalue = 17.4m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 19.2m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (2, >= 90 and < 96) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 13.5m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 17.2m, minvalue = 13.6m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 19m, minvalue = 17.2m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 19m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (1, >= 96 and < 102) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 14m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 17.8m, minvalue = 14.1m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 19.7m, minvalue = 17.8m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 19.7m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (2, >= 96 and < 102) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 13.6m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 17.6m, minvalue = 13.7m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 19.4m, minvalue = 17.6m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 19.4m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (1, >= 102 and < 108) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 14m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 18.1m, minvalue = 14.1m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 20.3m, minvalue = 18.1m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 20.3m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (2, >= 102 and < 108) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 13.7m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 18.1m, minvalue = 13.8m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 19.9m, minvalue = 18.1m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 19.9m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (1, >= 108 and < 114) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 14.1m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 18.5m, minvalue = 14.2m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 20.8m, minvalue = 18.5m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 20.8m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (2, >= 108 and < 114) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 13.8m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 18.5m, minvalue = 13.9m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 20.4m, minvalue = 18.5m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 20.4m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (1, >= 114 and < 120) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 14.2m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 18.9m, minvalue = 14.3m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 21.4m, minvalue = 18.9m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 21.4m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (2, >= 114 and < 120) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 13.9m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 19m, minvalue = 14m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 21m, minvalue = 19m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 21m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (1, >= 120 and < 126) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 14.4m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 19.2m, minvalue = 14.5m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 21.9m, minvalue = 19.2m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 21.9m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (2, >= 120 and < 126) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 14m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 19.5m, minvalue = 14.1m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 21.5m, minvalue = 19.5m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 21.5m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (1, >= 126 and < 132) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 14.8m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 19.6m, minvalue = 14.9m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 22.5m, minvalue = 19.6m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 22.5m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (2, >= 126 and < 132) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 14.2m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 20m, minvalue = 14.3m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 22.1m, minvalue = 20m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 22.1m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (1, >= 132 and < 138) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 14.9m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 19.9m, minvalue = 15m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 23m, minvalue = 19.9m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 23m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (2, >= 132 and < 138) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 14.3m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 20.5m, minvalue = 14.4m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 22.7m, minvalue = 20.5m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 22.7m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (1, >= 138 and < 144) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 15.3m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 20.3m, minvalue = 15.4m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 23.6m, minvalue = 20.3m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 23.6m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (2, >= 138 and < 144) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 14.6m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 21.1m, minvalue = 14.7m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 23.3m, minvalue = 21.1m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 23.3m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (1, >= 144 and < 150) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 15.4m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 20.7m, minvalue = 15.5m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 24.1m, minvalue = 20.7m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 24.1m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (2, >= 144 and < 150) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 14.7m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 21.5m, minvalue = 14.8m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 23.9m, minvalue = 21.5m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 23.9m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (1, >= 150 and < 156) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 15.7m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 21m, minvalue = 15.8m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 24.7m, minvalue = 21m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 24.7m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (2, >= 150 and < 156) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 15.1m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 21.9m, minvalue = 15.2m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 24.5m, minvalue = 21.9m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 24.5m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (1, >= 156 and < 162) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 15.9m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 21.4m, minvalue = 16m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 25.2m, minvalue = 21.4m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 25.2m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (2, >= 156 and < 162) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 15.3m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 22.2m, minvalue = 15.4m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 25m, minvalue = 22.2m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 25m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (1, >= 162 and < 168) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 16.3m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 21.9m, minvalue = 16.4m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 25.7m, minvalue = 21.9m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 25.7m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (2, >= 162 and < 168) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 15.5m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 22.6m, minvalue = 15.6m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 25.6m, minvalue = 22.6m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 25.6m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (1, >= 168 and < 174) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 16.4m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 22.3m, minvalue = 16.5m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 26.1m, minvalue = 22.3m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 26.1m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (2, >= 168 and < 174) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 16m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 22.8m, minvalue = 16.1m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 25.9m, minvalue = 22.8m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 25.9m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (1, >= 174 and < 180) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 16.7m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 22.6m, minvalue = 16.8m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 26.4m, minvalue = 22.6m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 26.4m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (2, >= 174 and < 180) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 16.2m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 23m, minvalue = 16.3m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 26.3m, minvalue = 23m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 26.3m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (1, >= 180 and < 186) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 16.9m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 22.9m, minvalue = 17m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 26.6m, minvalue = 22.9m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 26.6m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (2, >= 180 and < 186) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 16.6m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 23.2m, minvalue = 16.7m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 26.6m, minvalue = 23.2m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 26.6m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (1, >= 186 and < 192) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 17.1m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 23.1m, minvalue = 17.2m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 26.9m, minvalue = 23.1m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 26.9m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (2, >= 186 and < 192) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 16.8m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 23.4m, minvalue = 16.9m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 26.9m, minvalue = 23.4m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 26.9m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (1, >= 192 and < 198) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 17.3m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 23.3m, minvalue = 17.4m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 27.1m, minvalue = 23.3m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 27.1m, text = BMILevel.Fat, color = LevelColor.Fat } },
                (2, >= 192 and < 198) => new List<MeasureInfoItemValue> { new MeasureInfoItemValue { maxvalue = 17m, minvalue = 0, text = BMILevel.Thin, color = LevelColor.Thin }, new MeasureInfoItemValue { maxvalue = 23.6m, minvalue = 17.1m, text = BMILevel.Normal, color = LevelColor.Normal }, new MeasureInfoItemValue { maxvalue = 27.1m, minvalue = 23.6m, text = BMILevel.OverWeight, color = LevelColor.OverWeight }, new MeasureInfoItemValue { maxvalue = 50, minvalue = 27.1m, text = BMILevel.Fat, color = LevelColor.Fat } },
                _ => bmi_value(sex, 0)
            };
        /// <summary>
        /// 新的指标标准
        /// </summary>
        public class NewLevelModel
        {
            /// <summary>
            /// 异常值
            /// </summary>
            public const string Error = "异常";
            /// <summary>
            /// 偏大
            /// </summary>
            public const string big = "偏大";

            /// <summary>
            /// 偏瘦
            /// </summary>
            public const string thin = "偏瘦";
            /// <summary>
            /// 标准
            /// </summary>
            public const string normal = "标准";
            /// <summary>
            /// 达标
            /// </summary>
            public const string reach = "达标";
            /// <summary>
            /// 偏胖
            /// </summary>
            public const string fat = "偏胖";
            /// <summary>
            /// 肥胖
            /// </summary>
            public const string mfat = "肥胖";
            /// <summary>
            /// 偏重
            /// </summary>
            public const string weight = "偏重";
            /// <summary>
            /// 超重
            /// </summary>
            public const string mweight = "超重";
            /// <summary>
            /// 不足
            /// </summary>
            public const string notenu = "不足";
            /// <summary>
            /// 体重不足
            /// </summary>
            public const string weightnotenu = "体重不足";
            /// <summary>
            /// 偏高
            /// </summary>
            public const string high = "偏高";
            /// <summary>
            /// 高
            /// </summary>
            public const string mhigh = "超高";

            /// <summary>
            /// 警惕
            /// </summary>
            public const string alert = "警惕";
            /// <summary>
            /// 危险
            /// </summary>
            public const string danger = "危险";
            /// <summary>
            /// 偏低
            /// </summary>
            public const string flat = "偏低";
            /// <summary>
            /// 优
            /// </summary>
            public const string fine = "优秀";
            /// <summary>
            /// 隐形肥胖
            /// </summary>
            public const string hidefat = "隐形肥胖";
            /// <summary>
            /// 结实型偏胖
            /// </summary>
            public const string strongfat = "结实型偏胖";
            /// <summary>
            /// 缺乏肌肉型
            /// </summary>
            public const string notenumuscle = "缺乏肌肉型";
            /// <summary>
            /// 标准型
            /// </summary>
            public const string normalfat = "标准型";
            /// <summary>
            /// 标准肌肉型
            /// </summary>
            public const string normalmuscle = "标准肌肉型";
            /// <summary>
            /// 偏瘦肌肉型
            /// </summary>
            public const string thinmuscle = "偏瘦肌肉型";
            /// <summary>
            /// 健美肌肉型
            /// </summary>
            public const string perfetmuscle = "健美肌肉型";
        }
        /// <summary>
        /// BMI指标标准
        /// </summary>
        public class BMILevel
        {
            /// <summary>
            /// 异常
            /// </summary>
            public const string Error = "异常";
            /// <summary>
            /// 消瘦
            /// </summary>
            public const string Thin = "偏瘦";
            /// <summary>
            /// 正常
            /// </summary>
            public const string Normal = "正常";
            /// <summary>
            /// 超重
            /// </summary>
            public const string OverWeight = "超重";
            /// <summary>
            /// 肥胖
            /// </summary>
            public const string Fat = "肥胖";
        }
        /// <summary>
        /// 身高标准
        /// </summary>
        public class HeightLevel
        {
            /// <summary>
            /// 异常
            /// </summary>
            public const string Error = "异常";
            /// <summary>
            /// 严重偏矮
            /// </summary>
            public const string MoreLow = "严重偏矮";
            /// <summary>
            /// 矮
            /// </summary>
            public const string Low = "矮";
            /// <summary>
            /// 偏矮
            /// </summary>
            public const string LittleLow = "偏矮";
            /// <summary>
            /// 正常
            /// </summary>
            public const string Normal = "正常";
            /// <summary>
            /// 高
            /// </summary>
            public const string Height = "高";
        }
        /// <summary>
        /// 体重标准
        /// </summary>
        public class WeightLevel
        {
            /// <summary>
            /// 异常
            /// </summary>
            public const string Error = "异常";
            /// <summary>
            /// 偏低
            /// </summary>
            public const string LittleLow = "偏低";
            /// <summary>
            /// 正常
            /// </summary>
            public const string Normal = "正常";
            /// <summary>
            /// 偏高
            /// </summary>
            public const string Height = "偏高";
        }

        /// <summary>
        /// 算法返回结果定义
        /// </summary>
        public class BodyfatItem
        {
            /// <summary>
            /// bmi
            /// </summary>
            public string bmi;
            /// <summary>
            /// 骨量
            /// </summary>
            public string bm;
            /// <summary>
            /// 肌肉率
            /// </summary>
            public string rom;
            /// <summary>
            /// 水分
            /// </summary>
            public string moi;
            /// <summary>
            /// 脂肪率
            /// </summary>
            public string bfr;
            /// <summary>
            /// 皮下脂肪率
            /// </summary>
            public string sfr;
            /// <summary>
            /// 骨骼肌率
            /// </summary>
            public string rosm;
            /// <summary>
            /// 蛋白率
            /// </summary>
            public string pp;
            /// <summary>
            /// 内脏脂肪指数
            /// </summary>
            public string uvi;
            /// <summary>
            /// 基础代谢率
            /// </summary>
            public string bmr;
            /// <summary>
            /// 身体年龄
            /// </summary>
            public string physicAge;
            /// <summary>
            /// 体重
            /// </summary>
            public double weight;
            /// <summary>
            /// 身高
            /// </summary>
            public double height;
            /// <summary>
            /// 年龄
            /// </summary>
            public int age;
            /// <summary>
            /// 阻抗
            /// </summary>
            public int adc;
            /// <summary>
            /// 性别,0-女,1-男
            /// </summary>
            public int sex;
        }
        /// <summary>
        /// 盛群八电极算法返回的结果
        /// </summary>
        public class HTBodyFatReturnData : HTBodyFatReturnItem
        {
            /// <summary>
            /// 返回状态
            /// GetBodyFatOk(所有参数有效)
            /// UserZTwoLegsError/UserAgeError/UserGenderError(除BMI及李想体重外都无效)(除BMI及理想体重外都无效)
            /// UserWeightError/UserHeightError(所有参数无效)
            /// </summary>
            public string ErrorType { get; set; }
            /// <summary>
            /// 体脂算法版本号,两位小数
            /// </summary>
            public decimal VersionNumber { get; set; }
            /// <summary>
            /// 更新信息
            /// </summary>
            public string UpdateInfo { get; set; } = "";
            /// <summary>
            /// 脚对脚阻抗值,范围200.0-1200.0
            /// </summary>
            public decimal ZTwoLegs { get; set; }
        }
        /// <summary>
        /// 盛群八电极算法返回的测量结果
        /// </summary>
        public class HTBodyFatReturnItem
        {
            /// <summary>
            /// 理想体重,若体重或身高参数有误,则返回0
            /// </summary>
            public decimal IdealWeightKg { get; set; }
            /// <summary>
            /// 人体质量指数,分辨率0.1，范围10.0-90.0
            /// </summary>
            public decimal BMI { get; set; }
            /// <summary>
            /// 人体质量标准,有三个uansu,分别对应,瘦-普通,普通-偏胖,偏胖-肥胖的分界值
            /// </summary>
            public List<decimal> BMIRatingList { get; set; }
            /// <summary>
            /// 基础代谢,分辨率1,范围500-10000
            /// </summary>
            public int BMR { get; set; }
            /// <summary>
            /// 基础代谢健康标准,需先调用BMR()，一个元素，对应"偏低－达标"的分界值
            /// </summary>
            public List<int> BMRRatingList { get; set; }
            /// <summary>
            /// 脂肪率(%), 分辨率0.1, 范围5.0% ~ 75.0%
            /// </summary>
            public decimal BodyfatPercentage { get; set; }
            /// <summary>
            /// 脂肪率健康标准，需先调用BodyfatPercentage()，返回的数组有四个元素，对应"偏瘦－标准"、“标准－警惕”、“警惕－偏胖”、“偏胖－肥胖”的分界值
            /// </summary>
            public List<decimal> BodyfatRatingList { get; set; }
            /// <summary>
            /// 骨量(kg), 分辨率0.1, 范围0.5 ~ 8.0
            /// </summary>
            public decimal BoneKg { get; set; }
            /// <summary>
            /// 骨量等级标准,需先调用BoneKg()，两个元素，对应"不足－标准"、“标准－优秀”的分界值
            /// </summary>
            public List<decimal> BoneRatingList { get; set; }
            /// <summary>
            /// 肌肉量(kg), 分辨率0.1, 范围10.0 ~ 120.0
            /// </summary>
            public decimal Muscle { get; set; }
            /// <summary>
            /// 肌肉量健康标准，需先调用Muscle()，两个元素，对应"不足－标准"、“标准－优秀”的分界值
            /// </summary>
            public List<decimal> MuscleRatingList { get; set; }
            /// <summary>
            /// 内脏脂肪, 分辨率1, 范围1 ~ 6
            /// </summary>
            public int VFAL { get; set; }
            /// <summary>
            /// 内脏脂肪等级标准,两个元素，对应"标准-警惕"、"警惕-危险"的分界值
            /// </summary>
            public List<int> VFALRatingList { get; set; }
            /// <summary>
            /// 水分率(%), 分辨率0.1, 范围35.0% ~ 75.0%
            /// </summary>
            public decimal WaterPercentage { get; set; }
            /// <summary>
            /// 水分率健康标准，两个元素，对应"不足－标准"、“标准－优秀”
            /// </summary>
            public List<decimal> WaterRatingList { get; set; }
            /// <summary>
            /// 体龄
            /// </summary>
            public int BodyAge { get; set; }
            /// <summary>
            /// ProteinPercentage
            /// </summary>
            public decimal ProteinPercentage { get; set; }
            /// <summary>
            /// 蛋白质健康标准，两个元素，对应"不足－标准"、“标准－优秀”
            /// </summary>
            public List<decimal> ProteinRatingList { get; set; }
        }

        /// <summary>
        /// 计算算法
        /// </summary>
        /// <param name="weight"></param>
        /// <param name="height"></param>
        /// <param name="age"></param>
        /// <param name="adc"></param>
        /// <param name="sex"></param>
        /// <returns></returns>
        public static BodyfatItem GetBodyfatResults(double weight, double height, int age, int adc, int sex)
        {
            BodyfatItem bodyfatItem = new BodyfatItem();
            double mheight = height / 100;//米为单位的身高
            if ((weight <= 0.0) || (weight > 220.0) || (height <= 0.0) || (height > 270.0) || (age <= 0) || (age > 120) || (adc <= 0) || (adc > 0x3e8) || (sex < 0) || (sex > 1))
            {
                object[] arg = new object[] { weight, height, age, adc, sex };
                if (weight != 0 && height != 0)
                    bodyfatItem.bmi = (((double)((int)((weight / (mheight * mheight)) * 10.0))) / 10.0).ToString("0.0");
                return bodyfatItem;
            }
            double num = (double)(int)(weight / (mheight * mheight) * 10.0) / 10.0;
            double num2 = 0.0;
            double num3 = 0.0;
            double num4 = 0.0;
            double num5 = 0.0;
            double num6 = 0.0;
            double num7 = 0.0;
            double num8 = 0.0;
            double num9 = 0.0;
            double num10 = 0.0;
            double num11 = 0.0;
            if (sex == 1)
            {
                num2 = 0.015 * weight + (2.0 - 0.00055 * (double)adc) * height / 100.0 - 1.15;
                num3 = (0.0 - (0.00115 * (double)adc + 0.01)) * weight + (49.64 - 0.031 * (double)adc) * height / 100.0 + (double)adc * 0.08 + (double)age * 0.04 + 15.4;
                num4 = 1000000.0 / (num * (2.688 * (double)adc - 78.28)) - (double)(10058 / adc) - 0.22 * (double)age + 52.6;
                num5 = -930000.0 / num / (1.966 * (double)adc - 58.46) + (double)(13176 / adc) - 0.06 * (double)age + 40.0;
                num6 = 0.898 * num5;
                num7 = 0.895 * num4;
                num8 = 0.8 * (100.0 - num5 - num4 - num2 / weight);
                num9 = 0.304 * weight - 25.58 * height / 100.0 + 0.131 * (double)age + 0.005 * (double)adc + 22.0;
                num10 = (9.0 + 0.0015 * (double)adc) * weight + (1350.0 - 0.88 * (double)adc) * height / 100.0 + (double)(188 / age) + 0.748 * (double)adc - 1053.0;
                num11 = (double)age * (1.0 + 0.012 * (num - 1.0)) - 21.0 + (double)(30 - age) * 0.35 + (double)(adc - 450) * 0.02 + 11.0;
            }
            else
            {
                num2 = 2.2E-05 * (double)adc * weight + (4.99 - 0.00284 * (double)adc) * height / 100.0 + 0.0012 * (double)adc - 4.45;
                num3 = (0.0 - (0.00115 * (double)adc + 0.01)) * weight + (49.64 - 0.031 * (double)adc) * height / 100.0 + (double)adc * 0.08 + (double)age * 0.04 + 6.0;
                num4 = 1000000.0 / (num * (2.467 * (double)adc - 75.37)) - (double)(14215 / adc) - 0.034 * (double)age + 43.2;
                num5 = -3030000.0 / (num + 20.0) / (1.966 * (double)adc - 58.46) + (double)(28176 / adc) - 0.06 * (double)age + 51.0;
                num6 = 0.876 * num5 + 1.66;
                num7 = 0.857 * num4 - 0.36;
                num8 = 0.75 * (100.0 - num5 - num4 - num2 / weight);
                num9 = 0.304 * weight - 25.58 * height / 100.0 + 0.131 * (double)age + 0.005 * (double)adc + 22.0;
                num10 = (0.00307 * (double)adc + 1.5) * weight + (1459.0 - 0.989 * (double)adc) * height / 100.0 + (double)age * 0.9 + 0.923 * (double)adc - 950.0;
                num11 = (double)age * (0.95 + 0.02 * (num - 21.2)) + (double)(adc - 500) * 0.02;
            }
            bodyfatItem.bmi = num.ToString("0.0");
            num2 = ((num2 > weight * 0.15) ? (weight * 0.15) : num2);
            bodyfatItem.bm = ((num2 < weight * 0.02) ? (weight * 0.02) : num2).ToString("0.0");
            num3 = ((num3 > 75.0) ? 75.0 : num3);
            bodyfatItem.rom = ((num3 < 15.0) ? 15.0 : num3).ToString("0.0");
            num4 = ((num4 > 70.0) ? 70.0 : num4);
            bodyfatItem.moi = ((num4 < 20.0) ? 20.0 : num4).ToString("0.0");
            num5 = ((num5 > 50.0) ? 50.0 : num5);
            bodyfatItem.bfr = ((num5 < 5.0) ? 5.0 : num5).ToString("0.0");
            bodyfatItem.sfr = num6 <= 0 ? "0" : num6.ToString("0.0");
            bodyfatItem.rosm = num7.ToString("0.0");
            num8 = ((num8 > 50.0) ? 50.0 : num8);
            bodyfatItem.pp = ((num8 < 10.0) ? 10.0 : num8).ToString("0.0");
            num9 = ((num9 > 20.0) ? 20.0 : num9);
            bodyfatItem.uvi = ((num9 < 1.0) ? 1.0 : num9).ToString("0");
            bodyfatItem.bmr = num10 <= 0 ? "0" : num10.ToString("0");
            if (age < 18)
            {
                num11 = age;
            }
            else
            {
                num11 = ((num11 > (double)(age + 10)) ? ((double)(age + 10)) : num11);
                num11 = ((num11 < (double)(age - 10)) ? ((double)(age - 10)) : num11);
            }
            bodyfatItem.physicAge = num11.ToString("0");
            bodyfatItem.weight = weight;
            bodyfatItem.height = height;
            bodyfatItem.age = age;
            bodyfatItem.adc = adc;
            bodyfatItem.sex = sex;
            return bodyfatItem;
        }

        /// <summary>
        /// 计算算法
        /// </summary>
        /// <param name="weight"></param>
        /// <param name="height"></param>
        /// <param name="age"></param>
        /// <param name="adc"></param>
        /// <param name="sex"></param>
        /// <returns></returns>

        public static BodyfatItem Old_GetBodyfatResults(double weight, double height, int age, int adc, int sex)
        {
            BodyfatItem item = new BodyfatItem();
            if ((weight <= 0.0) || ((weight > 220.0) || ((height <= 0.0) || ((height > 270.0) || ((age <= 0) || ((age > 120) || ((adc <= 0) || ((adc > 0x3e8) || ((sex < 0) || (sex > 1))))))))))
            {
                object[] arg = new object[] { weight, height, age, adc, sex };
                Console.WriteLine("[input params invalid] weight:{0} height:{1} age:{2} adc:{3} sex:{4}", arg);
                if (weight != 0 && height != 0)
                    item.bmi = (((double)((int)((weight / (height * height)) * 10.0))) / 10.0).ToString("0.0");
                return item;
            }
            double bmi = ((double)((int)((weight / (height * height)) * 10.0))) / 10.0;
            double bm = 0.0;//骨量
            double rom = 0.0;//肌肉率
            double moi = 0.0;//水份
            double bfr = 0.0;//脂肪率
            double sfr = 0.0;//皮下脂肪率
            double rosm = 0.0;//骨骼肌率
            double pp = 0.0;//蛋白率
            double uvi = 0.0;//内脏脂肪指数
            double bmr = 0.0;//基础代谢率
            double physicAge = 0.0;//身体年龄
            if (sex == 1)
            {
                bm = ((0.015 * weight) + (((2.0 - (0.00055 * adc)) * height) / 100.0)) + 1.15;
                rom = ((((-((0.00115 * adc) + 0.01) * weight) + (((49.64 - (0.031 * adc)) * height) / 100.0)) + (adc * 0.08)) + (age * 0.04)) + 15.4;
                moi = (((0xf_4240 / (bmi * ((2.688 * adc) - 78.28))) - (0x274a / adc)) - (0.22 * age)) + 52.6;
                bfr = ((((-930_000.0 / bmi) / ((1.966 * adc) - 58.46)) + (0x3378 / adc)) - (0.06 * age)) + 40.0;
                sfr = 0.898 * bfr;
                rosm = 0.895 * moi;
                pp = 0.8 * (((100.0 - bfr) - moi) - (bm / weight));
                uvi = ((((0.304 * weight) + ((25.58 * height) / 100.0)) + (0.131 * age)) + (0.005 * adc)) - 0x16;
                //bmr = (((((9.0 + (0.0015 * adc)) * weight) + (((0x546 - (0.88 * adc)) * height) / 100.0)) + (0xbc / age)) + (0.748 * adc)) - 0x41d;
                bmr = 370 + 21.6 * weight * (1 - bfr / 100);
                physicAge = ((((age * (1.0 + (0.012 * (bmi - 1.0)))) - 0x15) + ((30 - age) * 0.35)) + ((adc - 450) * 0.02)) + 11.0;
            }
            else
            {
                bm = ((((2.2E-05 * adc) * weight) + (((4.99 - (0.00284 * adc)) * height) / 100.0)) + (0.0012 * adc)) + 1.15;
                rom = ((((-((0.00115 * adc) + 0.01) * weight) + (((49.64 - (0.031 * adc)) * height) / 100.0)) + (adc * 0.08)) + (age * 0.04)) + 6.0;
                moi = (((0xf_4240 / (bmi * ((2.467 * adc) - 75.37))) - (0x3787 / adc)) - (0.034 * age)) + 43.2;
                bfr = ((((-3_030_000.0 / (bmi + 20.0)) / ((1.966 * adc) - 58.46)) + (0x6e10 / adc)) - (0.06 * age)) + 0x33;
                sfr = (0.876 * bfr) + 1.66;
                rosm = (0.857 * moi) - 0.36;
                pp = 0.75 * (((100.0 - bfr) - moi) - (bm / weight));
                uvi = ((((0.304 * weight) + ((25.58 * height) / 100.0)) + (0.131 * age)) + (0.005 * adc)) - 0x16;
                bmr = 370 + 21.6 * weight * (1 - bfr / 100);
                //bmr = ((((((0.00307 * adc) + 1.5) * weight) + (((0x5b3 - (0.989 * adc)) * height) / 100.0)) + (age * 0.9)) + (0.923 * adc)) - 950.0;
                physicAge = (age * (0.95 + (0.02 * (bmi - 21.2)))) + ((adc - 500) * 0.02);
            }
            item.bmi = bmi.ToString("0.0");
            bm = (bm > (weight * 0.15)) ? (weight * 0.15) : bm;
            item.bm = ((bm < (weight * 0.02)) ? (weight * 0.02) : bm).ToString("0.0");
            rom = (rom > 0x4b) ? 0x4b : rom;
            item.rom = ((rom < 15.0) ? 15.0 : rom).ToString("0.0");
            moi = (moi > 70.0) ? 70.0 : moi;
            item.moi = ((moi < 20.0) ? 20.0 : moi).ToString("0.0");
            bfr = (bfr > 50.0) ? 50.0 : bfr;
            item.bfr = ((bfr < 5.0) ? 5.0 : bfr).ToString("0.0");
            item.sfr = sfr.ToString("0.0");
            item.rosm = rosm.ToString("0.0");
            pp = (pp > 50.0) ? 50.0 : pp;
            item.pp = ((pp < 10.0) ? 10.0 : pp).ToString("0.0");
            uvi = (uvi > 20.0) ? 20.0 : uvi;
            item.uvi = ((uvi < 1.0) ? 1.0 : uvi).ToString("0");
            item.bmr = bmr.ToString("0.0");
            if (age < 0x12)
            {
                physicAge = age;
            }
            else
            {
                physicAge = (physicAge > (age + 10)) ? ((double)(age + 10)) : physicAge;
                physicAge = (physicAge < (age - 10)) ? ((double)(age - 10)) : physicAge;
            }
            item.physicAge = physicAge.ToString("0");
            item.weight = weight;
            item.height = height;
            item.age = age;
            item.adc = adc;
            item.sex = sex;
            return item;
        }
        /// <summary>
        /// 盛群八电极算法
        /// </summary>
        /// <param name="weight">体重,KG</param>
        /// <param name="height">身高,CM</param>
        /// <param name="age">年龄,岁</param>
        /// <param name="sex">性别,1-男,2-女,0-未知</param>
        /// <param name="ohm">HT_MCU上传的加密电阻值</param>
        /// <returns></returns>
        public async Task<HTBodyFatReturnItem> HTBodyFatResultAsync(double weight, double height, int age, int sex, int ohm)
        {
            var _loggerservice = App.GetService<ILoggerService>();
            //算法使用的性别为,0-女,1-男
            sex = sex == 1 ? 1 : 0;
            var url = "http://123.57.232.130:100/HTBodyFatTwoLegs.ashx";
            var request = new HttpRequestMessage(HttpMethod.Post, url);
            var data = new
            {
                UserWeightKg = weight,
                UserHeightcm = height,
                UserAge = age,
                UserGender = sex,
                UserZTwoLegsohm = ohm
            };
            var postdata = data.ToJson();
            request.Content = new StringContent(postdata, Encoding.UTF8, "application/json");
            var client = _clientFactory.CreateClient();
            var response = await client.SendAsync(request);
            if (response.IsSuccessStatusCode)
            {
                var result = await response.Content.ReadAsStringAsync();
                if (result.ToLower().Contains("errortype"))
                {
                    var jsondata = result.ToObject<HTBodyFatReturnData>();
                    return jsondata;
                }
                _loggerservice.AddLogger($"八电极算法请求成功,参数:{postdata}\r\n地址:{url}\r\n返回值:{result}");
                return null;
            }
            else
            {
                _loggerservice.AddLogger($"八电极算法请求失败,参数:{postdata}\r\n地址:{url}\r\n返回值:{response.ToJson()}");
                return null;
            }
        }

        /// <summary>
        /// BMI标准的范围
        /// </summary>
        /// <param name="sex"></param>
        /// <param name="age"></param>
        /// <returns></returns>
        public MeasureInfoItemValue bmi_stand(int sex, int age)
        {
            return bmi_value(sex, age).Skip(1).Take(1).FirstOrDefault();
        }

        /// <summary>
        /// 成人bmi范围标准
        /// </summary>
        /// <param name="sex"></param>
        /// <param name="age"></param>
        /// <returns></returns>
        public List<MeasureInfoItemValue> bmi_value(int sex, int age)
        {
            var list = new List<MeasureInfoItemValue>();
            list.Add(new MeasureInfoItemValue
            {
                maxvalue = 18.5m,
                minvalue = 0,
                text = BMILevelConst.Thin,
                color = LevelColor.Thin
            });
            list.Add(new MeasureInfoItemValue
            {
                maxvalue = 25,
                minvalue = 18.5m,
                text = BMILevelConst.Normal,
                color = LevelColor.Normal
            });
            list.Add(new MeasureInfoItemValue
            {
                maxvalue = 30,
                minvalue = 25,
                text = BMILevelConst.OverWeight,
                color = LevelColor.OverWeight
            });
            list.Add(new MeasureInfoItemValue
            {
                maxvalue = 50,
                minvalue = 30,
                text = BMILevelConst.Fat,
                color = LevelColor.Fat
            });
            return list;
        }
        /// <summary>
        /// 肌肉量标准
        /// </summary>
        /// <param name="sex"></param>
        /// <param name="age"></param>
        /// <param name="weight"></param>
        /// <returns></returns>
        public MeasureInfoItemValue muscleval_stand(int sex, int age, decimal weight)
        {
            return muscleval_value(sex, age, weight).Skip(1).Take(1).FirstOrDefault();
        }

        /// <summary>
        /// 肌肉重量标准范围
        /// </summary>
        /// <param name="sex">性别</param>
        /// <param name="age">年龄</param>
        /// <param name="weight">重量,kg</param>
        /// <returns></returns>
        public List<MeasureInfoItemValue> muscleval_value(int sex, int age, decimal weight)
        {
            var list = new List<MeasureInfoItemValue>();
            var values = muscle_value(sex, age);
            values.ForEach(x =>
            {
                list.Add(new MeasureInfoItemValue
                {
                    maxvalue = ((x.maxvalue / 100.0m) * weight).ToDecimal(1),
                    minvalue = ((x.minvalue / 100.0m) * weight).ToDecimal(1),
                    text = x.text,
                    color = x.color
                });
            });
            return list;
        }
        /// <summary>
        /// 脂肪重量标准
        /// </summary>
        /// <param name="sex"></param>
        /// <param name="age"></param>
        /// <param name="weight"></param>
        /// <returns></returns>
        public MeasureInfoItemValue fat_w_stand(int sex, int age, decimal weight)
        {
            return fat_w_value(sex, age, weight).Skip(1).Take(1).FirstOrDefault();
        }

        /// <summary>
        /// 脂肪重量标准范围
        /// </summary>
        /// <param name="sex">性别</param>
        /// <param name="age">年龄</param>
        /// <param name="weight">重量,kg</param>
        /// <returns></returns>
        public List<MeasureInfoItemValue> fat_w_value(int sex, int age, decimal weight)
        {
            var list = new List<MeasureInfoItemValue>();
            var values = fa_r_value(sex, age);
            values.ForEach(x =>
            {
                list.Add(new MeasureInfoItemValue
                {
                    maxvalue = ((x.maxvalue / 100.0m) * weight).ToDecimal(1),
                    minvalue = ((x.minvalue / 100.0m) * weight).ToDecimal(1),
                    text = x.text,
                    color = x.color
                });
            });
            return list;
        }
        /// <summary>
        /// 脂肪率/体脂率标准
        /// </summary>
        /// <param name="sex"></param>
        /// <param name="age"></param>
        /// <returns></returns>
        public MeasureInfoItemValue fat_r_stand(int sex, int age)
        {
            return fa_r_value(sex, age).Skip(1).Take(1).FirstOrDefault();
        }

        /// <summary>
        /// 脂肪率/体脂率范围标准
        /// </summary>
        /// <param name="sex"></param>
        /// <param name="age"></param>
        /// <returns></returns>
        public List<MeasureInfoItemValue> fa_r_value(int sex, int age)
            => (sex, age) switch
            {
                _ when sex == 1 && age < 30 => new List<MeasureInfoItemValue> {
                    new MeasureInfoItemValue
                    {
                        maxvalue=10,
                        minvalue=0,
                        text = NewLevelModel.flat,
                        color = LevelColor.Thin
                    },
                    new MeasureInfoItemValue
                    {
                        maxvalue=21,
                        minvalue=10,
                        text = NewLevelModel.normal,
                        color = LevelColor.Normal
                    },
                    new MeasureInfoItemValue
                    {
                        maxvalue=26,
                        minvalue=21,
                        text = NewLevelModel.high,
                        color = LevelColor.OverWeight
                    },
                    new MeasureInfoItemValue
                    {
                        maxvalue=50,
                        minvalue=26,
                        text = NewLevelModel.mhigh,
                        color = LevelColor.Fat
                    }
                },
                _ when sex == 1 && age >= 30 => new List<MeasureInfoItemValue> {
                    new MeasureInfoItemValue
                    {
                        maxvalue=11,
                        minvalue=0,
                        text = NewLevelModel.flat,
                        color = LevelColor.Thin
                    },
                    new MeasureInfoItemValue
                    {
                        maxvalue=22,
                        minvalue=11,
                         text = NewLevelModel.normal,
                        color = LevelColor.Normal
                    },
                    new MeasureInfoItemValue
                    {
                        maxvalue=27,
                        minvalue=22,
                         text = NewLevelModel.high,
                        color = LevelColor.OverWeight
                    },
                    new MeasureInfoItemValue
                    {
                        maxvalue=50,
                        minvalue=27,
                        text = NewLevelModel.mhigh,
                        color = LevelColor.Fat
                    }
                },
                _ when sex == 0 && age < 30 => new List<MeasureInfoItemValue> {
                    new MeasureInfoItemValue
                    {
                        maxvalue=20,
                        minvalue=0,
                        text = NewLevelModel.flat,
                        color = LevelColor.Thin
                    },
                    new MeasureInfoItemValue
                    {
                        maxvalue=31,
                        minvalue=20,
                         text = NewLevelModel.normal,
                        color = LevelColor.Normal
                    },
                    new MeasureInfoItemValue
                    {
                        maxvalue=38,
                        minvalue=31,
                         text = NewLevelModel.high,
                        color = LevelColor.OverWeight
                    },
                    new MeasureInfoItemValue
                    {
                        maxvalue=50,
                        minvalue=38,
                        text = NewLevelModel.mhigh,
                        color = LevelColor.Fat
                    }
                },
                _ when sex == 0 && age >= 30 => new List<MeasureInfoItemValue> {
                    new MeasureInfoItemValue
                    {
                        maxvalue=21,
                        minvalue=0,
                        text = NewLevelModel.flat,
                        color = LevelColor.Thin
                    },
                    new MeasureInfoItemValue
                    {
                        maxvalue=32,
                        minvalue=21,
                         text = NewLevelModel.normal,
                        color = LevelColor.Normal
                    },
                    new MeasureInfoItemValue
                    {
                        maxvalue=39,
                        minvalue=32,
                         text = NewLevelModel.high,
                        color = LevelColor.OverWeight
                    },
                    new MeasureInfoItemValue
                    {
                        maxvalue=50,
                        minvalue=39,
                        text = NewLevelModel.mhigh,
                        color = LevelColor.Fat
                    }
                },
                _ => new List<MeasureInfoItemValue>()
            };
        /// <summary>
        /// 肌肉率范围
        /// </summary>
        /// <param name="sex"></param>
        /// <param name="age"></param>
        /// <returns></returns>
        public List<MeasureInfoItemValue> muscle_value(int sex, int age)
            => (sex, age) switch
            {
                _ when sex == 1 => new List<MeasureInfoItemValue> {
                    new MeasureInfoItemValue
                    {
                        maxvalue=40,
                        minvalue=0,
                        text = NewLevelModel.notenu,
                        color = LevelColor.Thin
                    },
                    new MeasureInfoItemValue
                    {
                        maxvalue=60,
                        minvalue=40,
                        text = NewLevelModel.normal,
                        color = LevelColor.Normal
                    },
                    new MeasureInfoItemValue
                    {
                        maxvalue=80,
                        minvalue=60,
                        text = NewLevelModel.fine,
                        color = LevelColor.Fine
                    }
                },
                _ when sex == 0 => new List<MeasureInfoItemValue> {
                    new MeasureInfoItemValue
                    {
                        maxvalue=30,
                        minvalue=0,
                        text = NewLevelModel.notenu,
                        color = LevelColor.Thin
                    },
                    new MeasureInfoItemValue
                    {
                        maxvalue=50,
                        minvalue=30,
                        text = NewLevelModel.normal,
                        color = LevelColor.Normal
                    },
                    new MeasureInfoItemValue
                    {
                        maxvalue=80,
                        minvalue=50,
                        text = NewLevelModel.fine,
                        color = LevelColor.Fine
                    }
                },
                _ => new List<MeasureInfoItemValue>()
            };
        /// <summary>
        /// 水份范围
        /// </summary>
        /// <param name="sex"></param>
        /// <param name="age"></param>
        /// <returns></returns>
        public List<MeasureInfoItemValue> water_value(int sex, int age)
          => (sex, age) switch
          {
              _ when sex == 1 => new List<MeasureInfoItemValue> {
                    new MeasureInfoItemValue
                    {
                        maxvalue=55,
                        minvalue=0,
                        text = NewLevelModel.notenu,
                        color = LevelColor.Thin
                    },
                    new MeasureInfoItemValue
                    {
                        maxvalue=65,
                        minvalue=55,
                        text = NewLevelModel.normal,
                        color = LevelColor.Normal
                    },
                    new MeasureInfoItemValue
                    {
                        maxvalue=80,
                        minvalue=65,
                        text = NewLevelModel.fine,
                        color = LevelColor.Fine
                    }
              },
              _ when sex == 0 => new List<MeasureInfoItemValue> {
                    new MeasureInfoItemValue
                    {
                        maxvalue=45,
                        minvalue=0,
                        text = NewLevelModel.notenu,
                        color = LevelColor.Thin
                    },
                    new MeasureInfoItemValue
                    {
                        maxvalue=60,
                        minvalue=45,
                        text = NewLevelModel.normal,
                        color = LevelColor.Normal
                    },
                    new MeasureInfoItemValue
                    {
                        maxvalue=80,
                        minvalue=60,
                        text = NewLevelModel.fine,
                        color = LevelColor.Fine
                    }
              },
              _ => new List<MeasureInfoItemValue>()
          };
        /// <summary>
        /// 骨骼肌量范围
        /// </summary>
        /// <param name="sex"></param>
        /// <param name="age"></param>
        /// <returns></returns>
        public List<MeasureInfoItemValue> skeletalmusclekg(int sex, int age)
        {
            return new List<MeasureInfoItemValue> {
                    new MeasureInfoItemValue
                    {
                        maxvalue=20,
                        minvalue=0,
                        text = NewLevelModel.notenu,
                        color = LevelColor.Thin
                    },
                    new MeasureInfoItemValue
                    {
                        maxvalue=35,
                        minvalue=20,
                        text = NewLevelModel.normal,
                        color = LevelColor.Normal
                    },
                    new MeasureInfoItemValue
                    {
                        maxvalue=50,
                        minvalue=35,
                        text = NewLevelModel.fine,
                        color = LevelColor.Fine
                    }
              };
        }

        /// <summary>
        /// 骨量范围
        /// </summary>
        /// <param name="sex"></param>
        /// <param name="age"></param>
        /// <param name="weight">体重</param>
        /// <returns></returns>
        public List<MeasureInfoItemValue> bone_value(int sex, int age, decimal weight)
          => (sex, age, weight) switch
          {
              _ when sex == 1 && weight < 60 => new List<MeasureInfoItemValue> {
                    new MeasureInfoItemValue
                    {
                        maxvalue=2.4m,
                        minvalue=0,
                        text = NewLevelModel.notenu,
                        color = LevelColor.Thin
                    },
                    new MeasureInfoItemValue
                    {
                        maxvalue=2.6m,
                        minvalue=2.4m,
                        text = NewLevelModel.normal,
                        color = LevelColor.Normal
                    },
                    new MeasureInfoItemValue
                    {
                        maxvalue=5,
                        minvalue=2.6m,
                        text = NewLevelModel.fine,
                        color = LevelColor.Fine
                    }
              },
              _ when sex == 1 && weight < 75 && weight >= 60 => new List<MeasureInfoItemValue> {
                    new MeasureInfoItemValue
                    {
                        maxvalue=2.8m,
                        minvalue=0,
                        text = NewLevelModel.notenu,
                        color = LevelColor.Thin
                    },
                    new MeasureInfoItemValue
                    {
                        maxvalue=3.0m,
                        minvalue=2.8m,
                        text = NewLevelModel.normal,
                        color = LevelColor.Normal
                    },
                    new MeasureInfoItemValue
                    {
                        maxvalue=5,
                        minvalue=3.0m,
                        text = NewLevelModel.fine,
                        color = LevelColor.Fine
                    }
              },
              _ when sex == 1 && weight >= 75 => new List<MeasureInfoItemValue> {
                    new MeasureInfoItemValue
                    {
                        maxvalue=3.1m,
                        minvalue=0,
                        text = NewLevelModel.notenu,
                        color = LevelColor.Thin
                    },
                    new MeasureInfoItemValue
                    {
                        maxvalue=3.3m,
                        minvalue=3.1m,
                        text = NewLevelModel.normal,
                        color = LevelColor.Normal
                    },
                    new MeasureInfoItemValue
                    {
                        maxvalue=5,
                        minvalue=3.3m,
                        text = NewLevelModel.fine,
                        color = LevelColor.Fine
                    }
              },
              _ when sex == 0 && weight < 45 => new List<MeasureInfoItemValue> {
                    new MeasureInfoItemValue
                    {
                        maxvalue=1.7m,
                        minvalue=0,
                        text = NewLevelModel.notenu,
                        color = LevelColor.Thin
                    },
                    new MeasureInfoItemValue
                    {
                        maxvalue=1.9m,
                        minvalue=1.7m,
                        text = NewLevelModel.normal,
                        color = LevelColor.Normal
                    },
                    new MeasureInfoItemValue
                    {
                        maxvalue=5,
                        minvalue=1.9m,
                        text = NewLevelModel.fine,
                        color = LevelColor.Fine
                    }
              },
              _ when sex == 0 && weight < 60 && weight >= 45 => new List<MeasureInfoItemValue> {
                    new MeasureInfoItemValue
                    {
                        maxvalue=2.1m,
                        minvalue=0,
                        text = NewLevelModel.notenu,
                        color = LevelColor.Thin
                    },
                    new MeasureInfoItemValue
                    {
                        maxvalue=2.3m,
                        minvalue=2.1m,
                        text = NewLevelModel.normal,
                        color = LevelColor.Normal
                    },
                    new MeasureInfoItemValue
                    {
                        maxvalue=5,
                        minvalue=2.3m,
                        text = NewLevelModel.fine,
                        color = LevelColor.Fine
                    }
              },
              _ when sex == 0 && weight >= 60 => new List<MeasureInfoItemValue> {
                    new MeasureInfoItemValue
                    {
                        maxvalue=2.4m,
                        minvalue=0,
                        text = NewLevelModel.notenu,
                        color = LevelColor.Thin
                    },
                    new MeasureInfoItemValue
                    {
                        maxvalue=2.6m,
                        minvalue=2.4m,
                        text = NewLevelModel.normal,
                        color = LevelColor.Normal
                    },
                    new MeasureInfoItemValue
                    {
                        maxvalue=5,
                        minvalue=2.6m,
                        text = NewLevelModel.fine,
                        color = LevelColor.Fine
                    }
              },
              _ => new List<MeasureInfoItemValue>()
          };
        /// <summary>
        /// 基础代谢范围
        /// </summary>
        /// <param name="sex"></param>
        /// <param name="age"></param>
        /// <param name="weight"></param>
        /// <returns></returns>
        public List<MeasureInfoItemValue> kcal_value(int sex, int age, decimal weight)
            => (sex, age, weight) switch
            {
                _ when sex == 1 && age < 3 && age > 0 => new List<MeasureInfoItemValue> {
                    new MeasureInfoItemValue
                    {
                        minvalue = (60.9*weight.ToDouble()-54).ToDecimal(2),
                        maxvalue = (60.9*weight.ToDouble()-54).ToDecimal(2)
                    }
                },
                _ when sex == 1 && age < 10 && age >= 3 => new List<MeasureInfoItemValue> {
                    new MeasureInfoItemValue
                    {
                        minvalue = (22.7*weight.ToDouble()+495).ToDecimal(2),
                        maxvalue = (22.7*weight.ToDouble()+495).ToDecimal(2),
                    }
                },
                _ when sex == 1 && age < 18 && age >= 10 => new List<MeasureInfoItemValue> {
                    new MeasureInfoItemValue
                    {
                        minvalue = (17.5*weight.ToDouble()+651).ToDecimal(2),
                        maxvalue = (17.5*weight.ToDouble()+651).ToDecimal(2)
                    }
                },
                _ when sex == 1 && age < 30 && age >= 18 => new List<MeasureInfoItemValue> {
                    new MeasureInfoItemValue
                    {
                        minvalue = (15.3*weight.ToDouble()+679).ToDecimal(2),
                        maxvalue = (15.3*weight.ToDouble()+679).ToDecimal(2)
                    }
                },
                _ when sex == 1 && age >= 30 => new List<MeasureInfoItemValue> {
                    new MeasureInfoItemValue
                    {
                        minvalue = (11.6*weight.ToDouble()+879).ToDecimal(2),
                        maxvalue = (11.6*weight.ToDouble()+879).ToDecimal(2)
                    }
                },
                _ when sex == 0 && age < 3 && age > 0 => new List<MeasureInfoItemValue> {
                    new MeasureInfoItemValue
                    {
                        minvalue = (61.0*weight.ToDouble()-51).ToDecimal(2),
                        maxvalue = (61.0*weight.ToDouble()-51).ToDecimal(2)
                    }
                },
                _ when sex == 0 && age < 10 && age >= 3 => new List<MeasureInfoItemValue> {
                    new MeasureInfoItemValue
                    {
                        minvalue = (22.5*weight.ToDouble()+499).ToDecimal(2),
                        maxvalue = (22.5*weight.ToDouble()+499).ToDecimal(2),
                    }
                },
                _ when sex == 0 && age < 18 && age >= 10 => new List<MeasureInfoItemValue> {
                    new MeasureInfoItemValue
                    {
                        minvalue = (12.2*weight.ToDouble()+746).ToDecimal(2),
                        maxvalue = (12.2*weight.ToDouble()+746).ToDecimal(2)
                    }
                },
                _ when sex == 0 && age < 30 && age >= 18 => new List<MeasureInfoItemValue> {
                    new MeasureInfoItemValue
                    {
                        minvalue = (14.7*weight.ToDouble()+496).ToDecimal(2),
                        maxvalue = (14.7*weight.ToDouble()+496).ToDecimal(2)
                    }
                },
                _ when sex == 0 && age >= 30 => new List<MeasureInfoItemValue> {
                    new MeasureInfoItemValue
                    {
                        minvalue = (8.7*weight.ToDouble()+820).ToDecimal(2),
                        maxvalue = (8.7*weight.ToDouble()+820).ToDecimal(2)
                    }
                },
                _ => new List<MeasureInfoItemValue>()
            };
        /// <summary>
        /// 内脂范围
        /// </summary>
        /// <param name="sex"></param>
        /// <param name="age"></param>
        /// <returns></returns>
        public List<MeasureInfoItemValue> visceral_value(int sex, int age)
            => (sex, age) switch
            {
                _ => new List<MeasureInfoItemValue> {
                    new MeasureInfoItemValue
                    {
                        minvalue=0,
                        maxvalue=9,
                        text = NewLevelModel.normal,
                        color = LevelColor.Normal
                    },
                    new MeasureInfoItemValue
                    {
                        minvalue=9,
                        maxvalue=14,
                        text = NewLevelModel.alert,
                        color = LevelColor.OverWeight
                    },
                    new MeasureInfoItemValue
                    {
                        minvalue=14,
                        maxvalue=20,
                        text = NewLevelModel.danger,
                        color = LevelColor.Fat
                    }
                }
            };
        /// <summary>
        /// 蛋白量标准范围
        /// </summary>
        /// <param name="sex"></param>
        /// <param name="age"></param>
        /// <param name="weight"></param>
        /// <returns></returns>
        public List<MeasureInfoItemValue> proteinval_value(int sex, int age, decimal weight)
        {
            var list = new List<MeasureInfoItemValue>();
            var values = protein_value(sex, age);
            values.ForEach(x =>
            {
                list.Add(new MeasureInfoItemValue
                {
                    maxvalue = ((x.maxvalue / 100.0m) * weight).ToDecimal(1),
                    minvalue = ((x.minvalue / 100.0m) * weight).ToDecimal(1),
                    text = x.text,
                    color = x.color
                });
            });
            return list;
        }

        /// <summary>
        /// 蛋白质范围
        /// </summary>
        /// <param name="sex"></param>
        /// <param name="age"></param>
        /// <returns></returns>
        public List<MeasureInfoItemValue> protein_value(int sex, int age)
           => (sex, age) switch
           {
               _ when sex == 1 => new List<MeasureInfoItemValue> {
                    new MeasureInfoItemValue
                    {
                        minvalue=0,
                        maxvalue=16,
                        text = NewLevelModel.notenu,
                        color = LevelColor.Thin
                    },
                    new MeasureInfoItemValue
                    {
                        minvalue=16,
                        maxvalue=18,
                        text = NewLevelModel.normal,
                        color = LevelColor.Normal
                    },
                    new MeasureInfoItemValue
                    {
                        minvalue=18,
                        maxvalue=25,
                        text = NewLevelModel.fine,
                        color = LevelColor.Fine
                    }
               },
               _ when sex == 0 => new List<MeasureInfoItemValue> {
                    new MeasureInfoItemValue
                    {
                        minvalue=0,
                        maxvalue=14,
                        text = NewLevelModel.notenu,
                        color = LevelColor.Thin
                    },
                    new MeasureInfoItemValue
                    {
                        minvalue=14,
                        maxvalue=16,
                        text = NewLevelModel.normal,
                        color = LevelColor.Normal
                    },
                    new MeasureInfoItemValue
                    {
                        minvalue=16,
                        maxvalue=25,
                        text = NewLevelModel.fine,
                        color = LevelColor.Fine
                    }
               },
               _ => new List<MeasureInfoItemValue>()
           };
        /// <summary>
        /// 皮下脂肪范围
        /// </summary>
        /// <param name="sex"></param>
        /// <param name="age"></param>
        /// <returns></returns>
        public List<MeasureInfoItemValue> sfr_value(int sex, int age)
           => (sex, age) switch
           {
               _ when sex == 1 => new List<MeasureInfoItemValue> {
                    new MeasureInfoItemValue
                    {
                        minvalue=0,
                        maxvalue=7,
                        text = NewLevelModel.notenu,
                        color = LevelColor.Thin
                    },
                    new MeasureInfoItemValue
                    {
                        minvalue=7,
                        maxvalue=15,
                        text = NewLevelModel.normal,
                        color = LevelColor.Normal
                    },
                    new MeasureInfoItemValue
                    {
                        minvalue=15,
                        maxvalue=25,
                        text = NewLevelModel.high,
                        color = LevelColor.OverWeight
                    }
               },
               _ when sex == 0 => new List<MeasureInfoItemValue> {
                    new MeasureInfoItemValue
                    {
                        minvalue=0,
                        maxvalue=11,
                        text = NewLevelModel.notenu,
                        color = LevelColor.Thin
                    },
                    new MeasureInfoItemValue
                    {
                        minvalue=11,
                        maxvalue=17,
                        text = NewLevelModel.normal,
                        color = LevelColor.Normal
                    },
                    new MeasureInfoItemValue
                    {
                        minvalue=17,
                        maxvalue=25,
                        text = NewLevelModel.high,
                        color = LevelColor.OverWeight
                    }
               },
               _ => new List<MeasureInfoItemValue>()
           };
        /// <summary>
        /// 皮下脂肪量范围
        /// </summary>
        /// <param name="sex"></param>
        /// <param name="age"></param>
        /// <param name="weight"></param>
        /// <returns></returns>
        public List<MeasureInfoItemValue> sfrval_value(int sex, int age, decimal weight)
        {
            var list = new List<MeasureInfoItemValue>();
            var values = sfr_value(sex, age);
            values.ForEach(x =>
            {
                list.Add(new MeasureInfoItemValue
                {
                    maxvalue = ((x.maxvalue / 100.0m) * weight).ToDecimal(1),
                    minvalue = ((x.minvalue / 100.0m) * weight).ToDecimal(1),
                    text = x.text,
                    color = x.color
                });
            });
            return list;
        }
        /// <summary>
        /// 骨骼肌量标准
        /// </summary>
        /// <param name="sex"></param>
        /// <param name="age"></param>
        /// <param name="val">骨骼肌值</param>
        /// <returns></returns>
        public List<MeasureInfoItemValue> skeletalmusclekg_val(int sex, int age, decimal val)
        {
            decimal maxval = 50;
            if (val > maxval)
            {
                maxval = val;
            }
            return new List<MeasureInfoItemValue> {
                    new MeasureInfoItemValue
                    {
                        minvalue=1,
                        maxvalue=20,
                        text = NewLevelModel.notenu,
                        color = LevelColor.Thin
                    },
                    new MeasureInfoItemValue
                    {
                        minvalue=20,
                        maxvalue=35,
                        text = NewLevelModel.normal,
                        color = LevelColor.Normal
                    },
                    new MeasureInfoItemValue
                    {
                        minvalue=35,
                        maxvalue=maxval,
                        text = NewLevelModel.fine,
                        color = LevelColor.Fine
                    }
            };
        }
        /// <summary>
        /// 获取儿童身高范围
        /// </summary>
        /// <param name="sex">1-男,2-女</param>
        /// <param name="month">月龄</param>
        /// <returns></returns>
        public List<MeasureInfoItemValue> ChildHeightStand(int sex, int month)
        {
            return null;
        }
        /// <summary>
        /// 获取儿童体重范围
        /// </summary>
        /// <param name="sex">1-男,2-女</param>
        /// <param name="month">月龄</param>
        /// <returns></returns>
        public List<MeasureInfoItemValue> ChildWeightStand(int sex, int month)
        {
            return null;
        }
    }
}
