예제 #1
0
    public WeightPercentile GetWeightPercentile(int agemos, int gender, string src)
    {
        WeightPercentile x = new WeightPercentile();

        try {
            string fileName = PercentileFileName(agemos, src, "weight");
            if (string.IsNullOrWhiteSpace(fileName))
            {
                return(x);
            }
            string path = string.Format("~/app/assets/json/percentiles/{0}", fileName);
            string json = null;
            if (File.Exists(Server.MapPath(path)))
            {
                json = File.ReadAllText(Server.MapPath(path));
            }
            if (!string.IsNullOrWhiteSpace(json))
            {
                List <WeightPercentile> xx = JsonConvert.DeserializeObject <List <WeightPercentile> >(json);
                if (xx.Count > 0)
                {
                    x = xx.Find(a => a.Agemos == agemos + 0.5 && a.Sex == gender + 1);
                }
            }
            if (x == null)
            {
                x = new WeightPercentile();
            }
            return(x);
        } catch (Exception e) {
            L.SendErrorLog(e, null, null, "Calculations", "GetWeightPercentile");
            return(x);
        }
    }
예제 #2
0
    private RecommenderWeight RecommendedWeight(ClientsData.NewClientData client)
    {
        RecommenderWeight x = new RecommenderWeight();

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