private static OperationResult InsertAllSignedNotes(SignedDocument document) { OperationResult operationResult = new Models.OperationResult(); if (string.IsNullOrEmpty(document.DocumentID.ToString())) { document.DocumentID = 0; } //if (string.IsNullOrEmpty(document.DateSigned)) //{ // document.DateSigned = string.Empty; //} if (string.IsNullOrEmpty(document.PatientID.ToString())) { document.PatientID = 0; } if (string.IsNullOrEmpty(document.PatientName)) { document.PatientName = string.Empty; } if (string.IsNullOrEmpty(document.CareProviderID.ToString())) { document.CareProviderID = 0; } if (string.IsNullOrEmpty(document.CareProviderName)) { document.CareProviderName = string.Empty; } if (string.IsNullOrEmpty(document.PrimaryCareProviderID.ToString())) { document.PrimaryCareProviderID = 0; } if (string.IsNullOrEmpty(document.PrimaryCareProvider)) { document.PrimaryCareProvider = string.Empty; } if (string.IsNullOrEmpty(document.ReferringCareProviderID.ToString())) { document.ReferringCareProviderID = 0; } if (string.IsNullOrEmpty(document.ReferringCareProvider)) { document.ReferringCareProvider = string.Empty; } if (string.IsNullOrEmpty(document.DocTypeName)) { document.DocTypeName = string.Empty; } if (string.IsNullOrEmpty(document.SignerID.ToString())) { document.SignerID = 0; } using (IDbConnection db = new SqlConnection(ConfigurationValues.WaldenFaxConnection)) { try { const string query = "INSERT INTO [AllSignedNotes]" + " (" + " [DocumentID]" + " ,[VisitID]" + " ,[DateSigned]" + " ,[PatientID]" + " ,[PatientName]" + " ,[CareProviderID]" + " ,[CareProviderName]" + " ,[PrimaryCareProviderID]" + " ,[PrimaryCareProvider]" + " ,[ReferringCareProviderID]" + " ,[ReferringCareProvider]" + " ,[DocTypeName]" + " ,[SignerID]" + ")" + " VALUES" + " (" + " @DocumentID,@VisitID ,@DateSigned , @PatientID, @PatientName, @CareProviderID, @CareProviderName," + " @PrimaryCareProviderID, @PrimaryCareProvider, @ReferringCareProviderID, @ReferringCareProvider," + " @DocTypeName, @SignerID" + " )"; int rowsAffectd = db.Execute(query, new { @DocumentID = document.DocumentID, @VisitID = document.VisitID, @DateSigned = document.DateSigned, @PatientID = document.PatientID, @PatientName = document.PatientName, @CareProviderID = document.CareProviderID, @CareProviderName = document.CareProviderName, @PrimaryCareProviderID = document.PrimaryCareProviderID, @PrimaryCareProvider = document.ReferringCareProvider, @ReferringCareProviderID = document.ReferringCareProviderID, @ReferringCareProvider = document.ReferringCareProvider, @DocTypeName = document.DocTypeName, @SignerID = document.SignerID }); operationResult.Success = true; operationResult.AddMessage("Success"); return operationResult; } catch (Exception er) { operationResult.Success = false; operationResult.AddMessage(er.ToString()); return operationResult; } } }
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); }