public ProcessBaseVm(AdminLevel a, ProcessDetails s, ICalcIndicators c) { r = new ProcessRepository(); this.model = r.GetById(s.Id); adminLevel = a; calc = c; }
public ProcessBaseVm(AdminLevel a, int typeId, ICalcIndicators c) { adminLevel = a; r = new ProcessRepository(); model = r.Create(typeId); model.AdminLevelId = adminLevel.Id; calc = c; }
private void lnkProcess_ClickOverride() { ReportRepository repo = new ReportRepository(); opts.EntityType = Model.IndicatorEntityType.Process; opts.AvailableIndicators = repo.GetProcessIndicators(); ProcessRepository typeRepo = new ProcessRepository(); var types = typeRepo.GetProcessTypes().Select(t => t.TypeName).ToList(); ProcessBase saes = typeRepo.Create(9); types.Add(saes.ProcessType.TypeName); opts.FormTypes = types.OrderBy(t => t).ToList(); OnSwitchStep(new IndStepIndicators(opts)); }
private void ProcessTypeView_Load(object sender, EventArgs e) { if (!DesignMode) { Localizer.TranslateControl(this); repo = new ProcessRepository(); lvIndicators.SetObjects(model.Indicators.Values.Where(i => i.IsEditable)); if (model.Id == 0) pnlName.Visible = true; bsProcessType.DataSource = model; } }
private void SplittingSaes_Load(object sender, EventArgs e) { if (!DesignMode) { Localizer.TranslateControl(this); ProcessRepository repo = new ProcessRepository(); if (options.SplitType == SplittingType.Split) { var saes = repo.GetAllForAdminLevel(options.Source.Id).Where(i => i.TypeId == (int)StaticProcessType.SAEs); foreach (var s in saes) { var sae = repo.GetById(s.Id); var index = tblNewUnits.RowStyles.Add(new RowStyle { SizeType = SizeType.AutoSize }); var chooser = new SaeMatcher(sae, options.SplitDestinations.Select(d => d.Unit).ToList(), options.Source); chooser.Margin = new Padding(0, 5, 10, 5); tblNewUnits.Controls.Add(chooser, 0, index); matchers.Add(chooser); } } else if (options.SplitType == SplittingType.SplitCombine) { foreach (var source in options.MergeSources) { var saes = repo.GetAllForAdminLevel(source.Id).Where(i => i.TypeId == (int)StaticProcessType.SAEs); foreach (var s in saes) { var sae = repo.GetById(s.Id); var index = tblNewUnits.RowStyles.Add(new RowStyle { SizeType = SizeType.AutoSize }); List<AdminLevel> dests = new List<AdminLevel> { source, options.MergeDestination }; var chooser = new SaeMatcher(sae, dests, options.Source); chooser.Margin = new Padding(0, 5, 10, 5); tblNewUnits.Controls.Add(chooser, 0, index); matchers.Add(chooser); } } } if (matchers.Count() == 0) DoNextStep(); } }
public void CreateIndicatorOptionUpdateForm() { string path = ConfigurationManager.AppSettings["AutomatedListsSavePath"]; DataTable table = new DataTable(); table.Columns.Add(new DataColumn("Indicator Id")); table.Columns.Add(new DataColumn("Type Id")); table.Columns.Add(new DataColumn("Type Name")); table.Columns.Add(new DataColumn("Form Name")); table.Columns.Add(new DataColumn("Indicator Name")); table.Columns.Add(new DataColumn("Indicator Option ID")); table.Columns.Add(new DataColumn("Indicator Option")); table.Columns.Add(new DataColumn("Weighted Ranking")); ReportRepository repo = new ReportRepository(); List<ReportIndicator> indicators = repo.GetDiseaseDistroIndicators(); foreach (var cmpc in indicators) foreach (var cat in cmpc.Children) AddOptions(table, cat.Children.Where(x => x.DataTypeId == (int)IndicatorDataType.Dropdown), cat.Name, IndicatorEntityType.DiseaseDistribution); indicators = repo.GetSurveyIndicators(); foreach (var cmpc in indicators) foreach (var cat in cmpc.Children) AddOptions(table, cat.Children.Where(x => x.DataTypeId == (int)IndicatorDataType.Dropdown), cat.Name, IndicatorEntityType.Survey); indicators = repo.GetIntvIndicators(); foreach (var cmpc in indicators) foreach (var cat in cmpc.Children) AddOptions(table, cat.Children.Where(x => x.DataTypeId == (int)IndicatorDataType.Dropdown), cat.Name, IndicatorEntityType.Intervention); indicators = repo.GetProcessIndicators(); foreach (var cmpc in indicators) foreach (var cat in cmpc.Children) AddOptions(table, cat.Children.Where(x => x.DataTypeId == (int)IndicatorDataType.Dropdown), cat.Name, IndicatorEntityType.Process); ProcessRepository prepo = new ProcessRepository(); ProcessBase saes = prepo.Create(9); foreach (var i in saes.ProcessType.Indicators) indicators.Add(ReportRepository.CreateReportIndicator(saes.ProcessType.Id, i)); AddOptions(table, indicators.Where(x => x.DataTypeId == (int)IndicatorDataType.Dropdown), saes.ProcessType.TypeName, IndicatorEntityType.Process); using (ExcelPackage pck = new ExcelPackage()) { ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Sheet1"); ws.Cells["A1"].LoadFromDataTable(table, true); File.WriteAllBytes(path + string.Format("IndicatorDropdownWeightedRules_{0}.xlsx", DateTime.Now.ToString("yyyyMMdd")), pck.GetAsByteArray()); } }
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; }
void importerWorker_DoWork(object sender, DoWorkEventArgs e) { try { int userId = ApplicationData.Instance.GetUserId(); Nada.UI.View.Wizard.SplitDistro.WorkerPayload payload = (Nada.UI.View.Wizard.SplitDistro.WorkerPayload)e.Argument; ImportResult result = payload.Importer.UpdateData(payload.FileName, userId, payload.Forms); if (result.WasSuccess) { ProcessRepository repo = new ProcessRepository(); repo.Save(result.Forms.Cast<ProcessBase>().ToList(), userId); } e.Result = result; } catch (Exception ex) { Logger log = new Logger(); log.Error("Error updating process forms during split. SplitProcesses:importerWorker_DoWork. ", ex); throw; } }
public List<ReportIndicator> GetProcessIndicators() { List<ReportIndicator> indicators = new List<ReportIndicator>(); ProcessRepository repo = new ProcessRepository(); var types = repo.GetProcessTypes(); var pc = new ReportIndicator { Name = TranslationLookup.GetValue("PcNtds"), IsCategory = true }; var cm = new ReportIndicator { Name = TranslationLookup.GetValue("OtherNtds"), IsCategory = true }; types.RemoveAll(t => t.TypeName == TranslationLookup.GetValue("SAEs")); indicators.Add(pc); indicators.Add(cm); foreach (var t in types.Where(i => i.DiseaseType == TranslationLookup.GetValue("PC")).OrderBy(t => t.TypeName)) { var cat = new ReportIndicator { Name = t.TypeName, IsCategory = true }; var instance = repo.Create(t.Id); foreach (var i in instance.ProcessType.Indicators) cat.Children.Add(CreateReportIndicator(t.Id, i, t.TypeName, 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.TypeName)) { var cat = new ReportIndicator { Name = t.TypeName, IsCategory = true }; var instance = repo.Create(t.Id); foreach (var i in instance.ProcessType.Indicators) cat.Children.Add(CreateReportIndicator(t.Id, i, t.TypeName, t.DisplayNameKey)); cat.Children = cat.Children.OrderBy(c => c.Name).ToList(); cm.Children.Add(cat); } // SAEs ProcessBase saes = repo.Create(9); var saeCat = new ReportIndicator { Name = saes.ProcessType.TypeName, IsCategory = true }; foreach (var i in saes.ProcessType.Indicators) saeCat.Children.Add(CreateReportIndicator(saes.ProcessType.Id, i, saes.ProcessType.TypeName, saes.ProcessType.DisplayNameKey)); saeCat.Children = saeCat.Children.OrderBy(c => c.Name).ToList(); indicators.Add(saeCat); return indicators; }
//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++; } } }