public CategoryAreaDataWriter(IAreasReader areasReader, IGroupDataReader groupDataReader, WorksheetInfo worksheet,
            ProfileDataWriter profileDataWriter, CategoryAreaType categoryAreaType)
            : base(areasReader, groupDataReader, worksheet, profileDataWriter)
        {
            _categoryAreaTypeId = categoryAreaType.CategoryTypeId;

            categories = areasReader.GetCategories(_categoryAreaTypeId);

                subnationalCategoryIdToCategoryAreaMap = categories
                    .ToDictionary<Category, int, IArea>(
                    category => category.Id,
                    category => CategoryArea.New(category)
                    );
        }
 public AreaTypeListProvider(IGroupIdProvider groupdIdProvider,
     IAreasReader areasReader, IGroupDataReader groupDataReader)
 {
     this.groupdIdProvider = groupdIdProvider;
     this.areasReader = areasReader;
     this.groupDataReader = groupDataReader;
 }
 protected ParentDataWriter(IAreasReader areasReader, IGroupDataReader groupDataReader, WorksheetInfo worksheetInfo, ProfileDataWriter profileDataWriter)
 {
     AreasReader = areasReader;
     GroupDataReader = groupDataReader;
     Worksheet = worksheetInfo;
     ProfileDataWriter = profileDataWriter;
 }
 public PracticeProfilesExcelFileGenerator(ILogger logger, IGroupDataReader groupDataReader,
     IExcelFileWriter excelFileWriter)
 {
     _logger = logger;
     _groupDataReader = groupDataReader;
     _excelFileWriter = excelFileWriter;
 }
        /// <summary>
        /// Assigns required data if the comparer calculate categories.
        /// </summary>
        /// <param name="subnationalDataList">Use null if you know the categories will be national</param>
        public static void AssignCategoryDataIfRequired(IndicatorComparer comparer, Grouping grouping, 
            IGroupDataReader groupDataReader, IList<CoreDataSet> subnationalDataList)
        {
            ICategoryComparer categoryComparer = comparer as ICategoryComparer;
            if (categoryComparer != null)
            {
                IList<CoreDataSet> coreDataList = null;

                if (grouping.ComparatorId == ComparatorIds.England)
                {
                    coreDataList = groupDataReader.GetCoreDataForAllAreasOfType(
                    grouping, TimePeriod.GetDataPoint(grouping));
                }
                else
                {
                    if (subnationalDataList != null)
                    {
                        coreDataList = subnationalDataList;
                    }
                }

                if (coreDataList != null)
                {
                    var values = coreDataList
                        .Where(x => x.IsValueValid)
                        .Select(x => x.Value)
                        .ToList();

                    categoryComparer.SetDataForCategories(values);
                }
            }
        }
        private void SetSingleAreaValue(IGroupDataReader groupDataReader, Area area, Grouping grouping, TimePeriod period)
        {
            IList<CoreDataSet> dataList = groupDataReader.GetCoreData(grouping, period, area.Code);
            if (dataList.Count == 1)
            {
                var data = dataList.First();
                if (data.IsValueValid)
                {
                    Value = data.Value;

                    if (area.IsGpPractice == false)
                    {
                        // Calculate average

                        var areasReader = ReaderFactory.GetAreasReader();

                        int count = area.IsCountry ?
                            areasReader.GetAreaCountForAreaType(grouping.AreaTypeId) :
                            areasReader.GetChildAreaCount(area.Code, grouping.AreaTypeId);

                        Value /= count;
                    }
                }
            }
            else if (dataList.Count > 1)
            {
                throw new FingertipsException(string.Format(
                    "More data than expected on determination of QOF list size: area:{0}", area.Code));
            }
        }
 public static ParentDataWriter New(IAreasReader areasReader, IGroupDataReader groupDataReader, WorksheetInfo worksheetInfo, 
     ProfileDataWriter profileDataWriter, IAreaType parentAreaType)
 {
     var categoryAreaType = parentAreaType as CategoryAreaType;
     return categoryAreaType != null
         ? (ParentDataWriter)new CategoryAreaDataWriter(areasReader, groupDataReader, worksheetInfo, profileDataWriter, categoryAreaType)
         : (ParentDataWriter)new SubnationalAreaDataWriter(areasReader, groupDataReader, worksheetInfo, profileDataWriter, parentAreaType);
 }
 public ChildAreaValuesBuilder(IndicatorComparerFactory indicatorComparerFactory,
     IGroupDataReader groupDataReader, IAreasReader areasReader, IProfileReader profileReader)
     : base(groupDataReader)
 {
     this.indicatorComparerFactory = indicatorComparerFactory;
     this.areasReader = areasReader;
     this.profileReader = profileReader;
 }
 public CcgCoreDataSetProvider(Area area, CcgPopulationProvider ccgPopulationProvider,
     CoreDataSetListProvider coreDataSetListProvider, IGroupDataReader groupDataReader)
     : base(area)
 {
     this.ccgPopulationProvider = ccgPopulationProvider;
     this.coreDataSetListProvider = coreDataSetListProvider;
     this.groupDataReader = groupDataReader;
 }
        public IndicatorComparisonHelper(IndicatorMetadata indicatorMetadata, Grouping grouping,
            IGroupDataReader groupDataReader, PholioReader pholioReader, IArea nationalArea)
        {
            // Assign constructor parameter to instance variables
            this.indicatorMetadata = indicatorMetadata;
            this.grouping = grouping;
            this.groupDataReader = groupDataReader;

            InitComparer(pholioReader, nationalArea);
        }
        protected override void ReadGroupings(IGroupDataReader groupDataReader)
        {
            var profileIds = RestrictSearchProfileIds != null && RestrictSearchProfileIds.Any() ?
                RestrictSearchProfileIds :
                new List<int> { ProfileId };

            var profileReader = ReaderFactory.GetProfileReader();

            Groupings = new GroupingListProvider(groupDataReader, profileReader)
                .GetGroupings(profileIds, IndicatorIds, AreaTypeId);
        }
        public PracticePerformanceIndicatorValues(IGroupDataReader groupDataReader, string practiceCode, int dataPointOffset)
        {
            IndicatorToValue = new Dictionary<string, ValueData>();
            IndicatorToValue = new Dictionary<string, ValueData>();
            this.groupDataReader = groupDataReader;
            this.dataPointOffset = dataPointOffset;

            // Require count and denominator for QOF
            SetCoreData(GetData(IndicatorIds.QofPoints, practiceCode), Qof);
            SetValueData(GetData(IndicatorIds.PatientsThatWouldRecommendPractice, practiceCode),
                PatientsThatWouldRecommendPractice);
            SetLifeExpectancies(practiceCode);
        }
        public QofListSizeProvider(IGroupDataReader groupDataReader, Area area, int groupId, int dataPointOffset,
            YearType yearType)
        {
            Grouping grouping = groupDataReader.GetGroupingsByGroupIdAndIndicatorId(groupId, IndicatorId);
            var period = new DataPointOffsetCalculator(grouping, dataPointOffset, yearType).TimePeriod;

            if (area.IsCcg)
            {
                //Note: zeroes may occur and should be included
                Value = groupDataReader
                    .GetCoreDataListForChildrenOfArea(grouping, period, area.Code)
                    .Where(x => x.IsValueValid)
                    .Average(x => x.Value);
            }
            else
            {
                SetSingleAreaValue(groupDataReader, area, grouping, period);
            }
        }
 public CategoryAreaCoreDataSetProvider(CategoryArea area, IGroupDataReader groupDataReader) : base(area)
 {
     this.groupDataReader = groupDataReader;
 }
 public GroupingListProvider(IGroupDataReader groupDataReader, IProfileReader profileReader)
 {
     this.groupDataReader = groupDataReader;
     this.profileReader = profileReader;
 }
 protected override void ReadGroupings(IGroupDataReader groupDataReader)
 {
     Groupings = groupDataReader.GetGroupingsByGroupIdAndAreaTypeIdOrderedBySequence(GroupId, ChildAreaTypeId);
 }
 public GroupRootFilter(IGroupDataReader groupDataReader)
 {
     _groupDataReader = groupDataReader;
 }
 public BenchmarkDataProvider(IGroupDataReader groupDataReader)
 {
     this._groupDataReader = groupDataReader;
 }
 protected AreaValuesBuilder(IGroupDataReader groupDataReader)
 {
     this.groupDataReader = groupDataReader;
 }
 public CoreDataSetListProvider(IGroupDataReader groupDataReader)
 {
     this.groupDataReader = groupDataReader;
 }
 private static IList<GroupRoot> RemoveRootsWithoutChildAreaData(IGroupDataReader groupDataReader, 
     List<GroupRoot> roots)
 {
     var filteredRoots = new GroupRootFilter(groupDataReader).RemoveRootsWithoutChildAreaData(roots);
     return filteredRoots;
 }
 public Calculator()
 {
     _groupReader = ReaderFactory.GetGroupDataReader();
     _areasReader = ReaderFactory.GetAreasReader();
 }
 public SingleGroupingProvider(IGroupDataReader groupDataReader, GroupIdProvider groupIdProvider)
 {
     this.groupDataReader = groupDataReader;
     this.groupIdProvider = groupIdProvider;
 }
 protected abstract void ReadGroupings(IGroupDataReader groupDataReader);
 public TargetComparerHelper(IGroupDataReader groupDataReader, IArea nationalArea)
 {
     this.groupDataReader = groupDataReader;
     this.nationalArea = nationalArea;
 }
 /// <summary>
 /// New numeric formatter instance.
 /// </summary>
 public static NumericFormatter New(IndicatorMetadata metadata, IGroupDataReader groupDataReader)
 {
     var limits = groupDataReader.GetCoreDataLimitsByIndicatorId(metadata.IndicatorId);
     return NewWithLimits(metadata, limits);
 }
 public PracticeAreaValuesBuilder(IGroupDataReader groupDataReader)
     : base(groupDataReader)
 {
 }
 public GroupMetadataBuilder(IGroupDataReader groupDataReader)
 {
     this.groupDataReader = groupDataReader;
 }
 public SimpleCoreDataSetProvider(Area area, IGroupDataReader groupDataReader)
     : base(area)
 {
     this.groupDataReader = groupDataReader;
 }