Exemple #1
0
        Tuple <double, double> acceptableRange(Dictionary <WHOData.Sex, Dictionary <WHOData.Percentile, List <double> > > data)
        {
            //Measurement Anonamlies
            DateTime maxDateofWeight = CurrentChild.Measurements.weightData.Keys.Count == 0 ? DateTime.MinValue : CurrentChild.Measurements.weightData.Keys.Max();
            DateTime maxDateofHeight = CurrentChild.Measurements.heightData.Keys.Count == 0 ? DateTime.MinValue : CurrentChild.Measurements.heightData.Keys.Max();
            DateTime maxDateofHead   = CurrentChild.Measurements.headCircumferenceData.Keys.Count == 0 ? DateTime.MinValue : CurrentChild.Measurements.headCircumferenceData.Keys.Max();

            TimeSpan diff   = maxDateofWeight - CurrentChild.Birthday;
            double   months = diff.TotalDays / 30.4;

            Dictionary <WHOData.Percentile, List <double> > weightData;

            if (CurrentChild.ChildGender == Child.Gender.MALE)
            {
                data.TryGetValue(WHOData.Sex.Male, out weightData);
            }
            else
            {
                data.TryGetValue(WHOData.Sex.Female, out weightData);
            }

            List <double> P5WeightList;
            List <double> P95WeightList;

            weightData.TryGetValue(WHOData.Percentile.P5, out P5WeightList);
            weightData.TryGetValue(WHOData.Percentile.P95, out P95WeightList);

            double x = Math.Round(months * 2, MidpointRounding.AwayFromZero) / 2;

            double acceptableP5Weight;
            double acceptableP95Weight;

            WHOData ageData = new WHOData();

            if (x % 1 == 0 && x > 0)
            {
                double lowX    = x - 0.5;
                double highX   = x + 0.5;
                int    ageLow  = ageData.ageList.IndexOf(lowX);
                int    ageHigh = ageData.ageList.IndexOf(highX);
                acceptableP5Weight  = (P5WeightList[ageLow] + P5WeightList[ageHigh]) / 2;
                acceptableP95Weight = (P95WeightList[ageLow] + P95WeightList[ageHigh]) / 2;
            }
            else
            {
                int age = ageData.ageList.IndexOf(x);
                acceptableP5Weight  = P5WeightList[age];
                acceptableP95Weight = P95WeightList[age];
            }

            return(new Tuple <double, double>(acceptableP5Weight, acceptableP95Weight));
        }
Exemple #2
0
        void findWarnings()
        {
            warning.Clear();

            //Measurement Anonamlies
            DateTime maxDateofWeight = CurrentChild.Measurements.weightData.Keys.Count == 0 ? DateTime.MinValue : CurrentChild.Measurements.weightData.Keys.Max();
            DateTime maxDateofHeight = CurrentChild.Measurements.heightData.Keys.Count == 0 ? DateTime.MinValue : CurrentChild.Measurements.heightData.Keys.Max();
            DateTime maxDateofHead   = CurrentChild.Measurements.headCircumferenceData.Keys.Count == 0 ? DateTime.MinValue : CurrentChild.Measurements.headCircumferenceData.Keys.Max();

            // Update weights
            double  wt   = maxDateofWeight == DateTime.MinValue ? -1 : CurrentChild.GetMeasurementForDateAndType(maxDateofWeight, MeasurementType.WEIGHT).Value;
            double  ht   = maxDateofHeight == DateTime.MinValue ? -1 : CurrentChild.GetMeasurementForDateAndType(maxDateofHeight, MeasurementType.HEIGHT).Value;
            double  hd   = maxDateofHead == DateTime.MinValue ? -1 : CurrentChild.GetMeasurementForDateAndType(maxDateofHead, MeasurementType.HEAD_CIRCUMFERENCE).Value;
            WHOData data = new WHOData();

            if (wt != -1)
            {
                Tuple <double, double> acceptable = acceptableRange(data.weightPercentile);
                if (wt < acceptable.Item1)
                {
                    if (CurrentContext.CurrentLanguage == Language.ENGLISH)
                    {
                        warning.Add(new Warning {
                            WarningName = CurrentChild.Name + " " + "is under the 5th percentile in weight"
                        });
                    }
                    else
                    {
                        warning.Add(new Warning {
                            WarningName = CurrentChild.Name + " " + "está bajo el 5 por ciento en peso"
                        });
                    }
                }

                if (wt > acceptable.Item2)
                {
                    if (CurrentContext.CurrentLanguage == Language.ENGLISH)
                    {
                        warning.Add(new Warning {
                            WarningName = CurrentChild.Name + " " + "is over the 95th percentile in weight"
                        });
                    }
                    else
                    {
                        warning.Add(new Warning {
                            WarningName = CurrentChild.Name + " " + "está sobre el 95 por ciento en peso"
                        });
                    }
                }
            }


            if (ht != -1)
            {
                Tuple <double, double> acceptable = acceptableRange(data.heightPercentile);
                if (ht < acceptable.Item1)
                {
                    if (CurrentContext.CurrentLanguage == Language.ENGLISH)
                    {
                        warning.Add(new Warning {
                            WarningName = CurrentChild.Name + " " + "is under the 5th percentile in height"
                        });
                    }
                    else
                    {
                        warning.Add(new Warning {
                            WarningName = CurrentChild.Name + " " + "está bajo el 5 por ciento en estatura"
                        });
                    }
                }
            }

            if (hd != -1)
            {
                Tuple <double, double> acceptable = acceptableRange(data.headPercentile);
                if (hd < acceptable.Item1)
                {
                    if (CurrentContext.CurrentLanguage == Language.ENGLISH)
                    {
                        warning.Add(new Warning {
                            WarningName = CurrentChild.Name + " " + "is under the 5th percentile in head circumference"
                        });
                    }
                    else
                    {
                        warning.Add(new Warning {
                            WarningName = CurrentChild.Name + " " + "está bajo el 5 por ciento en circunferencia de cabeza"
                        });
                    }
                }

                if (hd > acceptable.Item2)
                {
                    if (CurrentContext.CurrentLanguage == Language.ENGLISH)
                    {
                        warning.Add(new Warning {
                            WarningName = CurrentChild.Name + " " + "is over the 95th percentile in head circumference"
                        });
                    }
                    else
                    {
                        warning.Add(new Warning {
                            WarningName = CurrentChild.Name + " " + "está sobre el 95 por ciento en circunferencia de cabeza"
                        });
                    }
                }
            }
        }