private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { PatientCohort.StartTime = dateTimePicker1.Value; PatientCohort.EndTime = dateTimePicker2.Value; PatientCohort.BackgroundListLoad(); backgroundWorker1.ReportProgress(10); ///////////////////////////////////////////////////////////// // Patients ///////////////////////////////////////////////////////////// //SeriesCollection PatientsChartCollection = new SeriesCollection(); Series PatientSeries = new Series("Patient Visits By Type"); string patients_html = dt.GetTableDiv("Patients"); string metric = ""; ////////////////////////////// ListViewItem lvi = GetListViewAndUpdateHtml("Number of Scheduled Visits", PatientCohort.ToArray(), ref patients_html); // Image chartImage = chart1.GetChartBitmap(); // ListViewItem lvi = GetListViewAndUpdateHtml("Number of Scheduled Visits", // PatientCohort.ToArray(), // ref patients_html, chartImage, 14); backgroundWorker1.ReportProgress(11, lvi); HraObject[] totalAssessments = PatientCohort.Where(p => ((PatientCohortMember)p).RiskAssessment == 1).ToArray(); if (totalAssessments != null) { PatientSeries.Name += (" (n=" + totalAssessments.Length.ToString() + ")"); } lvi = GetListViewAndUpdateHtml("Risk Assessments", totalAssessments, ref patients_html); backgroundWorker1.ReportProgress(11, lvi); ////////////////////////////// lvi = new ListViewItem("Unique Patients"); lvi.Tag = null; metric = PatientCohort.Where(p => ((PatientCohortMember)p).RiskAssessment == 1) .Select(p => ((PatientCohortMember)p).unitnum) .Distinct() .Count() .ToString(); lvi.SubItems.Add(metric); patients_html = dt.InsertTwoColumnLeftRightTableRow(patients_html, "Unique Patients", metric); backgroundWorker1.ReportProgress(11, lvi); ////////////////////////////// lvi = GetListViewAndUpdateHtml("New Patient Visits", PatientCohort.Where( p => ((PatientCohortMember)p).Followup == 0 && ((PatientCohortMember)p).RiskAssessment == 1).ToArray(), ref patients_html); backgroundWorker1.ReportProgress(11, lvi); ////////////////////////////// lvi = GetListViewAndUpdateHtml("Followup Visits", PatientCohort.Where( p => ((PatientCohortMember)p).Followup == 1 && ((PatientCohortMember)p).RiskAssessment == 1).ToArray(), ref patients_html); backgroundWorker1.ReportProgress(11, lvi); ////////////////////////////// lvi = GetListViewAndUpdateHtml("Cancer Patient Visits", PatientCohort.Where( p => ((PatientCohortMember)p).CancerPatient == 1 && ((PatientCohortMember)p).RiskAssessment == 1).ToArray(), ref patients_html); backgroundWorker1.ReportProgress(11, lvi); ////////////////////////////// lvi = GetListViewAndUpdateHtml("Non Cancer Patient Visits", PatientCohort.Where( p => ((PatientCohortMember)p).CancerPatient == 0 && ((PatientCohortMember)p).RiskAssessment == 1).ToArray(), ref patients_html); backgroundWorker1.ReportProgress(11, lvi); ////////////////////////////// lvi = GetListViewAndUpdateHtml("Cancer Patient New Visits", PatientCohort.Where( p => ((PatientCohortMember)p).CancerPatient == 1 && ((PatientCohortMember)p).RiskAssessment == 1 && ((PatientCohortMember)p).Followup == 0).ToArray(), ref patients_html); AddToSeries(ref PatientSeries, lvi); backgroundWorker1.ReportProgress(11, lvi); ////////////////////////////// lvi = GetListViewAndUpdateHtml("Cancer Patient Followup Visits", PatientCohort.Where( p => ((PatientCohortMember)p).CancerPatient == 1 && ((PatientCohortMember)p).RiskAssessment == 1 && ((PatientCohortMember)p).Followup == 1).ToArray(), ref patients_html); AddToSeries(ref PatientSeries, lvi); backgroundWorker1.ReportProgress(11, lvi); ////////////////////////////// lvi = GetListViewAndUpdateHtml("Non Cancer Patient New Visits", PatientCohort.Where( p => ((PatientCohortMember)p).CancerPatient == 0 && ((PatientCohortMember)p).RiskAssessment == 1 && ((PatientCohortMember)p).Followup == 0).ToArray(), ref patients_html); AddToSeries(ref PatientSeries, lvi); backgroundWorker1.ReportProgress(11, lvi); ////////////////////////////// lvi = GetListViewAndUpdateHtml("Non Cancer Followup Patient Visits", PatientCohort.Where( p => ((PatientCohortMember)p).CancerPatient == 0 && ((PatientCohortMember)p).RiskAssessment == 1 && ((PatientCohortMember)p).Followup == 1).ToArray(), ref patients_html); AddToSeries(ref PatientSeries, lvi); backgroundWorker1.ReportProgress(11, lvi); ////////////////////////////// lvi = GetListViewAndUpdateHtml("Visits by Relatives of Other Patients", PatientCohort.Where( p => ((PatientCohortMember)p).RelatedAppts == 1 && ((PatientCohortMember)p).RiskAssessment == 1).ToArray(), ref patients_html); backgroundWorker1.ReportProgress(11, lvi); backgroundWorker1.ReportProgress(12, PatientSeries); AddImageAsThirdColumn(ref patients_html, chart1.GetChartBitmap()); ///////////////////////////////////////////////////////////// // Tests ///////////////////////////////////////////////////////////// TestingCohort.StartTime = dateTimePicker1.Value; TestingCohort.EndTime = dateTimePicker2.Value; TestingCohort.BackgroundListLoad(); backgroundWorker1.ReportProgress(20); string tests_html = dt.GetTableDiv("Tests"); metric = ""; lvi = GetListViewAndUpdateHtml("Total Number of Tests Ordered", TestingCohort.ToArray(), ref tests_html); backgroundWorker1.ReportProgress(21, lvi); lvi = GetListViewAndUpdateHtml("Total Number of Tests Pending", TestingCohort.Where(p => ((TestingCohorttMember)p).IsCompleted == 0) .ToArray(), ref tests_html); backgroundWorker1.ReportProgress(21, lvi); lvi = GetListViewAndUpdateHtml("Total Number of Tests Completed", TestingCohort.Where(p => ((TestingCohorttMember)p).IsCompleted == 1) .ToArray(), ref tests_html); backgroundWorker1.ReportProgress(21, lvi); lvi = new ListViewItem("Unique Patients"); lvi.Tag = null; metric = TestingCohort.Where(p => ((TestingCohorttMember)p).IsCompleted == 1) .Select(p => ((TestingCohorttMember)p).unitnum) .Distinct() .Count() .ToString(); lvi.SubItems.Add(metric); tests_html = dt.InsertTwoColumnLeftRightTableRow(tests_html, "Unique Patients", metric); backgroundWorker1.ReportProgress(21, lvi); lvi = GetListViewAndUpdateHtml("Completed BRCA Tests", TestingCohort.Where( p => ((TestingCohorttMember)p).IsCompleted == 1 && ((TestingCohorttMember)p).IsBrcaPanel == 1).ToArray(), ref tests_html); backgroundWorker1.ReportProgress(21, lvi); lvi = GetListViewAndUpdateHtml("Completed Lynch Tests", TestingCohort.Where( p => ((TestingCohorttMember)p).IsCompleted == 1 && ((TestingCohorttMember)p).IsLynchPanel == 1).ToArray(), ref tests_html); backgroundWorker1.ReportProgress(21, lvi); lvi = GetListViewAndUpdateHtml("Completed Other Tests", TestingCohort.Where( p => ((TestingCohorttMember)p).IsCompleted == 1 && ((TestingCohorttMember)p).IsLynchPanel == 0 && ((TestingCohorttMember)p).IsBrcaPanel == 0).ToArray(), ref tests_html); backgroundWorker1.ReportProgress(21, lvi); lvi = GetListViewAndUpdateHtml("Positive BRCA Tests", TestingCohort.Where( p => ((TestingCohorttMember)p).IsCompleted == 1 && ((TestingCohorttMember)p).IsBrcaPanel == 1 && ((TestingCohorttMember)p).VariantFound == 1).ToArray(), ref tests_html); backgroundWorker1.ReportProgress(21, lvi); lvi = GetListViewAndUpdateHtml("Positive Lynch Tests", TestingCohort.Where( p => ((TestingCohorttMember)p).IsCompleted == 1 && ((TestingCohorttMember)p).IsLynchPanel == 1 && ((TestingCohorttMember)p).VariantFound == 1).ToArray(), ref tests_html); backgroundWorker1.ReportProgress(21, lvi); lvi = GetListViewAndUpdateHtml("Positive Other Tests", TestingCohort.Where( p => ((TestingCohorttMember)p).IsCompleted == 1 && ((TestingCohorttMember)p).IsLynchPanel == 0 && ((TestingCohorttMember)p).IsBrcaPanel == 0 && ((TestingCohorttMember)p).VariantFound == 1).ToArray(), ref tests_html); backgroundWorker1.ReportProgress(21, lvi); ///////////////////////////////////////////////////////////// // Ethnicity ///////////////////////////////////////////////////////////// Series EthnicitySeries = new Series("Ethnicity"); string ethnicity_html = dt.GetTableDiv("Ethnicity"); EthnicityCohort.StartTime = dateTimePicker1.Value; EthnicityCohort.EndTime = dateTimePicker2.Value; EthnicityCohort.BackgroundListLoad(); backgroundWorker1.ReportProgress(60); ////////////////////////////// lvi = GetListViewAndUpdateHtml("Total number of Ethnicity Reports", EthnicityCohort.ToArray(), ref ethnicity_html); backgroundWorker1.ReportProgress(61, lvi); ////////////////////////////// lvi = new ListViewItem("Unique Patients"); lvi.Tag = null; metric = EthnicityCohort.Select(p => ((EthnicityCohortMember)p).unitnum).Distinct().Count().ToString(); lvi.SubItems.Add(metric); ethnicity_html = dt.InsertTwoColumnLeftRightTableRow(ethnicity_html, "Unique Patients", metric); backgroundWorker1.ReportProgress(61, lvi); ////////////////////////////// foreach (string o in EthnicityCohort.Select(p => ((EthnicityCohortMember)p).racialBackground).Distinct()) { if (string.IsNullOrEmpty(o)) { lvi = GetListViewAndUpdateHtml("People Identifying as no ethnicity", EthnicityCohort.Where( p => ((EthnicityCohortMember)p).racialBackground == "") .ToArray(), ref ethnicity_html); AddToSeries(ref EthnicitySeries, lvi); backgroundWorker1.ReportProgress(61, lvi); } else { lvi = GetListViewAndUpdateHtml("People Identifying as " + o, EthnicityCohort.Where( p => ((EthnicityCohortMember)p).racialBackground == o).ToArray(), ref ethnicity_html); AddToSeries(ref EthnicitySeries, lvi); backgroundWorker1.ReportProgress(61, lvi); } } ////////////////////////////// backgroundWorker1.ReportProgress(62, EthnicitySeries); AddImageAsThirdColumn(ref ethnicity_html, chart2.GetChartBitmap()); ///////////////////////////////////////////////////////////// // ReferringProviders ///////////////////////////////////////////////////////////// ReferringProviders.StartTime = dateTimePicker1.Value; ReferringProviders.EndTime = dateTimePicker2.Value; ReferringProviders.BackgroundListLoad(); backgroundWorker1.ReportProgress(30); ///////////////////////////////////////////////////////////// // emailReport ///////////////////////////////////////////////////////////// emailReport.StartTime = dateTimePicker1.Value; emailReport.EndTime = dateTimePicker2.Value; emailReport.BackgroundListLoad(); backgroundWorker1.ReportProgress(40); ///////////////////////////////////////////////////////////// // optInOrOutReport ///////////////////////////////////////////////////////////// optInOrOutReport.StartTime = dateTimePicker1.Value; optInOrOutReport.EndTime = dateTimePicker2.Value; optInOrOutReport.BackgroundListLoad(); backgroundWorker1.ReportProgress(50); ///////////////////////////////////////////////////////////// // Document ///////////////////////////////////////////////////////////// dt.documentTemplateID = 500; dt.BackgroundLoadWork(); dt.OpenHTML(); dt.UseDocArgs = false; dt.ProcessDocument(); dt.AddDiv(patients_html); dt.AddDiv(tests_html); dt.AddDiv(ethnicity_html); }