public void TestPracticePerformanceIndicatorValues()
        {
            PracticePerformanceIndicatorValues values = new PracticePerformanceIndicatorValues(ReaderFactory.GetGroupDataReader(),
                "C85026", 0);

            var val = values.IndicatorToValue[PracticePerformanceIndicatorValues.Qof];
            Assert.IsTrue(val != null && val.IsValueValid);

            val = values.IndicatorToValue[PracticePerformanceIndicatorValues.PatientsThatWouldRecommendPractice];
            Assert.IsTrue(val != null && val.IsValueValid);

            val = values.IndicatorToValue[PracticePerformanceIndicatorValues.LifeExpectancyMale];
            Assert.IsTrue(val != null && val.IsValueValid);

            val = values.IndicatorToValue[PracticePerformanceIndicatorValues.LifeExpectancyFemale];
            Assert.IsTrue(val != null && val.IsValueValid);
        }
コード例 #2
0
        public void Build()
        {
            var metadataRepo = IndicatorMetadataRepository.Instance;

            const int indicatorId = IndicatorIds.QuinaryPopulations;

            Grouping grouping = groupDataReader.GetGroupingsByGroupIdAndIndicatorId(GroupId, indicatorId);

            area = areasReader.GetAreaFromCode(AreaCode);

            var metadata = metadataRepo.GetIndicatorMetadata(indicatorId);
            period = new DataPointOffsetCalculator(grouping, DataPointOffset, metadata.YearType).TimePeriod;

            // Get data for each sex
            int overallTotal = 0;
            foreach (var sexId in sexIds)
            {
                IEnumerable<double> vals;

                if (area.IsCcg)
                {
                    QuinaryPopulation population = practiceReader.GetCcgQuinaryPopulation(indicatorId, period, AreaCode, sexId);
                    vals = new QuinaryPopulationSorter(population.Values).SortedValues;
                }
                else
                {
                    IList<CoreDataSet> data = groupDataReader.GetCoreDataForAllAges(indicatorId, period, AreaCode, sexId);
                    vals = new QuinaryPopulationSorter(data).SortedValues;
                }

                // Add total
                int total = Convert.ToInt32(Math.Round(vals.Sum(), MidpointRounding.AwayFromZero));
                overallTotal += total;

                Values.Add(sexId, vals);
            }

            // Convert to %
            foreach (var sexId in sexIds)
            {
                Values[sexId] = Values[sexId].Select(x => Math.Round((x / overallTotal) * 100, 2, MidpointRounding.AwayFromZero));
            }

            // List size
            var val = new QofListSizeProvider(groupDataReader, area, GroupId, DataPointOffset, metadata.YearType).Value;
            if (val.HasValue)
            {
                metadata = metadataRepo.GetIndicatorMetadata(QofListSizeProvider.IndicatorId);
                ListSize = new ValueData { Value = val.Value };

                var formatter = NumericFormatterFactory.New(metadata, groupDataReader);
                formatter.Format(ListSize);
            }

            if (area.IsGpPractice && AreOnlyPopulationsRequired == false)
            {
                SetEthnicityText();

                SetDeprivationDecile();

                Shape = practiceReader.GetShape(AreaCode);

                AdHocValues = new PracticePerformanceIndicatorValues(groupDataReader, AreaCode, DataPointOffset).IndicatorToValue;
            }
        }
 public void TestPracticePerformanceIndicatorValuesDataPointYearOvershoot()
 {
     PracticePerformanceIndicatorValues values =
             new PracticePerformanceIndicatorValues(ReaderFactory.GetGroupDataReader(), "C85026", 100);
         Assert.AreEqual(0, values.IndicatorToValue.Count);
 }