예제 #1
0
        public async Task <double> CalculateBMI()
        {
            Tuple <double, double> wfaTuple = await AnthroStatsService.GetWFA(Weight, "365", Sex).ConfigureAwait(false);

            WfaZscore     = wfaTuple.Item1;
            WfaPercentile = wfaTuple.Item2;

            BMI = await AnthroService.GetBMI(Weight, Height).ConfigureAwait(false);

            BMI = Math.Round(BMI, 1);

            return(BMI);
        }
예제 #2
0
        protected async Task HandleHcaAsync()
        {
            var watch = System.Diagnostics.Stopwatch.StartNew();

            var isValid = EditContext.Validate();

            try
            {
                LoadFailed = false;

                if (isValid)
                {
                    IsCalculating = true;

                    Tuple <double, double> hcaTuple = await AnthroStatsService.GetHCA(
                        FormModel.FormInputs.HeadCircumference,
                        FormattableString.Invariant($"{FormModel.FormOutputs.Age.TotalDays}"),
                        FormModel.FormInputs.Sex).ConfigureAwait(false);

                    FormModel.FormOutputs.HcaZscore     = hcaTuple.Item1;
                    FormModel.FormOutputs.HcaPercentile = hcaTuple.Item2;

                    IsCalculating = false;
                }
                else
                {
                    LoadFailed = true;
                }
            }
            catch (ApplicationException ex)
            {
                LoadFailed = true;
                Error.ProcessError(ex);
                ErrorMessage = ex.Message;
                Logger.LogWarning(ex.Message);
            }

            watch.Stop();
            ExecutionTime = "- HCA Click - " + watch.ElapsedMilliseconds + "ms";
        }