private void butPDF_Click(object sender, EventArgs e) { if (!TryToSaveData()) { return; } SheetCur = Sheets.GetSheet(SheetCur.SheetNum); string filePathAndName = Path.ChangeExtension(Path.GetTempFileName(), ".pdf"); //Graphics g=this.CreateGraphics(); SheetPrinting.CreatePdf(SheetCur, filePathAndName); //g.Dispose(); Process.Start(filePathAndName); DialogResult = DialogResult.OK; }
private void butPDF_Click(object sender, EventArgs e) { if (!TryToSaveData()) { return; } SheetCur = Sheets.GetSheet(SheetCur.SheetNum); string filePathAndName = Path.ChangeExtension(Path.GetTempFileName(), ".pdf"); //Graphics g=this.CreateGraphics(); SheetPrinting.CreatePdf(SheetCur, filePathAndName); //g.Dispose(); Process.Start(filePathAndName); SecurityLogs.MakeLogEntry(Permissions.SheetEdit, SheetCur.PatNum, SheetCur.Description + " from " + SheetCur.DateTimeSheet.ToShortDateString() + " pdf was created"); DialogResult = DialogResult.OK; }
private void butPrint_Click(object sender, EventArgs e) { if (!TryToSaveData()) { return; } SheetCur = Sheets.GetSheet(SheetCur.SheetNum); //whether this is a new sheet, or one pulled from the database, //it will have the extra parameter we are looking for. //A new sheet will also have a PatNum parameter which we will ignore. FormSheetOutputFormat FormS = new FormSheetOutputFormat(); if (SheetCur.SheetType == SheetTypeEnum.ReferralSlip || SheetCur.SheetType == SheetTypeEnum.ReferralLetter) { FormS.PaperCopies = 2; } else { FormS.PaperCopies = 1; } if (SheetCur.PatNum != 0 && SheetCur.SheetType != SheetTypeEnum.DepositSlip) { Patient pat = Patients.GetPat(SheetCur.PatNum); if (SheetCur.SheetType == SheetTypeEnum.LabSlip) { FormS.IsForLab = true; //Changes label to "E-mail to Lab:" } else if (pat.Email != "") { FormS.EmailPatOrLabAddress = pat.Email; //No need to email to a patient for sheet types: LabelPatient (0), LabelCarrier (1), LabelReferral (2), ReferralSlip (3), LabelAppointment (4), Rx (5), Consent (6), ReferralLetter (8), ExamSheet (13), DepositSlip (14) //The data is too private to email unencrypted for sheet types: PatientForm (9), RoutingSlip (10), MedicalHistory (11), LabSlip (12) //A patient might want email for the following sheet types and the data is not very private: PatientLetter (7) if (SheetCur.SheetType == SheetTypeEnum.PatientLetter) { //This just defines the default selection. The user can manually change selections in FormSheetOutputFormat. FormS.EmailPatOrLab = true; FormS.PaperCopies--; } } } Referral referral = null; if (SheetCur.SheetType == SheetTypeEnum.ReferralSlip || SheetCur.SheetType == SheetTypeEnum.ReferralLetter) { FormS.Email2Visible = true; SheetParameter parameter = SheetParameter.GetParamByName(SheetCur.Parameters, "ReferralNum"); if (parameter == null) //it can be null sometimes because of old bug in db. { FormS.Email2Visible = false; //prevents trying to attach email to nonexistent referral. } else { long referralNum = PIn.Long(parameter.ParamValue.ToString()); referral = Referrals.GetReferral(referralNum); if (referral.EMail != "") { FormS.Email2Address = referral.EMail; FormS.Email2 = true; FormS.PaperCopies--; } } } else { FormS.Email2Visible = false; } FormS.ShowDialog(); if (FormS.DialogResult != DialogResult.OK) { return; } if (FormS.PaperCopies > 0) { SheetPrinting.Print(SheetCur, FormS.PaperCopies, RxIsControlled); } EmailMessage message; Random rnd = new Random(); string attachPath = EmailMessages.GetEmailAttachPath(); string fileName; string filePathAndName; EmailAddress emailAddress; Patient patCur = Patients.GetPat(SheetCur.PatNum); if (patCur == null) { emailAddress = EmailAddresses.GetByClinic(0); } else { emailAddress = EmailAddresses.GetByClinic(patCur.ClinicNum); } //Graphics g=this.CreateGraphics(); if (FormS.EmailPatOrLab) { fileName = DateTime.Now.ToString("yyyyMMdd") + "_" + DateTime.Now.TimeOfDay.Ticks.ToString() + rnd.Next(1000).ToString() + ".pdf"; filePathAndName = ODFileUtils.CombinePaths(attachPath, fileName); SheetPrinting.CreatePdf(SheetCur, filePathAndName); //Process.Start(filePathAndName); message = new EmailMessage(); message.PatNum = SheetCur.PatNum; message.ToAddress = FormS.EmailPatOrLabAddress; message.FromAddress = emailAddress.SenderAddress; //Can be blank just as it could with the old pref. message.Subject = SheetCur.Description.ToString(); //this could be improved EmailAttach attach = new EmailAttach(); string shortFileName = Regex.Replace(SheetCur.Description.ToString(), @"[^\w'@-_()&]", ""); attach.DisplayedFileName = shortFileName + ".pdf"; attach.ActualFileName = fileName; message.Attachments.Add(attach); FormEmailMessageEdit FormE = new FormEmailMessageEdit(message); FormE.IsNew = true; FormE.ShowDialog(); } if ((SheetCur.SheetType == SheetTypeEnum.ReferralSlip || SheetCur.SheetType == SheetTypeEnum.ReferralLetter) && FormS.Email2) { //email referral fileName = DateTime.Now.ToString("yyyyMMdd") + "_" + DateTime.Now.TimeOfDay.Ticks.ToString() + rnd.Next(1000).ToString() + ".pdf"; filePathAndName = ODFileUtils.CombinePaths(attachPath, fileName); SheetPrinting.CreatePdf(SheetCur, filePathAndName); //Process.Start(filePathAndName); message = new EmailMessage(); message.PatNum = SheetCur.PatNum; message.ToAddress = FormS.Email2Address; message.FromAddress = emailAddress.SenderAddress; //Can be blank just as it could with the old pref. message.Subject = Lan.g(this, "RE: ") + Patients.GetLim(SheetCur.PatNum).GetNameLF(); //works even if patnum invalid //SheetCur.Description.ToString()+" to "+Referrals.GetNameFL(referral.ReferralNum);//this could be improved EmailAttach attach = new EmailAttach(); string shortFileName = Regex.Replace(SheetCur.Description.ToString(), @"[^\w,'@-_()&]", ""); attach.DisplayedFileName = shortFileName + ".pdf"; attach.ActualFileName = fileName; message.Attachments.Add(attach); FormEmailMessageEdit FormE = new FormEmailMessageEdit(message); FormE.IsNew = true; FormE.ShowDialog(); } //g.Dispose(); DialogResult = DialogResult.OK; }
///<summary>Uses sheet framework to generate a PDF file, save it to patient's image folder, and attempt to launch file with defualt reader. ///If using ImagesStoredInDB it will not launch PDF. If no valid patient is selected you cannot perform this action.</summary> private void butPDF_Click(object sender, EventArgs e) { if (PatCur == null) //not attached to a patient when form loaded and they haven't selected a patient to attach to yet { MsgBox.Show(this, "The Medical Lab must be attached to a patient before the PDF can be saved."); return; } if (PatCur.PatNum > 0 && _medLabCur.PatNum != PatCur.PatNum) //save the current patient attached to the MedLab if it has been changed { MoveLabsAndImagesHelper(); } Cursor = Cursors.WaitCursor; SheetDef sheetDef = SheetUtil.GetMedLabResultsSheetDef(); Sheet sheet = SheetUtil.CreateSheet(sheetDef, _medLabCur.PatNum); SheetFiller.FillFields(sheet, null, null, _medLabCur); //create the file in the temp folder location, then import so it works when storing images in the db string tempPath = ODFileUtils.CombinePaths(PrefC.GetTempFolderPath(), _medLabCur.PatNum.ToString() + ".pdf"); SheetPrinting.CreatePdf(sheet, tempPath, null, _medLabCur); HL7Def defCur = HL7Defs.GetOneDeepEnabled(true); long category = defCur.LabResultImageCat; if (category == 0) { category = Defs.GetFirstForCategory(DefCat.ImageCats, true).DefNum; //put it in the first category. } //create doc-------------------------------------------------------------------------------------- OpenDentBusiness.Document docc = null; try { docc = ImageStore.Import(tempPath, category, Patients.GetPat(_medLabCur.PatNum)); } catch (Exception ex) { ex.DoNothing(); Cursor = Cursors.Default; MsgBox.Show(this, "Error saving document."); return; } finally { //Delete the temp file since we don't need it anymore. try { File.Delete(tempPath); } catch { //Do nothing. This file will likely get cleaned up later. } } docc.Description = Lan.g(this, "MedLab Result"); docc.DateCreated = DateTime.Now; Documents.Update(docc); string filePathAndName = ""; if (PrefC.AtoZfolderUsed == DataStorageType.LocalAtoZ) { string patFolder = ImageStore.GetPatientFolder(Patients.GetPat(_medLabCur.PatNum), ImageStore.GetPreferredAtoZpath()); filePathAndName = ODFileUtils.CombinePaths(patFolder, docc.FileName); } else if (CloudStorage.IsCloudStorage) { FormProgress FormP = new FormProgress(); FormP.DisplayText = "Downloading..."; FormP.NumberFormat = "F"; FormP.NumberMultiplication = 1; FormP.MaxVal = 100; //Doesn't matter what this value is as long as it is greater than 0 FormP.TickMS = 1000; OpenDentalCloud.Core.TaskStateDownload state = CloudStorage.DownloadAsync( ImageStore.GetPatientFolder(Patients.GetPat(_medLabCur.PatNum), ImageStore.GetPreferredAtoZpath()) , docc.FileName , new OpenDentalCloud.ProgressHandler(FormP.OnProgress)); if (FormP.ShowDialog() == DialogResult.Cancel) { state.DoCancel = true; return; } filePathAndName = PrefC.GetRandomTempFile(Path.GetExtension(docc.FileName)); File.WriteAllBytes(filePathAndName, state.FileContent); } Cursor = Cursors.Default; if (filePathAndName != "") { Process.Start(filePathAndName); } SecurityLogs.MakeLogEntry(Permissions.SheetEdit, sheet.PatNum, sheet.Description + " from " + sheet.DateTimeSheet.ToShortDateString() + " pdf was created"); DialogResult = DialogResult.OK; }
private void butPrint_Click(object sender, EventArgs e) { if (!TryToSaveData()) { return; } SheetCur = Sheets.GetSheet(SheetCur.SheetNum); //whether this is a new sheet, or one pulled from the database, //it will have the extra parameter we are looking for. //A new sheet will also have a PatNum parameter which we will ignore. FormSheetOutputFormat FormS = new FormSheetOutputFormat(); if (SheetCur.SheetType == SheetTypeEnum.ReferralSlip || SheetCur.SheetType == SheetTypeEnum.ReferralLetter) { FormS.PaperCopies = 2; } else { FormS.PaperCopies = 1; } if (SheetCur.PatNum != 0 && SheetCur.SheetType != SheetTypeEnum.DepositSlip) { Patient pat = Patients.GetPat(SheetCur.PatNum); if (SheetCur.SheetType == SheetTypeEnum.LabSlip) { FormS.IsForLab = true; //Changes label to "E-mail to Lab:" } else if (pat.Email != "") { FormS.EmailPatOrLabAddress = pat.Email; FormS.EmailPatOrLab = true; FormS.PaperCopies--; } } Referral referral = null; if (SheetCur.SheetType == SheetTypeEnum.ReferralSlip || SheetCur.SheetType == SheetTypeEnum.ReferralLetter) { FormS.Email2Visible = true; SheetParameter parameter = SheetParameter.GetParamByName(SheetCur.Parameters, "ReferralNum"); if (parameter == null) //it can be null sometimes because of old bug in db. { FormS.Email2Visible = false; //prevents trying to attach email to nonexistent referral. } else { long referralNum = PIn.Long(parameter.ParamValue.ToString()); referral = Referrals.GetReferral(referralNum); if (referral.EMail != "") { FormS.Email2Address = referral.EMail; FormS.Email2 = true; FormS.PaperCopies--; } } } else { FormS.Email2Visible = false; } FormS.ShowDialog(); if (FormS.DialogResult != DialogResult.OK) { return; } if (FormS.PaperCopies > 0) { SheetPrinting.Print(SheetCur, FormS.PaperCopies, RxIsControlled); } EmailMessage message; Random rnd = new Random(); string attachPath = FormEmailMessageEdit.GetAttachPath(); string fileName; string filePathAndName; //Graphics g=this.CreateGraphics(); if (FormS.EmailPatOrLab) { fileName = DateTime.Now.ToString("yyyyMMdd") + "_" + DateTime.Now.TimeOfDay.Ticks.ToString() + rnd.Next(1000).ToString() + ".pdf"; filePathAndName = ODFileUtils.CombinePaths(attachPath, fileName); SheetPrinting.CreatePdf(SheetCur, filePathAndName); //Process.Start(filePathAndName); message = new EmailMessage(); message.PatNum = SheetCur.PatNum; message.ToAddress = FormS.EmailPatOrLabAddress; message.FromAddress = PrefC.GetString(PrefName.EmailSenderAddress); message.Subject = SheetCur.Description.ToString(); //this could be improved EmailAttach attach = new EmailAttach(); string shortFileName = Regex.Replace(SheetCur.Description.ToString(), @"[^\w'@-_()&]", ""); attach.DisplayedFileName = shortFileName + ".pdf"; attach.ActualFileName = fileName; message.Attachments.Add(attach); FormEmailMessageEdit FormE = new FormEmailMessageEdit(message); FormE.IsNew = true; FormE.ShowDialog(); } if ((SheetCur.SheetType == SheetTypeEnum.ReferralSlip || SheetCur.SheetType == SheetTypeEnum.ReferralLetter) && FormS.Email2) { //email referral fileName = DateTime.Now.ToString("yyyyMMdd") + "_" + DateTime.Now.TimeOfDay.Ticks.ToString() + rnd.Next(1000).ToString() + ".pdf"; filePathAndName = ODFileUtils.CombinePaths(attachPath, fileName); SheetPrinting.CreatePdf(SheetCur, filePathAndName); //Process.Start(filePathAndName); message = new EmailMessage(); message.PatNum = SheetCur.PatNum; message.ToAddress = FormS.Email2Address; message.FromAddress = PrefC.GetString(PrefName.EmailSenderAddress); message.Subject = SheetCur.Description.ToString() + " to " + Referrals.GetNameFL(referral.ReferralNum); //this could be improved EmailAttach attach = new EmailAttach(); string shortFileName = Regex.Replace(SheetCur.Description.ToString(), @"[^\w,'@-_()&]", ""); attach.DisplayedFileName = shortFileName + ".pdf"; attach.ActualFileName = fileName; message.Attachments.Add(attach); FormEmailMessageEdit FormE = new FormEmailMessageEdit(message); FormE.IsNew = true; FormE.ShowDialog(); } //g.Dispose(); DialogResult = DialogResult.OK; }