Beispiel #1
0
        /// <summary>
        /// Runs the report with the report options and collects all the disease distribution calculation
        /// </summary>
        /// <param name="mainReportOptions">The report options</param>
        public void Run(ReportOptions mainReportOptions)
        {
            SettingsRepository settingsRepo = new SettingsRepository();

            Report = new SavedReport();
            DistributionReportGenerator gen = new DistributionReportGenerator();

            Report.ReportOptions = new ReportOptions();
            Report.ReportOptions.SelectedIndicators = new List<ReportIndicator>();

            Report.ReportOptions.Years = Util.DeepClone(mainReportOptions.Years);
            Report.ReportOptions.SelectedAdminLevels = Util.DeepClone(mainReportOptions.SelectedAdminLevels);
            Report.ReportOptions.MonthYearStarts = 1;
            Report.ReportOptions.IsByLevelAggregation = true;
            Report.ReportOptions.IsCountryAggregation = false;
            Report.ReportOptions.IsNoAggregation = false;

            // Determine the name of the reporting admin level
            if (mainReportOptions.SelectedAdminLevels.Count > 0)
            {
                int levelNum = mainReportOptions.SelectedAdminLevels[0].LevelNumber;
                AdminLevelType adminLevelType = settingsRepo.GetAdminLevelTypeByLevel(levelNum);
                NameOfReportingAdminLevel = adminLevelType.DisplayName;
            }
            if (NameOfReportingAdminLevel == null)
                throw new ArgumentException("Could not determine reporting level");

            // STH
            Report.ReportOptions.SelectedIndicators.Add(ReportRepository.CreateReportIndicator((int)DiseaseType.STH,
                        new KeyValuePair<string, Indicator>("DDSTHPopulationRequiringPc", new Indicator { Id = 141, DisplayName = "DDSTHPopulationRequiringPc" })));
            Report.ReportOptions.SelectedIndicators.Add(ReportRepository.CreateReportIndicator((int)DiseaseType.STH,
                        new KeyValuePair<string, Indicator>("DDSTHPsacAtRisk", new Indicator { Id = 142, DisplayName = "DDSTHPsacAtRisk" })));
            Report.ReportOptions.SelectedIndicators.Add(ReportRepository.CreateReportIndicator((int)DiseaseType.STH,
                        new KeyValuePair<string, Indicator>("DDSTHSacAtRisk", new Indicator { Id = 143, DisplayName = "DDSTHSacAtRisk" })));
            Report.ReportOptions.SelectedIndicators.Add(ReportRepository.CreateReportIndicator((int)DiseaseType.STH,
                        new KeyValuePair<string, Indicator>("DDSTHPopulationAtRisk", new Indicator { Id = 140, DisplayName = "DDSTHPopulationAtRisk" })));
            // LF
            Report.ReportOptions.SelectedIndicators.Add(ReportRepository.CreateReportIndicator((int)DiseaseType.Lf,
                    new KeyValuePair<string, Indicator>("DDLFPopulationAtRisk", new Indicator { Id = 98, DisplayName = "DDLFPopulationAtRisk" })));
            Report.ReportOptions.SelectedIndicators.Add(ReportRepository.CreateReportIndicator((int)DiseaseType.Lf,
                        new KeyValuePair<string, Indicator>("DDLFPopulationRequiringPc", new Indicator { Id = 99, DisplayName = "DDLFPopulationRequiringPc" })));
            // Oncho
            Report.ReportOptions.SelectedIndicators.Add(ReportRepository.CreateReportIndicator((int)DiseaseType.Oncho,
                    new KeyValuePair<string, Indicator>("DDOnchoPopulationAtRisk", new Indicator { Id = 111, DisplayName = "DDOnchoPopulationAtRisk" })));
            Report.ReportOptions.SelectedIndicators.Add(ReportRepository.CreateReportIndicator((int)DiseaseType.Oncho,
                        new KeyValuePair<string, Indicator>("DDOnchoPopulationRequiringPc", new Indicator { Id = 112, DisplayName = "DDOnchoPopulationRequiringPc" })));
            // Schisto
            Report.ReportOptions.SelectedIndicators.Add(ReportRepository.CreateReportIndicator((int)DiseaseType.Schisto,
                        new KeyValuePair<string, Indicator>("DDSchistoPopulationAtRisk", new Indicator { Id = 125, DisplayName = "DDSchistoPopulationAtRisk" })));
            Report.ReportOptions.SelectedIndicators.Add(ReportRepository.CreateReportIndicator((int)DiseaseType.Schisto,
                        new KeyValuePair<string, Indicator>("DDSchistoPopulationRequiringPc", new Indicator { Id = 126, DisplayName = "DDSchistoPopulationRequiringPc" })));
            Report.ReportOptions.SelectedIndicators.Add(ReportRepository.CreateReportIndicator((int)DiseaseType.Schisto,
                        new KeyValuePair<string, Indicator>("DDSchistoSacAtRisk", new Indicator { Id = 127, DisplayName = "DDSchistoSacAtRisk" })));
            // Trachoma
            Report.ReportOptions.SelectedIndicators.Add(ReportRepository.CreateReportIndicator((int)DiseaseType.Trachoma,
                    new KeyValuePair<string, Indicator>("DDTraPopulationAtRisk", new Indicator { Id = 161, DisplayName = "DDTraPopulationAtRisk" })));

            // Run the report
            Result = gen.Run(Report);
        }
Beispiel #2
0
 protected void AddIntvIndicators(ReportOptions options, int typeId, IntvRepository iRepo)
 {
     IntvType iType = iRepo.GetIntvType(typeId);
     if (typeId == 10)
         dropdownValues = iType.IndicatorDropdownValues;
     foreach (var indicator in iType.Indicators.Where(i => i.Value.DataTypeId != (int)IndicatorDataType.Calculated))
         options.SelectedIndicators.Add(ReportRepository.CreateReportIndicator(iType.Id, indicator));
 }
        public void AddIndicatorsToAggregate(string cmdText, ReportOptions options, Dictionary<int, AdminLevelIndicators> dic, OleDbCommand command,
            OleDbConnection connection, Func<OleDbDataReader, bool, ReportOptions, string> getKey, Func<OleDbDataReader, string> getName, Func<OleDbDataReader, string> getColTypeName,
            Action<CreateAggParams> addStaticIndicators, bool isCalcRelated, bool isDemoOrDistro, int entityTypeId, List<IndicatorDropdownValue> dropdownOptions)
        {
            command = new OleDbCommand(cmdText, connection);

            FillDictionary(command, connection, dic, options, getKey, getName, getColTypeName, addStaticIndicators, isCalcRelated, isDemoOrDistro, entityTypeId, dropdownOptions);
        }
 protected void AddIndicators(int id, string name, IHaveDynamicIndicators dd, string formName, string formTranslationKey,
     ReportOptions options)
 {
     if (dd.Indicators.ContainsKey(name) && options.SelectedIndicators.Count(i => i.Name == name && i.FormNameKey == formTranslationKey) < 1)
     {
         options.SelectedIndicators.Add(ReportRepository.CreateReportIndicator(id,
             new KeyValuePair<string, Indicator>(name, dd.Indicators[name]), formName, formTranslationKey));
     }
 }
Beispiel #5
0
        private Dictionary<int, DataRow> GetDd(DateTime start, DateTime end, List<AdminLevel> demography)
        {
            Dictionary<int, DataRow> dd = new Dictionary<int, DataRow>();
            ReportOptions options = new ReportOptions
            {
                MonthYearStarts = start.Month,
                StartDate = start,
                EndDate = end,
                IsCountryAggregation = false,
                IsByLevelAggregation = true,
                IsAllLocations = false,
                IsNoAggregation = false
            };
            options.SelectedAdminLevels = demography;
            DistributionReportGenerator gen = new DistributionReportGenerator();
            var lf = diseaseRepo.Create(DiseaseType.Lf);
            options.SelectedIndicators.Add(ReportRepository.CreateReportIndicator(lf.Id, lf.Indicators["DDLFDiseaseDistributionPcInterventions"]));
            options.SelectedIndicators.Add(ReportRepository.CreateReportIndicator(lf.Id, lf.Indicators["DDLFNumPcRoundsYearCurrentlyImplemented"]));
            var oncho = diseaseRepo.Create(DiseaseType.Oncho);
            options.SelectedIndicators.Add(ReportRepository.CreateReportIndicator(oncho.Id, oncho.Indicators["DDOnchoDiseaseDistributionPcInterventio"]));
            options.SelectedIndicators.Add(ReportRepository.CreateReportIndicator(oncho.Id, oncho.Indicators["DDOnchoNumPcRoundsYearCurrentlyImplemen"]));
            var sth = diseaseRepo.Create(DiseaseType.STH);
            options.SelectedIndicators.Add(ReportRepository.CreateReportIndicator(sth.Id, sth.Indicators["DDSTHDiseaseDistributionPcInterventions"]));
            options.SelectedIndicators.Add(ReportRepository.CreateReportIndicator(sth.Id, sth.Indicators["DDSTHNumPcRoundsYearCurrentlyImplemente"]));
            var schisto = diseaseRepo.Create(DiseaseType.Schisto);
            options.SelectedIndicators.Add(ReportRepository.CreateReportIndicator(schisto.Id, schisto.Indicators["DDSchistoDiseaseDistributionPcIntervent"]));
            options.SelectedIndicators.Add(ReportRepository.CreateReportIndicator(schisto.Id, schisto.Indicators["DDSchistoNumPcRoundsYearCurrentlyImplem"]));

            ReportResult ddResult = gen.Run(new SavedReport { ReportOptions = options });
            dd = new Dictionary<int, DataRow>();
            foreach (DataRow dr in ddResult.DataTableResults.Rows)
            {
                int id = 0;
                if (int.TryParse(dr["ID"].ToString(), out id))
                {
                    if (dd.ContainsKey(id))
                        dd[id] = dr;
                    else
                        dd.Add(id, dr);
                }
            }
            return dd;
        }
        private void FillDictionary(OleDbCommand command, OleDbConnection connection, Dictionary<int, AdminLevelIndicators> dic, ReportOptions options,
            Func<OleDbDataReader, bool, ReportOptions, string> getKey, Func<OleDbDataReader, string> getName, Func<OleDbDataReader, string> getColTypeName,
            Action<CreateAggParams> addStaticIndicators, bool isCalcRelated, bool isDemoOrDistro, int entityTypeId, List<IndicatorDropdownValue> dropdownOptions)
        {
            using (OleDbDataReader reader = command.ExecuteReader())
            {
                while (reader.Read())
                {
                    string indicatorName = getName(reader);
                    string indicatorKey = getKey(reader, options.IsNoAggregation, options) + isCalcRelated;
                    int adminLevelId = reader.GetValueOrDefault<int>("AID");
                    int dataType = reader.GetValueOrDefault<int>("DataTypeId");
                    if (!dic.ContainsKey(adminLevelId))
                        continue;
                    string val = reader.GetValueOrDefault<string>("DynamicValue");
                    if (dataType == (int)IndicatorDataType.LargeText && !string.IsNullOrEmpty(reader.GetValueOrDefault<string>("MemoValue")))
                        val = reader.GetValueOrDefault<string>("MemoValue");

                    var newIndicator = new AggregateIndicator
                    {
                        IndicatorId = reader.GetValueOrDefault<int>("IndicatorId"),
                        Name = indicatorName,
                        Key = reader.GetValueOrDefault<string>("IndicatorName"),
                        DataType = dataType,
                        Value = val,
                        AggType = reader.GetValueOrDefault<int>("AggTypeId"),
                        Year = Util.GetYearReported(options.MonthYearStarts, reader.GetValueOrDefault<DateTime>("DateReported")),
                        ReportedDate = reader.GetValueOrDefault<DateTime>("DateReported"),
                        IsCalcRelated = isCalcRelated,
                        ColumnTypeName = getColTypeName(reader),
                        TypeId = reader.GetValueOrDefault<int>("Tid"),
                        TypeName = reader.GetValueOrDefault<string>("TName"),
                        FormId = reader.GetValueOrDefault<int>("ID"),
                        EntityTypeId = entityTypeId
                    };
                    // if the adminlevel already contains the indicator for that year, aggregate
                    if (dic[adminLevelId].Indicators.ContainsKey(indicatorKey) && !isDemoOrDistro)
                    {
                        dic[adminLevelId].Indicators[indicatorKey] = IndicatorAggregator.Aggregate(newIndicator, dic[adminLevelId].Indicators[indicatorKey], dropdownOptions);
                    }
                    else if (dic[adminLevelId].Indicators.ContainsKey(indicatorKey) && isDemoOrDistro)
                    {
                        if (newIndicator.ReportedDate > dic[adminLevelId].Indicators[indicatorKey].ReportedDate)
                            dic[adminLevelId].Indicators[indicatorKey] = newIndicator;
                    }
                    else
                    {
                        dic[adminLevelId].Indicators.Add(indicatorKey, newIndicator);

                        // Add Column
                        if (!options.Columns.ContainsKey(indicatorKey))
                            options.Columns.Add(indicatorKey, newIndicator);

                        if (!isCalcRelated)
                            addStaticIndicators(new CreateAggParams
                            {
                                AdminLevel = dic[adminLevelId],
                                Reader = reader,
                                Options = options,
                            });
                    }

                }
                reader.Close();
            }
        }
 public static string CreateAdminFilter(ReportOptions options)
 {
     string filter = " ";
     if (options.IsNoAggregation && !options.IsAllLocations)
         filter += " and AdminLevels.Id in (" + String.Join(", ", options.SelectedAdminLevels.Select(a => a.Id.ToString()).ToArray()) + ") ";
     return filter;
 }
        protected Dictionary<int, DataRow> GetEligibleInSubdistricts(DateTime start, DateTime end)
        {
            IntvRepository iRepo = new IntvRepository();
            ReportOptions options = new ReportOptions
            {
                MonthYearStarts = start.Month,
                StartDate = start,
                EndDate = end,
                IsCountryAggregation = false,
                IsByLevelAggregation = true,
                IsAllLocations = false,
                IsNoAggregation = false,
                IsGroupByRange = true,

            };

            var childType = settings.GetAllAdminLevels().Where(a => a.LevelNumber > AdminLevelType.LevelNumber).OrderBy(l => l.LevelNumber).FirstOrDefault();
            if (childType == null)
                return new Dictionary<int, DataRow>();

            options.SelectedAdminLevels = demo.GetAdminLevelByLevel(childType.LevelNumber);
            IntvReportGenerator gen = new IntvReportGenerator();

            IntvType iType = iRepo.GetIntvType(23);
            var eligible = iType.Indicators.FirstOrDefault(i => i.Value.DisplayName == "PcIntvNumEligibleIndividualsTargeted");
            options.SelectedIndicators.Add(ReportRepository.CreateReportIndicator(iType.Id, eligible.Value));
            ReportResult ddResult = gen.Run(new SavedReport { ReportOptions = options });
            Dictionary<int, DataRow> intvData = new Dictionary<int, DataRow>();
            foreach (DataRow dr in ddResult.DataTableResults.Rows)
            {
                int id = 0;
                if (int.TryParse(dr["ID"].ToString(), out id))
                {
                    if (intvData.ContainsKey(id))
                        intvData[id] = dr;
                    else
                        intvData.Add(id, dr);
                }
            }
            return intvData;
        }
Beispiel #9
0
 //Worksheet 6: IVM Intervention
 //aggregated to the reporting level 
 //all IVM intervention indicators
 private void Add6(excel.Worksheet xlsWorksheet, excel.Range rng, List<AdminLevel> districts, DateTime start, DateTime end, int month)
 {
     ReportOptions options = new ReportOptions { MonthYearStarts = month, StartDate = start, EndDate = end, IsCountryAggregation = false, IsByLevelAggregation = true, IsAllLocations = false, IsNoAggregation = false };
     options.SelectedAdminLevels = districts;
     IntvRepository repo = new IntvRepository();
     IntvType intv = repo.GetIntvType((int)StaticIntvType.Ivm);
     IntvReportGenerator gen = new IntvReportGenerator();
     AddReportToSheet(xlsWorksheet, intv.Indicators, options, gen, (int)StaticIntvType.Ivm, intv.IntvTypeName, rng);
 }
 protected string DetermineInterventionSql(List<int> filteredIntvIds, ReportOptions reportOptions)
 {
     return @"Select 
                 AdminLevels.ID as AID, 
                 AdminLevels.DisplayName,
                 Interventions.ID, 
                 [DateReported], 
                 Interventions.PcIntvRoundNumber, 
                 InterventionTypes.InterventionTypeName as TName, 
                 InterventionTypes.ID as Tid,      
                 InterventionIndicators.ID as IndicatorId, 
                 InterventionIndicators.DisplayName as IndicatorName, 
                 InterventionIndicators.IsEditable, 
                 InterventionIndicators.DataTypeId, 
                 InterventionIndicators.AggTypeId, 
                 InterventionIndicatorValues.DynamicValue, 
                 InterventionIndicatorValues.MemoValue
                 FROM ((((Interventions INNER JOIN InterventionTypes on Interventions.InterventionTypeId = InterventionTypes.ID)
                     INNER JOIN InterventionIndicatorValues on Interventions.Id = InterventionIndicatorValues.InterventionId)
                     INNER JOIN AdminLevels on Interventions.AdminLevelId = AdminLevels.ID) 
                     INNER JOIN InterventionIndicators on InterventionIndicators.ID = InterventionIndicatorValues.IndicatorId)
                 WHERE Interventions.IsDeleted = 0"
     + " AND Interventions.ID IN (" + String.Join(", ", filteredIntvIds.Select(i => i.ToString()).ToArray()) + ") "
     + " AND InterventionIndicators.Id in (" + String.Join(", ", reportOptions.SelectedIndicators.Select(s => s.ID.ToString()).ToArray())
     + ") AND InterventionTypes.ID in (" + String.Join(", ", reportOptions.SelectedIndicators.Select(i => i.TypeId.ToString()).Distinct().ToArray()) + ") "
     + ReportRepository.CreateYearFilter(reportOptions, "DateReported") + ReportRepository.CreateAdminFilter(reportOptions)
     + " ORDER BY IsEditable DESC, InterventionIndicators.SortOrder";
 }
        protected string GetRecentDistroIndicator(int adminLevelId, string indicatorName, DiseaseType diseaseType, DateTime start, DateTime end, ref string errors)
        {
            // If there is a RecentDistro instance, look for the value there
            RecentDistro recentDistro = RecentDistro.GetInstance(false /* don't instantiate */);
            if (recentDistro != null)
            {
                string storedVal = recentDistro.GetRecentDistroIndicator(adminLevelId, indicatorName, diseaseType, start, end, ref errors);
                if (storedVal != null)
                {
                    return storedVal;
                }
            }

            AdminLevelIndicators levelInds = null;
            string key = adminLevelId + start.ToShortDateString() + end.ToShortDateString() + diseaseType.ToString();
            if (distroDict.ContainsKey(key))
                levelInds = distroDict[key];
            else
            {
                ReportOptions options = new ReportOptions();
                DistributionReportGenerator gen = new DistributionReportGenerator();
                DiseaseRepository repo = new DiseaseRepository();
                DemoRepository demo = new DemoRepository();
                var disease = repo.GetDiseaseById((int)diseaseType);
                DiseaseDistroPc dd = repo.Create(diseaseType);
                if (diseaseType == DiseaseType.STH)
                {
                    options.SelectedIndicators.Add(ReportRepository.CreateReportIndicator((int)diseaseType,
                        new KeyValuePair<string, Indicator>(indicatorName, new Indicator { Id = 141, DisplayName = "DDSTHPopulationRequiringPc" })));
                    options.SelectedIndicators.Add(ReportRepository.CreateReportIndicator((int)diseaseType,
                        new KeyValuePair<string, Indicator>(indicatorName, new Indicator { Id = 142, DisplayName = "DDSTHPsacAtRisk" })));
                    options.SelectedIndicators.Add(ReportRepository.CreateReportIndicator((int)diseaseType,
                        new KeyValuePair<string, Indicator>(indicatorName, new Indicator { Id = 143, DisplayName = "DDSTHSacAtRisk" })));
                    options.SelectedIndicators.Add(ReportRepository.CreateReportIndicator((int)diseaseType,
                        new KeyValuePair<string, Indicator>(indicatorName, new Indicator { Id = 140, DisplayName = "DDSTHPopulationAtRisk" })));
                }
                else if (diseaseType == DiseaseType.Lf)
                {
                    options.SelectedIndicators.Add(ReportRepository.CreateReportIndicator((int)diseaseType,
                    new KeyValuePair<string, Indicator>(indicatorName, new Indicator { Id = 98, DisplayName = "DDLFPopulationAtRisk" })));
                    options.SelectedIndicators.Add(ReportRepository.CreateReportIndicator((int)diseaseType,
                        new KeyValuePair<string, Indicator>(indicatorName, new Indicator { Id = 99, DisplayName = "DDLFPopulationRequiringPc" })));
                }
                else if (diseaseType == DiseaseType.Oncho)
                {
                    options.SelectedIndicators.Add(ReportRepository.CreateReportIndicator((int)diseaseType,
                    new KeyValuePair<string, Indicator>(indicatorName, new Indicator { Id = 111, DisplayName = "DDOnchoPopulationAtRisk" })));
                    options.SelectedIndicators.Add(ReportRepository.CreateReportIndicator((int)diseaseType,
                        new KeyValuePair<string, Indicator>(indicatorName, new Indicator { Id = 112, DisplayName = "DDOnchoPopulationRequiringPc" })));
                }
                else if (diseaseType == DiseaseType.Schisto)
                {
                    options.SelectedIndicators.Add(ReportRepository.CreateReportIndicator((int)diseaseType,
                        new KeyValuePair<string, Indicator>(indicatorName, new Indicator { Id = 125, DisplayName = "DDSchistoPopulationAtRisk" })));
                    options.SelectedIndicators.Add(ReportRepository.CreateReportIndicator((int)diseaseType,
                        new KeyValuePair<string, Indicator>(indicatorName, new Indicator { Id = 126, DisplayName = "DDSchistoPopulationRequiringPc" })));
                    options.SelectedIndicators.Add(ReportRepository.CreateReportIndicator((int)diseaseType,
                        new KeyValuePair<string, Indicator>(indicatorName, new Indicator { Id = 127, DisplayName = "DDSchistoSacAtRisk" })));
                }
                else if (diseaseType == DiseaseType.Trachoma)
                options.SelectedIndicators.Add(ReportRepository.CreateReportIndicator((int)diseaseType,
                    new KeyValuePair<string, Indicator>(indicatorName, new Indicator { Id = 161, DisplayName = "DDTraPopulationAtRisk" })));

                options.StartDate = start;
                options.EndDate = end;
                options.MonthYearStarts = start.Month;
                var adminlevel = demo.GetAdminLevelById(adminLevelId);
                options.SelectedAdminLevels = new List<AdminLevel> { adminlevel };
                options.IsNoAggregation = false;
                options.IsByLevelAggregation = true;
                options.IsAllLocations = false;

                levelInds = gen.GetRecentDiseaseDistribution(options);
                levelInds.StartDate = start;
                levelInds.EndDate = end;
                levelInds.DiseaseName = disease.DisplayName;
            }
            if (levelInds.Indicators.ContainsKey(indicatorName) )
            {
                if(!string.IsNullOrEmpty(levelInds.Indicators[indicatorName].Value))
                    return levelInds.Indicators[indicatorName].Value.ToString();
                else
                    return "";
            }
            string error = string.Format(Translations.ReportsNoDdInDateRange, levelInds.Name, start.ToShortDateString(), end.ToShortDateString(), levelInds.DiseaseName) + Environment.NewLine;
            if (!errors.Contains(error))
                errors += error;
            return Translations.NA;
        }
 private void RunLeishCountryAggDdReport()
 {
     // Report options
     ReportOptions reportOptions = new ReportOptions
     {
         MonthYearStarts = 1,
         StartDate = StartDate,
         EndDate = EndDate,
         IsCountryAggregation = true,
         IsByLevelAggregation = false,
         IsAllLocations = false,
         IsNoAggregation = false
     };
     // Add the indicators from the distro
     foreach (var indicator in LeishDd.Indicators)
         reportOptions.SelectedIndicators.Add(ReportRepository.CreateReportIndicator(LeishDd.Id, indicator,
             LeishDd.Disease.DisplayName, LeishDd.Disease.DisplayNameKey));
     // Run the report
     LeishCountryAggDdReport = DdReportGen.Run(new SavedReport { ReportOptions = reportOptions });
 }
Beispiel #13
0
        private ReportResult RunReport(excel.Worksheet xlsWorksheet, Dictionary<string, Indicator> indicators, ReportOptions options, IReportGenerator gen, int typeId)
        {
            foreach (var indicator in indicators.Where(i => !i.Value.IsMetaData && !i.Value.IsCalculated))
                options.SelectedIndicators.Add(ReportRepository.CreateReportIndicator(typeId, indicator));

            ReportResult result = gen.Run(new SavedReport { ReportOptions = options });
            result.DataTableResults.Columns.Remove(TranslationLookup.GetValue("Location"));
            result.DataTableResults.Columns.Remove(TranslationLookup.GetValue("Type"));
            result.DataTableResults.Columns.Remove(TranslationLookup.GetValue("Year"));
            return result;
        }
Beispiel #14
0
        private void AddReportToSheet(excel.Worksheet xlsWorksheet, Dictionary<string, Indicator> indicators, ReportOptions options, IReportGenerator gen, int typeId, string typeName, excel.Range rng)
        {
            ReportResult result = RunReport(xlsWorksheet, indicators, options, gen, typeId);
            int headerCol = 1;
            foreach (DataColumn col in result.DataTableResults.Columns)
            {
                xlsWorksheet.Cells[1, headerCol] = col.ColumnName.Replace(" - " + typeName, "");
                headerCol++;
            }

            int rowId = 2;
            foreach (DataRow dr in result.DataTableResults.Rows)
            {
                int colId = 1;
                foreach (DataColumn col in result.DataTableResults.Columns)
                {
                    rng = (excel.Range)xlsWorksheet.Cells[rowId, colId]; 
                    if (col.ColumnName.Contains(TranslationLookup.GetValue("OnchoMapSurAgeRange", "OnchoMapSurAgeRange")))
                        rng.NumberFormat = "@";
                    rng.Value = dr[col];
                    colId++;
                }
                rowId++;
            }
        }
Beispiel #15
0
 //Worksheet 3: Disease Distribution
 //aggregate to the reporting level
 //all Oncho Disease Distribution indicators
 private void AddDdPage(excel.Worksheet xlsWorksheet, excel.Range rng, List<AdminLevel> districts, DateTime start, DateTime end, int month, DiseaseDistroPc dd)
 {
     ReportOptions options = new ReportOptions { MonthYearStarts = month, StartDate = start, EndDate = end, IsCountryAggregation = false, IsByLevelAggregation = true, IsAllLocations = false, IsNoAggregation = false };
     options.SelectedAdminLevels = districts;
     DistributionReportGenerator gen = new DistributionReportGenerator(); 
     AddReportToSheet(xlsWorksheet, dd.Indicators, options, gen, disease.Id, disease.DisplayName, rng);
 }
Beispiel #16
0
 //Worksheet 4: Mapping Survey
 //no aggregation - list all
 //all Oncho Mapping indicators
 private void Add4(excel.Worksheet xlsWorksheet, excel.Range rng, List<AdminLevel> districts, DateTime start, DateTime end, int month)
 {
     ReportOptions options = new ReportOptions { MonthYearStarts = month, StartDate = start, EndDate = end, IsCountryAggregation = false, IsByLevelAggregation = false, IsAllLocations = true, IsNoAggregation = true };
     SurveyRepository repo = new SurveyRepository();
     SurveyType survey = repo.GetSurveyType((int)StaticSurveyType.OnchoMapping);
     SurveyReportGenerator gen = new SurveyReportGenerator();
     AddReportToSheet(xlsWorksheet, survey.Indicators, options, gen, (int)StaticSurveyType.OnchoMapping, survey.SurveyTypeName, rng);
 }
        protected List<int> DetermineInterventionsByDiseasesTargeted(List<IntvType> intvTypes, ReportOptions reportOptions, List<Disease> diseasesToFilterBy)
        {
            List<IntvBase> interventions = GetIntvsByReportOptions(intvTypes, reportOptions);

            // Filter the interventions based on whether or not they have the correct diseases targeted
            List<int> filteredIntvIds = new List<int>();
            foreach (IntvBase intv in interventions)
            {
                // Get the diseases targeted indicator
                IndicatorValue indVal = intv.IndicatorValues.Where(i => i.Indicator.DisplayName == "PcIntvDiseases").FirstOrDefault();
                if (indVal == null)
                    continue;

                // Get the value of the diseases targeted indicator
                string selectedDiseasesStr = indVal.DynamicValue;

                // Make sure the current intervention has one of the diseases targeted selected
                foreach (Disease disease in diseasesToFilterBy)
                {
                    if (selectedDiseasesStr.Contains(disease.DisplayNameKey))
                    {
                        filteredIntvIds.Add(intv.Id);
                        break;
                    }
                }
            }

            return filteredIntvIds;
        }
        protected List<IntvBase> GetIntvsByReportOptions(List<IntvType> intvTypes, ReportOptions reportOptions)
        {
            // Build a collection of ids for the intervention types
            List<int> intvTypeIds = new List<int>();
            foreach (IntvType type in intvTypes)
            {
                intvTypeIds.Add(type.Id);
            }

            // Build a collection of ids for the admin units
            List<int> adminUnitIds = new List<int>();
            foreach (AdminLevel level in reportOptions.SelectedAdminLevels)
            {
                adminUnitIds.Add(level.Id);
            }

            // Get all interventions that match the report options
            List<IntvBase> interventions = new List<IntvBase>();
            foreach (int year in reportOptions.Years)
            {
                DateTime startDate = new DateTime(year, 1, 1);
                DateTime yearEndDate = new DateTime(year, 1, 1).AddYears(1).AddDays(-1);
                List<IntvBase> interventionsForYear = IntvRepo.GetAllIntvInRangeByAdminUnit(intvTypeIds, startDate, yearEndDate, adminUnitIds);
                // Add them to the main collection
                interventions.AddRange(interventionsForYear);
            }

            return interventions;
        }
Beispiel #19
0
        protected Dictionary<int, DataRow> GetIntvsAggregatedToReportingLevel(DateTime start, DateTime end, List<AdminLevel> units)
        {
            IntvRepository iRepo = new IntvRepository();
            ReportOptions options = new ReportOptions
            {
                MonthYearStarts = start.Month,
                StartDate = start,
                EndDate = end,
                IsCountryAggregation = false,
                IsByLevelAggregation = true,
                IsAllLocations = false,
                IsNoAggregation = false,
                IsGroupByRange = true,

            };
            options.SelectedAdminLevels = units;
            IntvReportGenerator gen = new IntvReportGenerator();
            var intvIds = new List<int> { 2, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 };
            foreach (int id in intvIds)
                AddIntvIndicators(options, id, iRepo);
            ReportResult ddResult = gen.Run(new SavedReport { ReportOptions = options });
            Dictionary<int, DataRow> intvData = new Dictionary<int, DataRow>();
            foreach (DataRow dr in ddResult.DataTableResults.Rows)
            {
                int id = 0;
                if (int.TryParse(dr["ID"].ToString(), out id))
                {
                    if (intvData.ContainsKey(id))
                        intvData[id] = dr;
                    else
                        intvData.Add(id, dr);
                }
            }
            return intvData;
        }
 protected void AddIndicators(int id, string name, DiseaseDistroPc dd, ReportOptions options)
 {
     options.SelectedIndicators.Add(ReportRepository.CreateReportIndicator(id,
                        new KeyValuePair<string, Indicator>(name, dd.Indicators[name])));
 }
Beispiel #21
0
 //Worksheet 10: SAEs
 //list all in which Oncho was chosen from "Which parasitic/bacterial infections did the patient have" indicator
 //all SAE indicators
 //add an additional calculated field: "Duration between dates of treatment and appearance of symptoms" = TBD
 private void Add10(excel.Worksheet xlsWorksheet, excel.Range rng, List<AdminLevel> districts, DateTime start, DateTime end, int month)
 {
     ReportOptions options = new ReportOptions { MonthYearStarts = month, StartDate = start, EndDate = end, IsCountryAggregation = false, IsByLevelAggregation = false, IsAllLocations = true, IsNoAggregation = true };
     ProcessRepository repo = new ProcessRepository();
     ProcessType p = repo.GetProcessType((int)StaticProcessType.SAEs);
     ProcessReportGenerator gen = new ProcessReportGenerator();
     ReportResult result = RunReport(xlsWorksheet, p.Indicators, options, gen, (int)StaticProcessType.SAEs);
     int headerCol = 1;
     foreach (DataColumn col in result.DataTableResults.Columns)
     {
         xlsWorksheet.Cells[1, headerCol] = col.ColumnName.Replace(" - " + p.TypeName, "");
         headerCol++;
     }
     
     int rowId = 2;
     foreach (DataRow dr in result.DataTableResults.Rows)
     {
         if (dr[TranslationLookup.GetValue("SAEWhichparasitichave", "SAEWhichparasitichave") + " - " + p.TypeName].ToString().Contains(TranslationLookup.GetValue("SaeOncho", "SaeOncho")))
         {
             int colId = 1;
             foreach (DataColumn col in result.DataTableResults.Columns)
             {
                 xlsWorksheet.Cells[rowId, colId] = dr[col];
                 colId++;
             }
             rowId++;
         }
     }
 }
 /// <summary>
 /// Note aggregation is easy for demo, because it is pre aggregated
 /// </summary>
 /// <param name="options"></param>
 /// <param name="dt"></param>
 /// <returns></returns>
 public DataTable CreateDemoReport(ReportOptions options, DataTable dt)
 {
     Dictionary<string, ReportIndicator> keys = new Dictionary<string, ReportIndicator>();
     foreach (var i in options.SelectedIndicators)
         keys.Add(i.Key, i);
     OleDbConnection connection = new OleDbConnection(DatabaseData.Instance.AccessConnectionString);
     using (connection)
     {
         connection.Open();
         try
         {
             string adminFilter = "";
             if (options.IsByLevelAggregation || (options.IsNoAggregation && !options.IsAllLocations) || options.IsCountryAggregation)
                 adminFilter = " and AdminLevels.Id in (" + String.Join(", ", options.SelectedAdminLevels.Select(a => a.Id.ToString()).ToArray()) + ") ";
             else if (options.IsAllLocations && options.ShowOnlyRedistrictedUnits)
                 adminFilter = " AND AdminLevels.RedistrictIdForMother > 0 ";
             OleDbCommand command = new OleDbCommand(@"Select 
                         a.ID, 
                         AdminLevels.Id as aID, 
                         [DateDemographyData] as DateReported, 
                         AdminLevels.DisplayName, 
                         t.DisplayName as TName
                         ,YearCensus 
                         ,YearProjections 
                         ,GrowthRate 
                         ,PercentRural 
                         ,TotalPopulation 
                         ,Pop0Month 
                         ,PopPsac 
                         ,PopSac 
                         ,Pop5yo 
                         ,PopAdult 
                         ,PopFemale 
                         ,PopMale 
                         ,RedistrictIdForDaughter
                         ,RedistrictIdForMother
                         ,Notes
                     FROM ((AdminLevelDemography a INNER JOIN AdminLevels on a.AdminLevelId = AdminLevels.ID)
                         INNER JOIN AdminLevelTypes t on t.Id = AdminLevels.AdminLevelTypeId)
                     WHERE a.IsDeleted = 0 " + CreateYearFilter(options, "DateDemographyData") +
                     adminFilter +
                     "ORDER BY  t.AdminLevel, AdminLevels.SortOrder "
                 , connection);
             using (OleDbDataReader reader = command.ExecuteReader())
             {
                 while (reader.Read())
                 {
                     DataRow dr = dt.NewRow();
                     dr["ID"] = reader.GetValueOrDefault<int>("aID");
                     dr[TranslationLookup.GetValue("Location")] = reader.GetValueOrDefault<string>("DisplayName");
                     dr[TranslationLookup.GetValue("Type")] = TranslationLookup.GetValue(reader.GetValueOrDefault<string>("TName"), reader.GetValueOrDefault<string>("TName"));
                     int year = Util.GetYearReported(options.MonthYearStarts, reader.GetValueOrDefault<DateTime>("DateReported")); 
                     DateTime startMonth = new DateTime(year, options.MonthYearStarts, 1);
                     dr["YearNumber"] = year;
                     dr["DaughterId"] = reader.GetValueOrDefault<int>("RedistrictIdForDaughter");
                     dr["MotherId"] = reader.GetValueOrDefault<int>("RedistrictIdForMother");
                     dr[TranslationLookup.GetValue("Year")] = startMonth.ToString("MMM yyyy") + "-" + startMonth.AddYears(1).AddMonths(-1).ToString("MMM yyyy");
                     if (keys.ContainsKey("YearCensus")) dr[TranslationLookup.GetValue("YearCensus")] = reader.GetValueOrDefault<Nullable<int>>("YearCensus");
                     if (keys.ContainsKey("YearProjections")) dr[TranslationLookup.GetValue("YearProjections")] = reader.GetValueOrDefault<Nullable<int>>("YearProjections");
                     if (keys.ContainsKey("GrowthRate")) dr[TranslationLookup.GetValue("GrowthRate")] = reader.GetValueOrDefault<Nullable<double>>("GrowthRate");
                     if (keys.ContainsKey("PercentRural")) dr[TranslationLookup.GetValue("PercentRural")] = reader.GetValueOrDefault<Nullable<double>>("PercentRural");
                     if (keys.ContainsKey("TotalPopulation")) dr[TranslationLookup.GetValue("TotalPopulation")] = reader.GetValueOrDefault<Nullable<int>>("TotalPopulation");
                     if (keys.ContainsKey("Pop0Month")) dr[TranslationLookup.GetValue("Pop0Month")] = reader.GetValueOrDefault<Nullable<int>>("Pop0Month");
                     if (keys.ContainsKey("PopPsac")) dr[TranslationLookup.GetValue("PopPsac")] = reader.GetValueOrDefault<Nullable<int>>("PopPsac");
                     if (keys.ContainsKey("PopSac")) dr[TranslationLookup.GetValue("PopSac")] = reader.GetValueOrDefault<Nullable<int>>("PopSac");
                     if (keys.ContainsKey("Pop5yo")) dr[TranslationLookup.GetValue("Pop5yo")] = reader.GetValueOrDefault<Nullable<int>>("Pop5yo");
                     if (keys.ContainsKey("PopAdult")) dr[TranslationLookup.GetValue("PopAdult")] = reader.GetValueOrDefault<Nullable<int>>("PopAdult");
                     if (keys.ContainsKey("PopFemale")) dr[TranslationLookup.GetValue("PopFemale")] = reader.GetValueOrDefault<Nullable<int>>("PopFemale");
                     if (keys.ContainsKey("PopMale")) dr[TranslationLookup.GetValue("PopMale")] = reader.GetValueOrDefault<Nullable<int>>("PopMale");
                     if (keys.ContainsKey("Notes")) dr[TranslationLookup.GetValue("Notes")] = reader.GetValueOrDefault<string>("Notes");
                     dt.Rows.Add(dr);
                 }
                 reader.Close();
             }
         }
         catch (Exception)
         {
             throw;
         }
     }
     return dt;
 }
        public static string CreateYearFilter(ReportOptions options, string dateName)
        {
            if(options.StartDate == DateTime.MinValue && options.EndDate == DateTime.MinValue)
                return "";

            if (options.StartDate == DateTime.MinValue)
            {
                return string.Format(" AND {0} <= cdate('{1}') ", dateName,
                    options.EndDate.ToShortDateString());
            }
            else if (options.EndDate == DateTime.MinValue)
            {
                return string.Format(" AND {0} >= cdate('{1}') ", dateName,
                    options.StartDate.ToShortDateString());
            }
            else
            {
                return string.Format(" AND {0} >= cdate('{1}') AND {0} <= cdate('{2}') ", dateName,
                    options.StartDate.ToShortDateString(),
                    options.EndDate.ToShortDateString());
            }
        }
Beispiel #24
0
        /// <summary>
        /// Adds the LF sheet
        /// </summary>
        /// <param name="xlsWorksheet"></param>
        /// <param name="start"></param>
        /// <param name="end"></param>
        private void AddLfMm(excel.Worksheet xlsWorksheet, DateTime start, DateTime end)
        {
            ReportOptions options = new ReportOptions { MonthYearStarts = 1, StartDate = start, EndDate = end, IsCountryAggregation = true, IsByLevelAggregation = false, IsAllLocations = false, IsNoAggregation = false };
            IntvReportGenerator gen = new IntvReportGenerator();
            IntvRepository repo = new IntvRepository();
            SurveyRepository surveys = new SurveyRepository();
            // Indicator parser
            IndicatorParser indicatorParser = new IndicatorParser();
            indicatorParser.LoadRelatedLists();

            int rowCount = 0;
            IntvType type = repo.GetIntvType((int)StaticIntvType.LfMorbidityManagement);
            foreach (var indicator in type.Indicators)
                if (!indicator.Value.IsCalculated)
                    options.SelectedIndicators.Add(ReportRepository.CreateReportIndicator(type.Id, indicator));
            ReportResult result = gen.Run(new SavedReport { ReportOptions = options });

            // Top horizontal columns
            foreach (DataRow dr in result.DataTableResults.Rows)
            {
                foreach (DataColumn col in result.DataTableResults.Columns)
                {
                    if (col.ColumnName.Contains(TranslationLookup.GetValue("LFMMDPNumLymphoedemaPatients", "LFMMDPNumLymphoedemaPatients") + " -"))
                        xlsWorksheet.Cells[5, 10] = dr[col];
                    if (col.ColumnName.Contains(TranslationLookup.GetValue("LFMMDPNumLymphoedemaPatientsTreated", "LFMMDPNumLymphoedemaPatientsTreated") + " -"))
                        xlsWorksheet.Cells[7, 10] = dr[col];
                    if (col.ColumnName.Contains(TranslationLookup.GetValue("LFMMDPNumHydroceleCases", "LFMMDPNumHydroceleCases") + " -"))
                        xlsWorksheet.Cells[8, 10] = dr[col];
                    if (col.ColumnName.Contains(TranslationLookup.GetValue("LFMMDPNumHydroceleCasesTreated", "LFMMDPNumHydroceleCasesTreated") + " -"))
                        xlsWorksheet.Cells[9, 10] = dr[col];
                }
            }

            // Last half of year (J6)
            options.StartDate = start.AddMonths(6);
            result = gen.Run(new SavedReport { ReportOptions = options });
            foreach (DataRow dr in result.DataTableResults.Rows)
            {
                foreach (DataColumn col in result.DataTableResults.Columns)
                {
                    if (col.ColumnName.Contains(TranslationLookup.GetValue("LFMMDPNumLymphoedemaPatients", "LFMMDPNumLymphoedemaPatients") + " -"))
                        xlsWorksheet.Cells[6, 10] = dr[col];
                }
            }

            // Get surveys for rows
            var lfSurveys = surveys.GetByTypeForDistrictsInDateRange(new List<int> { (int)StaticSurveyType.LfMapping, (int)StaticSurveyType.LfSentinel, (int)StaticSurveyType.LfTas }, start, end);
            int rowNumber = 15;
            foreach (SurveyBase survey in lfSurveys.OrderBy(s => s.SortOrder))
            {
                foreach (var adminLevel in survey.AdminLevels)
                {
                    bool isMfTestType = false;
                    
                    // Static indicators
                    xlsWorksheet.Cells[rowNumber, (int)ExcelCol.B] = adminLevel.Name;
                    if (survey.TypeOfSurvey.Id == (int)StaticSurveyType.LfMapping)
                    {
                        var testTypeVal = survey.IndicatorValues.FirstOrDefault(v => v.Indicator.DisplayName == "LFMapSurTestType");
                        if (testTypeVal != null && testTypeVal.DynamicValue == "Mf")
                            isMfTestType = true; 

                        xlsWorksheet.Cells[rowNumber, (int)ExcelCol.D] = TranslationLookup.GetValue("Mapping", "Mapping");
                    }
                    else if (survey.TypeOfSurvey.Id == (int)StaticSurveyType.LfSentinel)
                    {
                        var testTypeVal = survey.IndicatorValues.FirstOrDefault(v => v.Indicator.DisplayName == "LFSurTestType");
                        if (testTypeVal != null && testTypeVal.DynamicValue == "Mf")
                            isMfTestType = true;

                        xlsWorksheet.Cells[rowNumber, (int)ExcelCol.D] = survey.SiteType;
                        if (survey.SentinelSiteId.HasValue)
                        {
                            var site = surveys.GetSiteById(survey.SentinelSiteId.Value);
                            if (site.Lat.HasValue)
                                xlsWorksheet.Cells[rowNumber, (int)ExcelCol.F] = Math.Round(site.Lat.Value, 2);
                            if (site.Lng.HasValue)
                                xlsWorksheet.Cells[rowNumber, (int)ExcelCol.G] = Math.Round(site.Lng.Value, 2);
                            // Name of survey site
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.C] = site.SiteName;
                        }
                        else
                        {
                            if (survey.Lat.HasValue)
                                xlsWorksheet.Cells[rowNumber, (int)ExcelCol.F] = Math.Round(survey.Lat.Value, 2);
                            if (survey.Lng.HasValue)
                                xlsWorksheet.Cells[rowNumber, (int)ExcelCol.G] = Math.Round(survey.Lng.Value, 2);
                            // Name of survey site
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.C] = survey.SpotCheckName;

                        }
                    }
                    else if (survey.TypeOfSurvey.Id == (int)StaticSurveyType.LfTas)
                    {
                        // Year of Start date of MDA of earliest Intervention
                        List<IntvBase> interventions = repo.GetAll(new List<int>
                        {
                            (int)StaticIntvType.Alb, (int)StaticIntvType.Alb2, (int)StaticIntvType.DecAlb, (int)StaticIntvType.Ivm, (int)StaticIntvType.IvmAlb,
                            (int)StaticIntvType.IvmPzq, (int)StaticIntvType.IvmPzqAlb, (int)StaticIntvType.Mbd, (int)StaticIntvType.Pzq, (int)StaticIntvType.PzqAlb,
                            (int)StaticIntvType.PzqMbd, (int)StaticIntvType.ZithroTeo
                        }, new List<int> {adminLevel.Id});
                        if (interventions.Count > 0) {
                            // Get all the MDA Start date indicators
                            List<string> mdaStarts = interventions.SelectMany(x => x.IndicatorValues).Where(v => v.Indicator.DisplayName == "PcIntvStartDateOfMda")
                                .Select(x => x.DynamicValue).ToList();
                            if (mdaStarts.Count > 0) {
                                // Get the earliest one
                                DateTime earliestMda = Convert.ToDateTime(mdaStarts.OrderBy(x => Convert.ToDateTime(x)).FirstOrDefault());
                                // Add it to the worksheet
                                xlsWorksheet.Cells[rowNumber, (int)ExcelCol.H] = earliestMda.Year;
                            }
                        }
                    }
 

                    // Dynamic indicators
                    foreach (IndicatorValue val in survey.IndicatorValues)
                    {
                        // Eval name
                        if (val.Indicator.DisplayName == "EuName")
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.A] = indicatorParser.Parse(val.Indicator.DataTypeId, val.IndicatorId, val.DynamicValue);
                        // Name of survey site
                        else if (val.Indicator.DisplayName == "LFMapSurSiteNames")
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.C] = val.DynamicValue;
                        // TAS objective
                        else if (val.Indicator.DisplayName == "TASTasObjective")
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.D] = TranslationLookup.GetValue(val.DynamicValue, val.DynamicValue);
                        else if (val.Indicator.DisplayName == "LFMapSurStartDateOfSurvey" || val.Indicator.DisplayName == "LFSurStartDateOfSurvey" || val.Indicator.DisplayName == "TASStartDateOfSurvey")
                        {
                            DateTime date;
                            if (DateTime.TryParse(val.DynamicValue, out date))
                                xlsWorksheet.Cells[rowNumber, (int)ExcelCol.E] = date.ToString("MMMM");
                        }
                        else if (val.Indicator.DisplayName == "LFMapSurLatitude" && !string.IsNullOrEmpty(val.DynamicValue))
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.F] = Math.Round(Convert.ToDouble(val.DynamicValue), 2);
                        else if (val.Indicator.DisplayName == "LFMapSurLongitude" && !string.IsNullOrEmpty(val.DynamicValue))
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.G] = Math.Round(Convert.ToDouble(val.DynamicValue), 2);
                        else if (val.Indicator.DisplayName == "LFSurDateOfTheFirstRoundOfPc")
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.H] = val.DynamicValue;
                        else if (val.Indicator.DisplayName == "LFSurNumberOfRoundsOfPcCompletedPriorToS" || val.Indicator.DisplayName == "4190984d-f272-4359-8414-6e7ef06fc4bc")
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.I] = val.DynamicValue;
                        //else if (val.Indicator.DisplayName == "LFMapSurTestType" || val.Indicator.DisplayName == "LFSurTestType")
                        //    xlsWorksheet.Cells[rowNumber, 9] = TranslationLookup.GetValue(val.DynamicValue, val.DynamicValue);
                        // MF: Number of people examined
                        else if (val.Indicator.DisplayName == "LFMapSurNumberOfIndividualsExamined" || val.Indicator.DisplayName == "LFSurNumberOfIndividualsExamined")
                        {
                            if (isMfTestType) // MF: Number of people examined
                                xlsWorksheet.Cells[rowNumber, (int)ExcelCol.J] = val.DynamicValue;
                            else // Ag/Ab: Number of people examined
                                xlsWorksheet.Cells[rowNumber, (int)ExcelCol.S] = val.DynamicValue;
                        }
                        // MF: Number of people positive
                        else if (val.Indicator.DisplayName == "LFSurNumberOfIndividualsPositive" || val.Indicator.DisplayName == "LFMapSurNumberOfIndividualsPositive")
                        {
                            if (isMfTestType) // MF: Number of people positive
                                xlsWorksheet.Cells[rowNumber, (int)ExcelCol.K] = val.DynamicValue;
                            else // Ag/Ab: Number of people positive
                                xlsWorksheet.Cells[rowNumber, (int)ExcelCol.T] = val.DynamicValue;
                        }
                        // mean dens
                        //else if (val.Indicator.DisplayName == "LFMapSurMeanDensity" || val.Indicator.DisplayName == "LFSurMeanDensity")
                        //    xlsWorksheet.Cells[rowNumber, 13] = val.DynamicValue;
                        // count
                        //else if (val.Indicator.DisplayName == "LFSurCount" || val.Indicator.DisplayName == "LFMapSurCount")
                        //    xlsWorksheet.Cells[rowNumber, 14] = val.DynamicValue;
                        // community load
                        //else if (val.Indicator.DisplayName == "LFMapSurCommunityMfLoad" || val.Indicator.DisplayName == "LFSurCommunityMfLoad")
                        //    xlsWorksheet.Cells[rowNumber, 15] = val.DynamicValue;

                        // MF: % Positive
                        else if (val.Indicator.DisplayName == "LFMapSurPositive" || val.Indicator.DisplayName == "LFSurPositive")
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.L] = val.DynamicValue;
                        // Test Type
                        else if (val.Indicator.DisplayName == "LFMapSurTestType" || val.Indicator.DisplayName == "LFSurTestType" || val.Indicator.DisplayName == "TASDiagnosticTest")
                        {
                            if (val.Indicator.DisplayName == "TASDiagnosticTest")
                                xlsWorksheet.Cells[rowNumber, (int)ExcelCol.M] = val.DynamicValue;
                            else
                            {
                                if (!isMfTestType)
                                    xlsWorksheet.Cells[rowNumber, (int)ExcelCol.M] = val.DynamicValue;
                            }
                        }
                        // Age range
                        else if (val.Indicator.DisplayName == "LFSurAgeRange" || val.Indicator.DisplayName == "LFMapSurAgeRange" || val.Indicator.DisplayName == "TASAgeRange")
                        {
                            if (val.Indicator.DisplayName == "TASAgeRange")
                                xlsWorksheet.Cells[rowNumber, (int)ExcelCol.N] = val.DynamicValue;
                            else
                            {
                                if (!isMfTestType)
                                    xlsWorksheet.Cells[rowNumber, (int)ExcelCol.N] = val.DynamicValue;
                            }
                        }
                        // Survey site
                        else if (val.Indicator.DisplayName == "LFMapSurMappingSiteLocation" || val.Indicator.DisplayName == "eab663f6-1eb8-4efc-85da-2844ee720020" || val.Indicator.DisplayName == "TASLocationType")
                        {
                            if (val.Indicator.DisplayName == "TASLocationType")
                                xlsWorksheet.Cells[rowNumber, (int)ExcelCol.O] = val.DynamicValue;
                            else
                            {
                                if (!isMfTestType)
                                    xlsWorksheet.Cells[rowNumber, (int)ExcelCol.O] = val.DynamicValue;
                            }
                        }
                        // Ag/Ab: Survey type
                        else if (val.Indicator.DisplayName == "TASSurveyType")
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.P] = val.DynamicValue;
                        // Ag/Ab: # schools or EA targeted
                        else if (val.Indicator.DisplayName == "TASTargetNumberOfSchoolsOrEas")
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.Q] = val.DynamicValue;
                        // Ag/Ab: Target sample size
                        else if (val.Indicator.DisplayName == "LFMapSurTargetSampleSize" || val.Indicator.DisplayName == "LFSurTargetSampleSize" || val.Indicator.DisplayName == "TASTargetSampleSize")
                        {
                            if (val.Indicator.DisplayName == "TASTargetSampleSize")
                                xlsWorksheet.Cells[rowNumber, (int)ExcelCol.R] = val.DynamicValue;
                            else
                            {
                                if (!isMfTestType)
                                    xlsWorksheet.Cells[rowNumber, (int)ExcelCol.R] = val.DynamicValue;
                            }
                        }
                        // Ag/Ab: Number of people examined
                        else if (val.Indicator.DisplayName == "d807913f-b3a1-4948-a2b3-54eb0800a3bc")
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.S] = val.DynamicValue;
                        // Ag/Ab: Number of people positive
                        else if (val.Indicator.DisplayName == "TASActualSampleSizePositive")
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.T] = val.DynamicValue;
                        // Ag/Ab: Critical cut-off
                        else if (val.Indicator.DisplayName == "TASCriticalCutoffValue")
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.V] = val.DynamicValue;
                        // Ag/Ab: Decision
                        else if (val.Indicator.DisplayName == "TASCriticalCutoff")
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.W] = TranslationLookup.GetValue(val.DynamicValue, val.DynamicValue);
                        // Lymphoedema: Number of people examined
                        else if (val.Indicator.DisplayName == "LFSurExaminedLympho" || val.Indicator.DisplayName == "LFMapSurExaminedLympho")
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.X] = val.DynamicValue;
                        // Lymphoedema: Number of people positive
                        else if (val.Indicator.DisplayName == "LFMapSurNumberOfCasesOfLymphoedema" || val.Indicator.DisplayName == "LFSurPosLympho")
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.Y] = val.DynamicValue;
                        // Hydrocele: Number of people examined
                        else if (val.Indicator.DisplayName == "LFSurExaminedHydro" || val.Indicator.DisplayName == "LFMapSurExaminedHydro1")
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.AA] = val.DynamicValue;
                        // Hydrocele: Number of people positive
                        else if (val.Indicator.DisplayName == "LFMapSurNumberOfCasesOfHydrocele" || val.Indicator.DisplayName == "LFSurPosHydro")
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.AB] = val.DynamicValue;
                        // Notes
                        else if (val.Indicator.DisplayName == "Notes")
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.AD] = val.DynamicValue;

                    }
                    rowNumber++;
                    rowCount++;
                }
            }

            // run formula
            xlsWorksheet.Cells[3, 5] = rowCount;

        }
 private void GetDdForDisease(DateTime start, DateTime end, List<AdminLevel> demography, out DiseaseDistroPc ddType, out Dictionary<int, DataRow> dd, DiseaseType dType)
 {
     ReportOptions options = new ReportOptions
     {
         MonthYearStarts = start.Month,
         StartDate = start,
         EndDate = end,
         IsCountryAggregation = false,
         IsByLevelAggregation = true,
         IsAllLocations = false,
         IsNoAggregation = false
     };
     options.SelectedAdminLevels = demography;
     DistributionReportGenerator gen = new DistributionReportGenerator();
     ddType = diseaseRepo.Create(dType);
     foreach (var indicator in ddType.Indicators.Where(i => i.Value.DataTypeId != (int)IndicatorDataType.Calculated))
         options.SelectedIndicators.Add(ReportRepository.CreateReportIndicator(ddType.Id, indicator));
     ReportResult ddResult = gen.Run(new SavedReport { ReportOptions = options });
     dd = new Dictionary<int, DataRow>();
     foreach (DataRow dr in ddResult.DataTableResults.Rows)
     {
         int id = 0;
         if (int.TryParse(dr["ID"].ToString(), out id))
         {
             if (dd.ContainsKey(id))
                 dd[id] = dr;
             else
                 dd.Add(id, dr);
         }
     }
 }