Ejemplo n.º 1
0
 public void DoNext()
 {
     DiseaseRepository diseases = new DiseaseRepository();
     vm.Diseases = diseases.GetSelectedDiseases();
     vm.DiseaseStepNumber = 0;
     OnSwitchStep(new StepDdReview(vm, this));
 }
Ejemplo n.º 2
0
 public DiseaseDistroPcVm(AdminLevel a, DiseaseDistroPc s, ICalcIndicators c)
 {
     r = new DiseaseRepository();
     this.model = s;
     adminLevel = a;
     calc = c;
 }
Ejemplo n.º 3
0
 public DiseaseDistroPcVm(AdminLevel a, int did, ICalcIndicators c)
 {
     adminLevel = a;
     r = new DiseaseRepository();
     model = r.Create((DiseaseType)did);
     model.AdminLevelId = adminLevel.Id;
     calc = c;
 }
Ejemplo n.º 4
0
 public void LoadAvailable(bool filterPc)
 {
     r = new DiseaseRepository();
     diseases = r.GetSelectedDiseases();
     if(filterPc)
         diseases = diseases.Where(d => d.DiseaseType == Translations.PC).ToList();
     diseaseBindingSource.DataSource = diseases;
 }
Ejemplo n.º 5
0
 private void lnkDistro_ClickOverride()
 {
     ReportRepository repo = new ReportRepository();
     opts.EntityType = Model.IndicatorEntityType.DiseaseDistribution;
     opts.AvailableIndicators = repo.GetDiseaseDistroIndicators();
     DiseaseRepository typeRepo = new DiseaseRepository();
     var types = typeRepo.GetSelectedDiseases();
     opts.FormTypes = types.Select(t => t.DisplayName).OrderBy(t => t).ToList();
     OnSwitchStep(new IndStepIndicators(opts));
 }
Ejemplo n.º 6
0
 private void IndicatorControl_Load(object sender, EventArgs e)
 {
     if (!DesignMode)
     {
         Localizer.TranslateControl(this);
         dtStart.Value = start;
         dtEnd.Value = end;
         tblMetaData.Visible = false;
         tblTopControls.Visible = false;
         DiseaseRepository diseases = new DiseaseRepository();
         selectedDiseases = diseases.GetSelectedDiseases().Select(d => d.DisplayName).ToList();
     }
 }
Ejemplo n.º 7
0
 private void btnSave_Click_1(object sender, EventArgs e)
 {
     if (!model.IsValid())
     {
         MessageBox.Show(Translations.ValidationError, Translations.ValidationErrorTitle);
         return;
     }
     model.UserDefinedName = model.DisplayName;
     bindingSource1.EndEdit();
     DiseaseRepository r = new DiseaseRepository();
     int userid = ApplicationData.Instance.GetUserId();
     r.Save(model, userid);
     OnSave(model);
     this.Close();
 }
Ejemplo n.º 8
0
 void importerWorker_DoWork(object sender, DoWorkEventArgs e)
 {
     try
     {
         int userId = ApplicationData.Instance.GetUserId();
         WorkerPayload payload = (WorkerPayload)e.Argument;
         ImportResult result = payload.Importer.UpdateData(payload.FileName, userId, payload.Forms);
         if (result.WasSuccess)
         {
             DiseaseRepository repo = new DiseaseRepository();
             if (payload.DiseaseType == "CM")
                 repo.Save(result.Forms.Cast<DiseaseDistroCm>().ToList(), userId);
             else
                 repo.Save(result.Forms.Cast<DiseaseDistroPc>().ToList(), userId);
         }
         e.Result = result;
     }
     catch (Exception ex)
     {
         Logger log = new Logger();
         log.Error("Error updating distribution forms during split. SplitDistro:importerWorker_DoWork. ", ex);
         throw;
     }
 }
Ejemplo n.º 9
0
        private List<KeyValuePair<string, int>> GetFormTypes(DataRow dr)
        {
            var result = new List<KeyValuePair<string, int>>();
            if (!string.IsNullOrEmpty(dr["Type ID"].ToString()))
            {
                var entityType = (IndicatorEntityType)Convert.ToInt32(dr["Type ID"]);

                switch (entityType)
                {
                    case IndicatorEntityType.DiseaseDistribution:
                        DiseaseRepository typeRepo = new DiseaseRepository();
                        result = typeRepo.GetSelectedDiseases().Select(d => new KeyValuePair<string, int>(d.DisplayName, d.Id)).ToList();
                        break;
                    case IndicatorEntityType.Intervention:
                        IntvRepository intv = new IntvRepository();
                        result = intv.GetAllTypes().Select(d => new KeyValuePair<string, int>(d.IntvTypeName, d.Id)).ToList();
                        break;
                    case IndicatorEntityType.Survey:
                        SurveyRepository sRepo = new SurveyRepository();
                        result = sRepo.GetSurveyTypes().Select(d => new KeyValuePair<string, int>(d.SurveyTypeName, d.Id)).ToList();
                        break;
                    case IndicatorEntityType.Process:
                        ProcessRepository pRepo = new ProcessRepository();
                        result = pRepo.GetProcessTypes().Select(d => new KeyValuePair<string, int>(d.TypeName, d.Id)).ToList();
                        break;
                }        
            }
            return result;
        }
        public override ReportResult Run(SavedReport report)
        {
            EliminationReportOptions standardOpts = (EliminationReportOptions)report.StandardReportOptions;
            ReportOptions options = report.ReportOptions;
            DistributionReportGenerator gen = new DistributionReportGenerator();
            DiseaseRepository repo = new DiseaseRepository();
            DemoRepository demo = new DemoRepository();
            foreach (var disease in standardOpts.Diseases)
            {
                DiseaseDistroPc dd = repo.Create((DiseaseType)disease.Id);

                switch (disease.Id)
                {
                    case (int)DiseaseType.Lf:
                        AddIndicators(disease.Id, "DDLFDiseaseDistributionPcInterventions", dd, options);
                        break;
                    case (int)DiseaseType.Trachoma:
                        AddIndicators(disease.Id, "DDTraDiseaseDistributionPcInterventions", dd, options);
                        break;
                    case (int)DiseaseType.Oncho:
                        AddIndicators(disease.Id, "DDOnchoDiseaseDistributionPcInterventio", dd, options);
                        break;
                    case (int)DiseaseType.STH:
                        AddIndicators(disease.Id, "DDSTHDiseaseDistributionPcInterventions", dd, options);
                        break;
                    case (int)DiseaseType.Schisto:
                        AddIndicators(disease.Id, "DDSchistoDiseaseDistributionPcIntervent", dd, options);
                        break;
                    default:
                        break;
                }
            }

            // need to add the proper sumation stuff
            report.ReportOptions.IsByLevelAggregation = true;
            report.ReportOptions.IsCountryAggregation = false;
            report.ReportOptions.IsNoAggregation = false;
            report.ReportOptions.SelectedAdminLevels = demo.GetAdminLevelByLevel(standardOpts.DistrictType.LevelNumber).Where(a => a.LevelNumber == standardOpts.DistrictType.LevelNumber).ToList();

            // run report
            ReportResult result = gen.Run(report);

            Dictionary<string, DataRow> years = new Dictionary<string,DataRow>();
            DataTable summed = new DataTable();
            summed.Columns.Add(new DataColumn(TranslationLookup.GetValue("Location")));
            summed.Columns.Add(new DataColumn(TranslationLookup.GetValue("Year"), typeof(string)));
            summed.Columns.Add(new DataColumn(string.Format(TranslationLookup.GetValue("EliminationEndemicDistricts"), standardOpts.DistrictType.DisplayName), typeof(int)));
            summed.Columns.Add(new DataColumn(string.Format(TranslationLookup.GetValue("EliminationStoppedDistricts"), standardOpts.DistrictType.DisplayName), typeof(int)));
            
            foreach (DataRow row in result.DataTableResults.Rows)
            {
                string endemicty = "";
                int totalEndemic = 0, totalStopped = 0;
                if (result.DataTableResults.Columns.Contains(TranslationLookup.GetValue("DDLFDiseaseDistributionPcInterventions") + " - " + TranslationLookup.GetValue("LF")))
                {
                    endemicty = row[TranslationLookup.GetValue("DDLFDiseaseDistributionPcInterventions") + " - " + TranslationLookup.GetValue("LF")].ToString();
                    if (endemicty == TranslationLookup.GetValue("LfEnd1") || endemicty == TranslationLookup.GetValue("LfEndPending"))
                        totalEndemic++;
                    else if (endemicty == TranslationLookup.GetValue("LfEnd100"))
                        totalStopped++;
                }
                if (result.DataTableResults.Columns.Contains(TranslationLookup.GetValue("DDOnchoDiseaseDistributionPcInterventio") + " - " + TranslationLookup.GetValue("Oncho")))
                {
                    endemicty = row[TranslationLookup.GetValue("DDOnchoDiseaseDistributionPcInterventio") + " - " + TranslationLookup.GetValue("Oncho")].ToString();
                    if (endemicty == TranslationLookup.GetValue("Oncho1") || endemicty == TranslationLookup.GetValue("OnchoPending"))
                        totalEndemic++;
                    else if (endemicty == TranslationLookup.GetValue("Oncho100"))
                        totalStopped++;
                }
                if (result.DataTableResults.Columns.Contains(TranslationLookup.GetValue("DDSchistoDiseaseDistributionPcIntervent") + " - " + TranslationLookup.GetValue("Schisto")))
                {
                    endemicty = row[TranslationLookup.GetValue("DDSchistoDiseaseDistributionPcIntervent") + " - " + TranslationLookup.GetValue("Schisto")].ToString();
                    if (endemicty == TranslationLookup.GetValue("Sch1") || endemicty == TranslationLookup.GetValue("Sch2") || endemicty == TranslationLookup.GetValue("Sch2a") || endemicty == TranslationLookup.GetValue("Sch3") || endemicty == TranslationLookup.GetValue("Sch3a")
                        || endemicty == TranslationLookup.GetValue("Sch3b") || endemicty == TranslationLookup.GetValue("Sch20") || endemicty == TranslationLookup.GetValue("Sch30") || endemicty == TranslationLookup.GetValue("Sch40")
                        || endemicty == TranslationLookup.GetValue("SchPending"))
                        totalEndemic++;
                    else if (endemicty == TranslationLookup.GetValue("Sch100"))
                        totalStopped++;
                }

                if (result.DataTableResults.Columns.Contains(TranslationLookup.GetValue("DDSTHDiseaseDistributionPcInterventions") + " - " + TranslationLookup.GetValue("STH")))
                {
                    endemicty = row[TranslationLookup.GetValue("DDSTHDiseaseDistributionPcInterventions") + " - " + TranslationLookup.GetValue("STH")].ToString();
                    if (endemicty == TranslationLookup.GetValue("Sth2") || endemicty == TranslationLookup.GetValue("Sth3") || endemicty == TranslationLookup.GetValue("Sth10") || endemicty == TranslationLookup.GetValue("Sth20")
                        || endemicty == TranslationLookup.GetValue("Sth30") || endemicty == TranslationLookup.GetValue("Sth40") || endemicty == TranslationLookup.GetValue("SthPending"))
                        totalEndemic++;
                    else if (endemicty == TranslationLookup.GetValue("Sth100"))
                        totalStopped++;
                }
                if (result.DataTableResults.Columns.Contains(TranslationLookup.GetValue("DDTraDiseaseDistributionPcInterventions") + " - " + TranslationLookup.GetValue("Trachoma")))
                {
                    endemicty = row[TranslationLookup.GetValue("DDTraDiseaseDistributionPcInterventions") + " - " + TranslationLookup.GetValue("Trachoma")].ToString();
                    if (endemicty == TranslationLookup.GetValue("Tra1") || endemicty == TranslationLookup.GetValue("Tra4") || endemicty == TranslationLookup.GetValue("Tra5")
                        || endemicty == TranslationLookup.GetValue("TraPending"))
                        totalEndemic++;
                    else if (endemicty == TranslationLookup.GetValue("Tra100"))
                        totalStopped++;
                }

                if (!years.ContainsKey(row[TranslationLookup.GetValue("Year")].ToString()))
                {
                    DataRow dr = summed.NewRow();
                    dr[TranslationLookup.GetValue("Year")] = row[TranslationLookup.GetValue("Year")];
                    dr[string.Format(TranslationLookup.GetValue("EliminationEndemicDistricts"), standardOpts.DistrictType.DisplayName)] = totalEndemic;
                    dr[string.Format(TranslationLookup.GetValue("EliminationStoppedDistricts"), standardOpts.DistrictType.DisplayName)] = totalStopped;
                    years.Add(row[TranslationLookup.GetValue("Year")].ToString(), dr);
                    summed.Rows.Add(dr);
                }
                else
                {
                    years[row[TranslationLookup.GetValue("Year")].ToString()][string.Format(TranslationLookup.GetValue("EliminationEndemicDistricts"), standardOpts.DistrictType.DisplayName)] =
                        totalEndemic + (int)years[row[TranslationLookup.GetValue("Year")].ToString()][string.Format(TranslationLookup.GetValue("EliminationEndemicDistricts"), standardOpts.DistrictType.DisplayName)];
                    years[row[TranslationLookup.GetValue("Year")].ToString()][string.Format(TranslationLookup.GetValue("EliminationStoppedDistricts"), standardOpts.DistrictType.DisplayName)] =
                        totalStopped + (int)years[row[TranslationLookup.GetValue("Year")].ToString()][string.Format(TranslationLookup.GetValue("EliminationStoppedDistricts"), standardOpts.DistrictType.DisplayName)];
                }
            }

            result.DataTableResults = summed;
            result.ChartData = summed.Copy();
            report.ReportOptions.IsByLevelAggregation = false;
            report.ReportOptions.IsCountryAggregation = true; // to show only year

            return result;
        }
Ejemplo n.º 11
0
 private RecentDistro()
 {
     DiseaseRepo = new DiseaseRepository();
     Diseases = new Dictionary<int, Disease>();
 }
Ejemplo n.º 12
0
        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 StepOptions_Load(object sender, EventArgs e)
        {
            if (!DesignMode)
            {
                // Set up the report inputs
                SetupReportTypeInput();
                SetupYearListBox();

                // Diseases
                DiseaseRepository diseaseRepo = new DiseaseRepository();
                var diseases = diseaseRepo.GetSelectedDiseases().Where(d => d.DiseaseType == Translations.PC).ToList();
                diseaseBindingSource.DataSource = diseases;
                // Add the diseases to the collection of available ones
                options.AvailableDiseases = diseases;

                // Interventions
                IntvRepository intvRepo = new IntvRepository();
                // The interventions we want to use to popualte the list
                List<int> interventionTypeIds = 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
                };
                List<IntvType> intvTypes = intvRepo.GetAllTypes().Where(i => interventionTypeIds.Contains(i.Id)).OrderBy(i => i.IntvTypeName).ToList();
                intvTypeBindingSource.DataSource = intvTypes;
                // Add the interventions to the collection of available ones
                options.AvailableDrugPackages = intvTypes;

                // Admin level types
                SettingsRepository settingsRepo = new SettingsRepository();
                var allLevelTypes = settingsRepo.GetAllAdminLevels();
                adminLevelTypeBindingSource.DataSource = allLevelTypes;

                // Repopulate the previous report options
                if (options != null)
                    RepopulateOptions();
            }
        }
Ejemplo n.º 14
0
        public ExportResult ExportData(string filePath, int userId, int year, AdminLevelType districtLevel)
        {
            try
            {
                int yearReporting = year;
                country = demo.GetCountry();
                DateTime start = new DateTime(year, 1, 1);
                DateTime end = start.AddYears(1).AddDays(-1);
                DiseaseRepository repo = new DiseaseRepository();
                DiseaseDistroPc dd = repo.Create(DiseaseType.Oncho);
                disease = dd.Disease;
                System.Globalization.CultureInfo oldCI = System.Threading.Thread.CurrentThread.CurrentCulture;
                System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
                Microsoft.Office.Interop.Excel.Application xlsApp = new Microsoft.Office.Interop.Excel.ApplicationClass();
                Microsoft.Office.Interop.Excel.Workbook xlsWorkbook;
                Microsoft.Office.Interop.Excel.Workbooks xlsWorkbooks;
                Microsoft.Office.Interop.Excel.Worksheet xlsCountry;
                Microsoft.Office.Interop.Excel.Sheets xlsWorksheets;
                Microsoft.Office.Interop.Excel.Worksheet xlsDemo;
                Microsoft.Office.Interop.Excel.Worksheet xls3;
                Microsoft.Office.Interop.Excel.Worksheet xls4;
                Microsoft.Office.Interop.Excel.Worksheet xls5;
                Microsoft.Office.Interop.Excel.Worksheet xls6;
                Microsoft.Office.Interop.Excel.Worksheet xls7;
                Microsoft.Office.Interop.Excel.Worksheet xls8;
                Microsoft.Office.Interop.Excel.Worksheet xls9;
                Microsoft.Office.Interop.Excel.Worksheet xls10;
                Microsoft.Office.Interop.Excel.Worksheet xls11;
                excel.Range rng = null;
                object missing = System.Reflection.Missing.Value;

                // Open workbook
                xlsWorkbooks = xlsApp.Workbooks;
                xlsWorkbook = xlsWorkbooks.Add(true);
                xlsWorksheets = xlsWorkbook.Worksheets;
                
                CountryDemography countryDemo = demo.GetCountryDemoByYear(yearReporting);
                List<AdminLevel> demography = new List<AdminLevel>();

                DateTime startDate = new DateTime(yearReporting, 1, 1);
                DateTime endDate = startDate.AddYears(1).AddDays(-1);

                demo.GetAdminLevelTreeForDemography(districtLevel.LevelNumber, startDate, endDate, ref demography);
                demography = demography.Where(d => d.LevelNumber == districtLevel.LevelNumber).ToList();

                xlsCountry = (excel.Worksheet)xlsWorkbook.Worksheets[1];
                xlsCountry.Name = Util.TruncateStringForExcelSheetName(TranslationLookup.GetValue("Country"));
                AddCountryPage(xlsCountry, rng, country);
                xlsDemo = (Microsoft.Office.Interop.Excel.Worksheet)xlsWorksheets.Add(missing, xlsCountry, missing, missing);
                xlsDemo.Name = Util.TruncateStringForExcelSheetName(TranslationLookup.GetValue("Demography"));
                AddDemoPage(xlsDemo, rng, demography, districtLevel);
                xls3 = (Microsoft.Office.Interop.Excel.Worksheet)xlsWorksheets.Add(missing, xlsDemo, missing, missing);
                xls3.Name = Util.TruncateStringForExcelSheetName(TranslationLookup.GetValue("DiseaseDistribution"));
                AddDdPage(xls3, rng, demography, start, end, 1, dd);
                xls4 = (Microsoft.Office.Interop.Excel.Worksheet)xlsWorksheets.Add(missing, xls3, missing, missing);
                xls4.Name = Util.TruncateStringForExcelSheetName(TranslationLookup.GetValue("SurOnchoMapping").Replace(TranslationLookup.GetValue("Oncho") + " ", ""));
                Add4(xls4, rng, demography, start, end, 1);
                xls5 = (Microsoft.Office.Interop.Excel.Worksheet)xlsWorksheets.Add(missing, xls4, missing, missing);
                xls5.Name = Util.TruncateStringForExcelSheetName(TranslationLookup.GetValue("SurOnchoAssesments").Replace(TranslationLookup.GetValue("Oncho") + " ", ""));
                Add5(xls5, rng, demography, start, end, 1);
                xls6 = (Microsoft.Office.Interop.Excel.Worksheet)xlsWorksheets.Add(missing, xls5, missing, missing);
                xls6.Name = Util.TruncateStringForExcelSheetName(TranslationLookup.GetValue("IntvIvm"));
                Add6(xls6, rng, demography, start, end, 1);
                xls7 = (Microsoft.Office.Interop.Excel.Worksheet)xlsWorksheets.Add(missing, xls6, missing, missing);
                xls7.Name = Util.TruncateStringForExcelSheetName(TranslationLookup.GetValue("IntvIvmAlb"));
                Add7(xls7, rng, demography, start, end, 1);
                xls8 = (Microsoft.Office.Interop.Excel.Worksheet)xlsWorksheets.Add(missing, xls7, missing, missing);
                xls8.Name = Util.TruncateStringForExcelSheetName(TranslationLookup.GetValue("IntvIvmPzq"));
                Add8(xls8, rng, demography, start, end, 1);
                xls9 = (Microsoft.Office.Interop.Excel.Worksheet)xlsWorksheets.Add(missing, xls8, missing, missing);
                xls9.Name = Util.TruncateStringForExcelSheetName(TranslationLookup.GetValue("IntvIvmPzqAlb"));
                Add9(xls9, rng, demography, start, end, 1);
                xls10 = (Microsoft.Office.Interop.Excel.Worksheet)xlsWorksheets.Add(missing, xls9, missing, missing);
                xls10.Name = Util.TruncateStringForExcelSheetName(TranslationLookup.GetValue("SAEs"));
                Add10(xls10, rng, demography, start, end, 1);
                xls11 = (Microsoft.Office.Interop.Excel.Worksheet)xlsWorksheets.Add(missing, xls10, missing, missing);
                xls11.Name = Util.TruncateStringForExcelSheetName(TranslationLookup.GetValue("PcTraining"));
                Add11(xls11, rng, demography, start, end,1);

                xlsApp.DisplayAlerts = false;
                xlsWorkbook.SaveAs(filePath, Microsoft.Office.Interop.Excel.XlFileFormat.xlOpenXMLWorkbook, missing,
                    missing, false, false, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange,
                    Microsoft.Office.Interop.Excel.XlSaveConflictResolution.xlUserResolution, true,
                    missing, missing, missing);
                xlsApp.Visible = true;
                Marshal.ReleaseComObject(xlsWorksheets);
                Marshal.ReleaseComObject(xlsCountry);
                Marshal.ReleaseComObject(xlsDemo);
                Marshal.ReleaseComObject(xls3);
                Marshal.ReleaseComObject(xls4);
                Marshal.ReleaseComObject(xls5);
                Marshal.ReleaseComObject(xls6);
                Marshal.ReleaseComObject(xls7);
                Marshal.ReleaseComObject(xls8);
                Marshal.ReleaseComObject(xls9);
                Marshal.ReleaseComObject(xls10);
                Marshal.ReleaseComObject(xls11);
                Marshal.ReleaseComObject(xlsWorkbooks);
                Marshal.ReleaseComObject(xlsWorkbook);
                Marshal.ReleaseComObject(xlsApp);
                System.Threading.Thread.CurrentThread.CurrentCulture = oldCI;
                return new ExportResult { WasSuccess = true };

            }
            catch (Exception ex)
            {
                return new ExportResult(ex.Message);
            }
        }
Ejemplo n.º 15
0
        private void StepOptions_Load(object sender, EventArgs e)
        {
            if (!DesignMode)
            {
                Localizer.TranslateControl(this);

                if (report.ReportOptions.StartDate != DateTime.MinValue)
                    dtStart.Value = report.ReportOptions.StartDate;
                if (report.ReportOptions.EndDate != DateTime.MinValue)
                    dtEnd.Value = report.ReportOptions.EndDate;

                var months = GlobalizationUtil.GetAllMonths();
                monthItemBindingSource.DataSource = months;
                cbMonths.DropDownWidth = BaseForm.GetDropdownWidth(months.Select(m => m.Name));
                if (report.ReportOptions.MonthYearStarts > 0)
                    cbMonths.SelectedValue = report.ReportOptions.MonthYearStarts;
                else
                    cbMonths.SelectedValue = 1;
                
                DiseaseRepository r = new DiseaseRepository();
                var diseases = r.GetSelectedDiseases().Where(d => d.DiseaseType == Translations.PC).ToList();
                bindingSource1.DataSource = diseases;
                cbDiseases.DropDownWidth = BaseForm.GetDropdownWidth(diseases.Select(m => m.DisplayName));
                if (options.Diseases.Count > 0)
                    cbDiseases.SelectedItem = diseases.FirstOrDefault(d => d.Id == options.Diseases.First().Id);
                else
                    cbMonths.SelectedIndex = 0;

                SettingsRepository settings = new SettingsRepository();
                cbEliminationType.Items.Add(Translations.Persons);
                cbEliminationType.Items.Add(Translations.RtiReportingLevel);
                if (options.IsPersons)
                    cbEliminationType.SelectedItem = Translations.Persons;
                else
                    cbEliminationType.SelectedItem = options.DistrictType.DisplayName;

                rbAggCountry.Checked = report.ReportOptions.IsCountryAggregation;
                rbAggLevel.Checked = report.ReportOptions.IsByLevelAggregation;

                var allLevelTypes = settings.GetAllAdminLevels();
                var reportingType = allLevelTypes.First();
                options.DistrictType = reportingType;
                bindingSource2.DataSource = allLevelTypes;
                bindingSource3.DataSource = options;
            }
        }
Ejemplo n.º 16
0
 protected void LoadRelatedLists()
 {
     IntvRepository repo = new IntvRepository();
     partners = repo.GetPartners();
     months = GlobalizationUtil.GetAllMonths();
     SettingsRepository settings = new SettingsRepository();
     ezs = settings.GetEcologicalZones();
     eus = settings.GetEvaluationUnits();
     subdistricts = settings.GetEvalSubDistricts();
     ess = settings.GetEvalSites();
     DiseaseRepository diseases = new DiseaseRepository();
     selectedDiseases = diseases.GetSelectedDiseases().Select(d => d.DisplayName).ToList();
     valueParser.LoadRelatedLists();
 }
Ejemplo n.º 17
0
        public List<ReportIndicator> GetDiseaseDistroIndicators()
        {
            List<ReportIndicator> indicators = new List<ReportIndicator>();
            DiseaseRepository repo = new DiseaseRepository();
            var types = repo.GetSelectedDiseases();
            var pc = new ReportIndicator { Name = TranslationLookup.GetValue("PcNtds"), IsCategory = true };
            var cm = new ReportIndicator { Name = TranslationLookup.GetValue("OtherNtds"), IsCategory = true };
            indicators.Add(pc);
            indicators.Add(cm);
            foreach (var t in types.Where(i => i.DiseaseType == TranslationLookup.GetValue("PC")).OrderBy(t => t.DisplayName))
            {
                var cat = new ReportIndicator { Name = t.DisplayName, IsCategory = true };
                DiseaseDistroPc dd = repo.Create((DiseaseType)t.Id);
                foreach (var i in dd.Indicators)
                    cat.Children.Add(CreateReportIndicator(t.Id, i, t.DisplayName, t.DisplayNameKey));
                cat.Children = cat.Children.OrderBy(c => c.Name).ToList();
                pc.Children.Add(cat);
            }
            foreach (var t in types.Where(i => i.DiseaseType == TranslationLookup.GetValue("CM")).OrderBy(t => t.DisplayName))
            {
                var cat = new ReportIndicator { Name = t.DisplayName, IsCategory = true };
                DiseaseDistroCm dd = repo.CreateCm((DiseaseType)t.Id);
                foreach (var i in dd.Indicators)
                    cat.Children.Add(CreateReportIndicator(t.Id, i, t.DisplayName, t.DisplayNameKey));
                cat.Children = cat.Children.OrderBy(c => c.Name).ToList();
                cm.Children.Add(cat);
            }

            return indicators;
        }
        public override ReportResult Run(SavedReport report)
        {
            EliminationReportOptions standardOpts = (EliminationReportOptions)report.StandardReportOptions;
            ReportOptions options = report.ReportOptions;
            DistributionReportGenerator gen = new DistributionReportGenerator();
            DiseaseRepository repo = new DiseaseRepository();
            foreach (var disease in standardOpts.Diseases)
            {
                DiseaseDistroPc dd = repo.Create((DiseaseType)disease.Id);

                switch (disease.Id)
                {

                    case (int)DiseaseType.Lf:
                        AddIndicators(disease.Id, "DDLFPopulationAtRisk", dd, options);
                        AddIndicators(disease.Id, "DDLFPopulationLivingInTheDistrictsThatAc", dd, options);
                        break;
                    case (int)DiseaseType.Trachoma:
                        AddIndicators(disease.Id, "DDTraPopulationAtRisk", dd, options);
                        AddIndicators(disease.Id, "DDTraPopulationLivingInAreasDistrict", dd, options);
                        break;
                    case (int)DiseaseType.Oncho:
                        AddIndicators(disease.Id, "DDOnchoPopulationAtRisk", dd, options);
                        AddIndicators(disease.Id, "DDOnchoPopulationLivingInTheDistrictsTha", dd, options);
                        break;
                    case (int)DiseaseType.STH:
                        AddIndicators(disease.Id, "DDSTHPopulationAtRisk", dd, options);
                        AddIndicators(disease.Id, "DDSTHPopulationLivingInTheDistrictsThatA", dd, options);
                        break;
                    case (int)DiseaseType.Schisto:
                        AddIndicators(disease.Id, "DDSchistoPopulationAtRisk", dd, options);
                        AddIndicators(disease.Id, "DDSchistoPopulationLivingInTheDistrictsT", dd, options);
                        break;
                    default:
                        break;
                }
            }

            ReportResult result = gen.Run(report);

            // loop table, make sure column exists (with 0), sum other columns to good column and delete other columns if they have em.
            result.DataTableResults.Columns.Add(new DataColumn(TranslationLookup.GetValue("EliminationAtRisk")));
            result.DataTableResults.Columns.Add(new DataColumn(TranslationLookup.GetValue("EliminationLiving")));
            foreach (DataRow row in result.DataTableResults.Rows)
            {
                double totalAtRisk = 0, totalLiving = 0;
                totalAtRisk += GetColumnDouble(TranslationLookup.GetValue("DDLFPopulationAtRisk") + " - " + TranslationLookup.GetValue("LF"), result.DataTableResults, row);
                totalAtRisk += GetColumnDouble(TranslationLookup.GetValue("DDTraPopulationAtRisk") + " - " + TranslationLookup.GetValue("Trachoma"), result.DataTableResults, row);
                totalAtRisk += GetColumnDouble(TranslationLookup.GetValue("DDOnchoPopulationAtRisk") + " - " + TranslationLookup.GetValue("Oncho"), result.DataTableResults, row);
                totalAtRisk += GetColumnDouble(TranslationLookup.GetValue("DDSTHPopulationAtRisk") + " - " + TranslationLookup.GetValue("STH"), result.DataTableResults, row);
                totalAtRisk += GetColumnDouble(TranslationLookup.GetValue("DDSchistoPopulationAtRisk") + " - " + TranslationLookup.GetValue("Schisto"), result.DataTableResults, row);
                totalLiving += GetColumnDouble(TranslationLookup.GetValue("DDLFPopulationLivingInTheDistrictsThatAc") + " - " + TranslationLookup.GetValue("LF"), result.DataTableResults, row);
                totalLiving += GetColumnDouble(TranslationLookup.GetValue("DDTraPopulationLivingInAreasDistrict") + " - " + TranslationLookup.GetValue("Trachoma"), result.DataTableResults, row);
                totalLiving += GetColumnDouble(TranslationLookup.GetValue("DDSTHPopulationLivingInTheDistrictsThatA") + " - " + TranslationLookup.GetValue("STH"), result.DataTableResults, row);
                totalLiving += GetColumnDouble(TranslationLookup.GetValue("DDOnchoPopulationLivingInTheDistrictsTha") + " - " + TranslationLookup.GetValue("Oncho"), result.DataTableResults, row);
                totalLiving += GetColumnDouble(TranslationLookup.GetValue("DDSchistoPopulationLivingInTheDistrictsT") + " - " + TranslationLookup.GetValue("Schisto"), result.DataTableResults, row);
                row[TranslationLookup.GetValue("EliminationAtRisk")] = totalAtRisk;
                row[TranslationLookup.GetValue("EliminationLiving")] = totalLiving;
            }

            TryRemoveColumn(TranslationLookup.GetValue("DDLFPopulationAtRisk") + " - " + TranslationLookup.GetValue("LF"), result.DataTableResults);
            TryRemoveColumn(TranslationLookup.GetValue("DDLFPopulationLivingInTheDistrictsThatAc") + " - " + TranslationLookup.GetValue("LF"), result.DataTableResults);
            TryRemoveColumn(TranslationLookup.GetValue("DDTraPopulationAtRisk") + " - " + TranslationLookup.GetValue("Trachoma"), result.DataTableResults);
            TryRemoveColumn(TranslationLookup.GetValue("DDOnchoPopulationAtRisk") + " - " + TranslationLookup.GetValue("Oncho"), result.DataTableResults);
            TryRemoveColumn(TranslationLookup.GetValue("DDSTHPopulationAtRisk") + " - " + TranslationLookup.GetValue("STH"), result.DataTableResults);
            TryRemoveColumn(TranslationLookup.GetValue("DDSchistoPopulationAtRisk") + " - " + TranslationLookup.GetValue("Schisto"), result.DataTableResults);
            TryRemoveColumn(TranslationLookup.GetValue("DDTraPopulationLivingInAreasDistrict") + " - " + TranslationLookup.GetValue("Trachoma"), result.DataTableResults);
            TryRemoveColumn(TranslationLookup.GetValue("DDSTHPopulationLivingInTheDistrictsThatA") + " - " + TranslationLookup.GetValue("STH"), result.DataTableResults);
            TryRemoveColumn(TranslationLookup.GetValue("DDOnchoPopulationLivingInTheDistrictsTha") + " - " + TranslationLookup.GetValue("Oncho"), result.DataTableResults);
            TryRemoveColumn(TranslationLookup.GetValue("DDSchistoPopulationLivingInTheDistrictsT") + " - " + TranslationLookup.GetValue("Schisto"), result.DataTableResults);

            result.ChartData = result.DataTableResults.Copy();
            result.DataTableResults.Columns.Remove(TranslationLookup.GetValue("Type"));
            if (options.IsCountryAggregation)
                result.DataTableResults.Columns.RemoveAt(0);
            return result;
        }
Ejemplo n.º 19
0
 void skipLink_ClickOverride()
 {
     int year = Convert.ToInt32(ConfigurationManager.AppSettings["SkipStartDemoYear"]);
     int userId = ApplicationData.Instance.GetUserId();
     var c = demo.GetCountry();
     c.Name = "Murkonia";
     demo.UpdateCountry(c, userId);
     demo.Save(new CountryDemography { AdminLevelId = 1, GrowthRate = 9.5, DateDemographyData = new DateTime(year, 1, 1), TotalPopulation = 1, PopSac = 1, PercentAdult = 30, PercentPsac = 20, PercentSac = 50 },
         userId); 
     DiseaseRepository diseases = new DiseaseRepository();
     var availableDiseases = diseases.GetAvailableDiseases();
     diseases.SaveSelectedDiseases(availableDiseases, true, userId);
     settings.SetDiseasesReviewedStatus();
     //Import stuff
     settings.Save(new AdminLevelType { DisplayName = "Village", LevelNumber = 3 }, userId);
     var adminLevels = settings.GetAllAdminLevels();
     var region = adminLevels.FirstOrDefault(a => a.DisplayName == "Region");
     region.DisplayName = "Province";
     settings.Save(region, userId);
     var countryDemo = demo.GetCountryDemoRecent();
     AdminLevelDemoImporter regImporter = new AdminLevelDemoImporter(region, countryDemo.Id);
     regImporter.ImportData("TestProvinces.xlsx", userId, false, false, 4, null, new DateTime(year, 1, 1));
     AdminLevelDemoImporter disImporter = new AdminLevelDemoImporter(adminLevels.FirstOrDefault(a => a.DisplayName == "District"), countryDemo.Id);
     disImporter.ImportData("TestDistricts.xlsx", userId, true, true, 25, null, new DateTime(year, 1, 1));
     AdminLevelDemoImporter vilImporter = new AdminLevelDemoImporter(adminLevels.FirstOrDefault(a => a.DisplayName == "Village"), countryDemo.Id);
     vilImporter.ImportData("TestVillages.xlsx", userId, true, false, 13, demo.GetAdminLevelById(3), new DateTime(year, 1, 1));
     CheckStatus();
 }