public Letter(Correspondence correspondence)
        {
            InitializeComponent();

            this.dateText.Value = correspondence.TodaysDate;
            this.messageFromText.Value = correspondence.MessageFrom;
            this.headerText.Value = correspondence.HeaderText;
            this.bodyText.Value = correspondence.BodyText;
            //this.footerText.Value = correspondence.FooterText;
        }
        public LetterOrthoNow(Correspondence correspondence)
        {

            InitializeComponent();

            this.dateText.Value = correspondence.TodaysDate;
            //this.firstNameLastName.Value = correspondence.MessageFrom;
            this.firstNameLastName.Value = correspondence.HeaderText;
            string htmlText = "<p style=" + Chr(34) + "font: 15px arial, sans-serif" + Chr(34) + ">" + correspondence.PatientName + " was seen today at <span style=" + Chr(34) + "font: bold italic 15px arial, sans-serif" + Chr(34) + ">Ortho</span><span style=" + Chr(34) + "color: #ff0000; font: bold 15px arial, sans-serif" + Chr(34) + ">NOW</span>, a walk in clinic associated with Connecticut Orthopaedic Specialists. <span style=" + Chr(34) + "font: bold italic 15px arial, sans-serif" + Chr(34) + ">Ortho</span><span style=" + Chr(34) + "color: #ff0000; font: bold 15px arial, sans-serif" + Chr(34) + ">NOW</span> accepts patients of all ages. We are available for anyone who needs immediate orthopaedic treatment with offices located in Hamden, Branford, and Orange. Patients are seen with a variety of orthopaedic conditions including but not limited to: fractures, dislocations, sprains and back pain.</p><p style=" + Chr(34) + "font: 15px arial, sans-serif" + Chr(34) + ">Enclosed is a copy of the office visit documentation which includes the diagnosis and treatment plan.</p><p style=" + Chr(34) + "font: 15px arial, sans-serif" + Chr(34) + ">Please let us know if we can answer any additional questions regarding your patient’s care.</p><p style=" + Chr(34) + "font: 15px arial, sans-serif" + Chr(34) + ">Respectfully,</p><p style=" + Chr(34) + "font: 15px arial, sans-serif" + Chr(34) + ">The <span style=" + Chr(34) + "font: bold italic 15px arial, sans-serif" + Chr(34) + ">Ortho</span><span style=" + Chr(34) + "color: #ff0000; font: bold 15px arial, sans-serif" + Chr(34) + ">NOW</span> Team</p>";
            this.htmlTextBox1.Value = htmlText;
        }
        private static void CreateLetterToPutInFrontOfNote(FaxTelephoneNumber faxTelephoneNumber, SignedDocument document)
        {
            Correspondence letter = new Correspondence();
            letter.TodaysDate = DateTime.Now.ToLongDateString();
            letter.MessageFrom = "A patient communications update from the office of " + document.CareProviderName;

            if (string.IsNullOrEmpty(faxTelephoneNumber.AddressLine1))
            {
                faxTelephoneNumber.AddressLine1 = string.Empty;
            }

            if (string.IsNullOrEmpty(faxTelephoneNumber.AddressLine2))
            {
                faxTelephoneNumber.AddressLine2 = string.Empty;
            }

            if (string.IsNullOrEmpty(faxTelephoneNumber.City))
            {
                faxTelephoneNumber.City = string.Empty;
            }
            else
            {
                faxTelephoneNumber.City = faxTelephoneNumber.City + ", ";
            }

            if (string.IsNullOrEmpty(faxTelephoneNumber.State))
            {
                faxTelephoneNumber.State = string.Empty;
            }
            else
            {
                faxTelephoneNumber.State = faxTelephoneNumber.State + " ";
            }

            if (string.IsNullOrEmpty(faxTelephoneNumber.PostalCode))
            {
                faxTelephoneNumber.PostalCode = string.Empty;
            }

            if (faxTelephoneNumber.AddressLine2.Length > 0)
            {
                letter.HeaderText = faxTelephoneNumber.Name + Environment.NewLine
                    + faxTelephoneNumber.AddressLine1 + Environment.NewLine
                    + faxTelephoneNumber.AddressLine2 + Environment.NewLine
                    + faxTelephoneNumber.City
                    + faxTelephoneNumber.State + faxTelephoneNumber.PostalCode;
            }
            else
            {
                string[] credential = faxTelephoneNumber.FullName.Split(' ');
                faxTelephoneNumber.Name = credential[1] + " " + credential[0] + " " + credential[credential.Length - 1];

                letter.HeaderText = credential[1] + " " + credential[0] + " " + credential[credential.Length - 1] + Environment.NewLine
                     + faxTelephoneNumber.AddressLine1 + Environment.NewLine
                     + faxTelephoneNumber.City
                     + faxTelephoneNumber.State + faxTelephoneNumber.PostalCode;
            }

            letter.BodyText = "I saw your patient " + document.PatientName
                + " at your request in consultation regarding the patient’s  orthopedic problem.  "
                + " Thank you for your kind referral." + Environment.NewLine + Environment.NewLine
                + "I’ve enclosed a copy of our office notes which includes "
                + "the diagnosis and treatment plan.  I will continue to keep you updated in the future with "
                + "regard to our patient’s progress .  Please let me know if I can answer any further questions "
                + "regarding our patient’s care." + Environment.NewLine + Environment.NewLine + Environment.NewLine
                + "All the Best,"
                + Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine
                + document.CareProviderName
                + Environment.NewLine + Environment.NewLine
                + "Enclosure"
            ;

            AutomatedFaxReports.Letter report1 = new AutomatedFaxReports.Letter(letter);
            Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
            Telerik.Reporting.InstanceReportSource instanceReportSource = new Telerik.Reporting.InstanceReportSource();
            instanceReportSource.ReportDocument = report1;
            Telerik.Reporting.Processing.RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, null);
            using (var pdfStream = new MemoryStream(result.DocumentBytes))
            using (var reportFile = new FileStream(ConfigurationValues.CorrespondensePath, FileMode.Create))
            {
                pdfStream.CopyTo(reportFile);
            }

            PdfFileEditor pdfEditor = new PdfFileEditor();

            //    try
            //    {
            //        File.Delete(ConfigurationValues.FinalFaxPath);
            //    }
            //    catch { }

            ConfigurationValues.FinalFaxPath = System.Configuration.ConfigurationManager.AppSettings["finalFaxPath"] + Guid.NewGuid().ToString() + ".pdf";
            pdfEditor.Concatenate(ConfigurationValues.CorrespondensePath, ConfigurationValues.CreatePdfPath, ConfigurationValues.FinalFaxPath);

        }