예제 #1
0
        public IEnumerable <CalculationResultViewModel> Calculate([FromBody] CalculationRequestViewModel data)
        {
            var guideline           = data.guidelineName.ElementAt(0);
            var option              = ParseDecisionString(data.option);
            var guidelineOfAnalytes = _dbContext.Set <Guideline>().Where(x => x.ShortCode == guideline).SelectMany(x => x.AnalyteGuidelines).ToList();
            var calculator          = new GuidelineValueCalculator();
            var results             = calculator.Calculate(data.data, guidelineOfAnalytes, option);

            return(results.Select(x => new CalculationResultViewModel
            {
                Analyte = x.Analyte,
                Site = x.Site,
                DateTime = x.DateTime,
                Value = x.Value,
                Unit = x.Unit,
                Guideline = x.GuidelineValueString,
                GuidelineUnit = x.GuidelineUnit,
                IsExceedance = x.IsExceedance
            }));
        }
예제 #2
0
        public CalculationResultViewModel CalculateSingle([FromBody] SingleCalculationRequestViewModel data)
        {
            var guidelineOfAnalytes = _dbContext.Set <Guideline>().Where(x => x.ShortCode == data.guidelineName).SelectMany(x => x.AnalyteGuidelines).ToList();
            var calculator          = new GuidelineValueCalculator();

            var requestData = ConstructRequestData(data);
            var results     = calculator.Calculate(requestData, guidelineOfAnalytes, DependentDecision.ExistingValue);

            var actualResult = results.Select(x => new CalculationResultViewModel
            {
                Analyte       = x.Analyte,
                Site          = x.Site,
                DateTime      = x.DateTime,
                Value         = x.Value,
                Unit          = x.Unit,
                Guideline     = x.GuidelineValueString,
                GuidelineUnit = x.GuidelineUnit,
                IsExceedance  = x.IsExceedance
            });

            return(actualResult.FirstOrDefault());
        }