Ejemplo n.º 1
0
 private void objectListView1_CellClick(object sender, CellClickEventArgs e)
 {
     if (objectListView1.SelectedObject != null)
     {
         if (objectListView1.Tag == null || objectListView1.SelectedObject != objectListView1.Tag)
         {
             objectListView2.Tag            = null;
             objectListView2.SelectedObject = null;                                      // jdg 8/12/15
             DocumentTemplate dt = (DocumentTemplate)objectListView1.SelectedObject;
             if (string.IsNullOrEmpty(dt.htmlPath))
             {
                 if (!string.IsNullOrEmpty(dt.documentFileName))
                 {
                     webBrowser1.DocumentText = "Preview is not available for Word documents";
                 }
             }
             else
             {
                 dt.SetPatient(SessionManager.Instance.GetActivePatient());
                 dt.OpenHTML();
                 webBrowser1.DocumentText = dt.htmlText;
                 objectListView1.Tag      = objectListView1.SelectedObject;
                 groupBox1.Text           = "Preview - " + dt.documentName;
                 while (backgroundWorker1.IsBusy)
                 {
                     Application.DoEvents();
                 }
                 splitContainer2.Enabled = false;
                 backgroundWorker1.RunWorkerAsync(dt);
             }
         }
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="documentID"></param>
 /// <param name="unitnum"></param>
 /// <param name="apptid"></param>
 ///
 public void CreateHtmlDocument(int documentID, string unitnum, int apptid)
 {
     template = new DocumentTemplate();
     template.SetPatient(SessionManager.Instance.GetActivePatient());
     template.documentTemplateID = documentID;
     template.BackgroundLoadWork();
     template.OpenHTML();
     template.ProcessDocument();
 }
Ejemplo n.º 3
0
 private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
 {
     reportTemplate.OpenHTML();
     PreProcessReportTemplate(reportTemplate);
     reportTemplate.ProcessDocument();
     reportTemplate.UpdateDocFromText();
     divCount = GetDivCount(reportTemplate.doc.DocumentNode);
     curDiv   = 0;
     ProcessDocumentNode(reportTemplate.doc.DocumentNode);
 }
Ejemplo n.º 4
0
        public string GenerateHtmlDocument(int documentID, string unitnum, int apptid)
        {
            SessionManager.Instance.SetActivePatientNoCallback(unitnum, apptid);

            DocumentTemplate dt = new DocumentTemplate();

            dt.documentTemplateID = documentID;
            dt.BackgroundLoadWork();
            dt.OpenHTML();
            dt.ProcessDocument();

            SessionManager.Instance.Shutdown();
            return(dt.htmlText);
        }
Ejemplo n.º 5
0
        public string GenerateHtmlDocument(int documentID, string unitnum, int apptid, string configFile)
        {
            RiskApps3.Utilities.Configurator.configFilePath = configFile;
            SessionManager.Instance.SetCoreConfigPath(configFile);

            SessionManager.Instance.SetActivePatientNoCallback(unitnum, apptid);

            DocumentTemplate dt = new DocumentTemplate();

            dt.documentTemplateID = documentID;
            dt.BackgroundLoadWork();
            dt.OpenHTML();
            dt.ProcessDocument();

            SessionManager.Instance.Shutdown();
            return(dt.htmlText);
        }
Ejemplo n.º 6
0
        /**********************************************************************/
        private void GetDataAndReplaceTag(HtmlTextNode tableNode)
        {
            int pos       = 0;
            int suffixPos = -1;

            while (pos < tableNode.Text.Length && pos >= 0)
            {
                pos = tableNode.Text.IndexOf(HraTagText, pos);
                if (pos >= 0)
                {
                    suffixPos = tableNode.Text.IndexOf(HraTagSuffix, pos);
                    if (pos >= 0 && suffixPos > pos)
                    {
                        string tag        = tableNode.Text.Substring(pos, suffixPos + HraTagSuffix.Length - pos);
                        string args       = tableNode.Text.Substring(pos + HraTagText.Length, suffixPos - pos - HraTagText.Length);
                        int    templateId = -1;
                        int.TryParse(args, out templateId);

                        string value = "";

                        if (templateId > 0)
                        {
                            DocumentTemplate dt = new DocumentTemplate();
                            dt.documentTemplateID = templateId;
                            dt.SetPatient(proband);
                            dt.BackgroundLoadWork();
                            dt.OpenHTML();
                            dt.UseDocArgs = UseDocArgs;
                            dt.ProcessDocument();
                            value = dt.htmlText;
                            HtmlNode body = dt.FindNodeByName(dt.doc.DocumentNode, "body");
                            StripNonInsertNodes(body);
                            if (body != null)
                            {
                                value = body.InnerHtml;
                            }

                            tableNode.Text = tableNode.Text.Replace(tag, value);
                        }
                    }
                }
            }
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        /**********************************************************************/
        private void GetDataAndReplaceTag(HtmlTextNode tableNode)
        {
            int pos = 0;
            int suffixPos = -1;

            while (pos < tableNode.Text.Length && pos >= 0)
            {
                pos = tableNode.Text.IndexOf(HraTagText, pos);
                if (pos >= 0)
                {
                    suffixPos = tableNode.Text.IndexOf(HraTagSuffix, pos);
                    if (pos >= 0 && suffixPos > pos)
                    {
                        string tag = tableNode.Text.Substring(pos, suffixPos + HraTagSuffix.Length - pos);
                        string args = tableNode.Text.Substring(pos + HraTagText.Length, suffixPos - pos - HraTagText.Length);
                        int templateId = -1;
                        int.TryParse(args, out templateId);

                        string value = "";

                        if (templateId > 0)
                        {
                            DocumentTemplate dt = new DocumentTemplate();
                            dt.documentTemplateID = templateId;
                            dt.SetPatient(proband);
                            dt.BackgroundLoadWork();
                            dt.OpenHTML();
                            dt.UseDocArgs = UseDocArgs;
                            dt.ProcessDocument();
                            value = dt.htmlText;
                            HtmlNode body = dt.FindNodeByName(dt.doc.DocumentNode, "body");
                            StripNonInsertNodes(body);
                            if (body != null)
                            {
                                value = body.InnerHtml;
                            }

                            tableNode.Text = tableNode.Text.Replace(tag, value);
                        }
                    }
                }
            }
        }
Ejemplo n.º 9
0
        private void backgroundWorker2_DoWork(object sender, DoWorkEventArgs e)
        {
            List <Appointment> appts = (List <Appointment>)e.Argument;

            try
            {
                foreach (object o in appts)
                {
                    Appointment appt = (Appointment)o;
                    if (appt.CloudWebQueueState == CREATE_NEW_APPT || appt.CloudWebQueueState == SYNCH_APPT)
                    {
                        backgroundWorker2.ReportProgress(2, "Retrieving Patient Record: " + appt.patientname + " - " + appt.dob);
                        XmlNode xml = cloud.FetchPatientRecord(appt.apptID);

                        MemoryStream stm = new MemoryStream();
                        StreamWriter stw = new StreamWriter(stm);
                        stw.Write(xml.OuterXml);
                        stw.Flush();
                        stm.Position = 0;

                        backgroundWorker2.ReportProgress(2, "Saving Data: " + appt.patientname + " - " + appt.dob);
                        DataContractSerializer ds = new DataContractSerializer(typeof(Patient));
                        Patient p2 = (Patient)ds.ReadObject(stm);

                        if (appt.CloudWebQueueState == CREATE_NEW_APPT)
                        {
                            Utilities.ParameterCollection pc = new RiskApps3.Utilities.ParameterCollection();
                            pc.Add("unitnum", p2.unitnum);
                            pc.Add("patientname", p2.name);
                            pc.Add("dob", p2.dob);
                            pc.Add("clinicId", appt.clinicID);
                            object newApptId = BCDB2.Instance.ExecuteSpWithRetValAndParams("sp_createMasteryAppointment", SqlDbType.Int, pc);
                            p2.apptid = (int)newApptId;
                        }
                        else if (appt.CloudWebQueueState == SYNCH_APPT)
                        {
                            p2.apptid = appt.CloudWebQueueSynchId;
                        }

                        p2.FHx.proband = p2;
                        p2.PersistFullObject(new RiskApps3.Model.HraModelChangedEventArgs(null));


                        if (checkBox4.Checked)
                        {
                            backgroundWorker2.ReportProgress(2, "Marking Complete and updating meta data: " + appt.patientname + " - " + appt.dob);
                            ParameterCollection pc = new ParameterCollection("apptID", p2.apptid);
                            BCDB2.Instance.RunSPWithParams("sp_markRiskDataCompleted", pc);
                        }


                        if (checkBox1.Checked)
                        {
                            backgroundWorker2.ReportProgress(2, "Running Risk Models: " + appt.patientname + " - " + appt.dob);
                            p2.RecalculateRisk();

                            ParameterCollection pc = new ParameterCollection("unitnum", p2.unitnum);
                            BCDB2.Instance.RunSPWithParams("sp_3_populateBigQueue", pc);
                        }

                        if (checkBox2.Checked)
                        {
                            backgroundWorker2.ReportProgress(2, "Printing Automation Documents: " + appt.patientname + " - " + appt.dob);

                            ParameterCollection printDocArgs = new ParameterCollection();
                            printDocArgs.Add("apptid", p2.apptid);
                            SqlDataReader reader = BCDB2.Instance.ExecuteReaderSPWithParams("sp_AutomationHtmlDocsToPrint", printDocArgs);
                            while (reader.Read())
                            {
                                int templateID = -1;
                                if (reader.IsDBNull(0) == false)
                                {
                                    templateID = reader.GetInt32(0);
                                }
                                SessionManager.Instance.SetActivePatientNoCallback(p2.unitnum, p2.apptid);
                                DocumentTemplate template = new DocumentTemplate();
                                template.documentTemplateID = templateID;
                                template.BackgroundLoadWork();
                                template.OpenHTML();
                                template.ProcessDocument();
                                htmlInProgress = true;
                                backgroundWorker2.ReportProgress(1, template.htmlText);
                                while (htmlInProgress)
                                {
                                    Application.DoEvents();
                                    Thread.Sleep(500);
                                }
                            }
                        }
                        if (checkBox5.Checked)
                        {
                            backgroundWorker2.ReportProgress(2, "Removing Web Survey: " + appt.patientname + " - " + appt.dob);
                            backgroundWorker2.ReportProgress(4, appt);
                            cloud.DeleteSurvey(appt.apptID);
                        }
                        backgroundWorker2.ReportProgress(2, "Precessing Queue Documents: " + appt.patientname + " - " + appt.dob);
                        if (checkBox3.Checked)
                        {
                            ParameterCollection pc = new ParameterCollection("apptID", p2.apptid);
                            BCDB2.Instance.RunSPWithParams("sp_processQueueDocuments", pc);
                        }
                    }
                    else if (appt.CloudWebQueueState == DELETE_APPT)
                    {
                        backgroundWorker2.ReportProgress(2, "Removing Web Survey: " + appt.patientname + " - " + appt.dob);
                        backgroundWorker2.ReportProgress(4, appt);
                        cloud.DeleteSurvey(appt.apptID);
                    }
                    backgroundWorker2.ReportProgress(3, o);
                }
            }
            catch (Exception exc)
            {
                Logger.Instance.WriteToLog(exc.ToString());
            }
        }