///<summary></summary> public static string ReplaceTemplateFields(string templateText,Patient pat,Appointment aptNext,Clinic clinic) { //patient information templateText=Patients.ReplacePatient(templateText,pat); //Guarantor Information templateText=Patients.ReplaceGuarantor(templateText,pat); //Family Information templateText=Family.ReplaceFamily(templateText,pat); //Next Scheduled Appointment Information templateText=Appointments.ReplaceAppointment(templateText,aptNext); //handles null nextApts. //Currently Logged in User Information templateText=FormMessageReplacements.ReplaceUser(templateText,Security.CurUser); //Clinic Information templateText=Clinics.ReplaceOffice(templateText,clinic); //Misc Information templateText=FormMessageReplacements.ReplaceMisc(templateText); //Referral Information templateText=Referrals.ReplaceRefProvider(templateText,pat); //Recall Information return Recalls.ReplaceRecall(templateText,pat); }
public void LoadTemplate(string subject, string bodyText, List <EmailAttach> attachments) { List <Appointment> listApts = Appointments.GetFutureSchedApts(PatNum); Appointment aptNext = null; if (listApts.Count > 0) { aptNext = listApts[0]; //next sched appt. If none, null. } Clinic clinic = Clinics.GetClinic(ClinicNum); Subject = subject; //patient information Subject = Patients.ReplacePatient(Subject, _patCur); //Next Scheduled Appointment Information Subject = Appointments.ReplaceAppointment(Subject, aptNext); //handles null nextApts. //Currently Logged in User Information Subject = FormMessageReplacements.ReplaceUser(Subject, Security.CurUser); //Clinic Information Subject = Clinics.ReplaceOffice(Subject, clinic); //Misc Information Subject = FormMessageReplacements.ReplaceMisc(Subject); BodyText = bodyText; //patient information BodyText = Patients.ReplacePatient(BodyText, _patCur); //Next Scheduled Appointment Information BodyText = Appointments.ReplaceAppointment(BodyText, aptNext); //handles null nextApts. //Currently Logged in User Information BodyText = FormMessageReplacements.ReplaceUser(BodyText, Security.CurUser); //Clinic Information BodyText = Clinics.ReplaceOffice(BodyText, clinic); //Misc Information BodyText = FormMessageReplacements.ReplaceMisc(BodyText); _emailMessage.Attachments.AddRange(attachments); FillAttachments(); _hasMessageChanged = false; }
///<summary>When viewing an existing message, the "Send" button text will be "Reply" and _webMailMode will be View. Pressing the button will ///reload this form as a reply message. ///When composing a new message or replying to an existing message, the button text will be "Send" and _webMailMode will be ///either Compose or Reply. Pressing the button will cause an attempt to send the secure and insecure message if applicable.</summary> private void butSend_Click(object sender, EventArgs e) { if (_webMailMode == WebMailMode.View) { _webMailMode = WebMailMode.Reply; FillFields(); return; } if (!Security.IsAuthorized(Permissions.WebMailSend)) { return; } VerifyInputs(); if (!VerifyOutputs()) { return; } if (!VerifyFromProvider()) { return; } butSend.Enabled = false; //Insert the message. The patient will not see this as an actual email. //Rather, they must login to the patient portal (secured) and view the message that way. //This is how we get around sending the patient a secure message, which would be a hassle for all involved. _secureMessage = new EmailMessage(); _secureMessage.FromAddress = textFrom.Text; _secureMessage.ToAddress = textTo.Text; _secureMessage.PatNum = _patCur.PatNum; _secureMessage.SentOrReceived = EmailSentOrReceived.WebMailSent; //this is secure so mark as webmail sent _secureMessage.ProvNumWebMail = _provCur.ProvNum; _secureMessage.Subject = textSubject.Text; _secureMessage.BodyText = textBody.Text; _secureMessage.MsgDateTime = DateTime.Now; _secureMessage.PatNumSubj = GetPatNumSubj(); if (_allowSendNotificationMessage) { _insecureMessage = new EmailMessage(); _insecureMessage.FromAddress = _emailAddressSender.SenderAddress; _insecureMessage.ToAddress = _patCur.Email; _insecureMessage.PatNum = _patCur.PatNum; _insecureMessage.Subject = SubjectInsecure; Clinic clinic = Clinics.GetClinic(_patCur.ClinicNum) ?? Clinics.GetPracticeAsClinicZero(); _insecureMessage.BodyText = Clinics.ReplaceOffice(BodyTextInsecure, clinic, isHtmlEmail: true, doReplaceDisclaimer: true); _insecureMessage.SentOrReceived = EmailSentOrReceived.Sent; //this is not secure so just mark as regular sent //Send an insecure notification email to the patient. _insecureMessage.MsgDateTime = DateTime.Now; _insecureMessage.PatNumSubj = GetPatNumSubj(); try { EmailMessages.PrepHtmlEmail(_insecureMessage); EmailMessages.SendEmailUnsecure(_insecureMessage, _emailAddressSender); //Insert the notification email into the emailmessage table so we have a record that it was sent. EmailMessages.Insert(_insecureMessage); } catch (Exception ex) { MessageBox.Show(this, "An error occurred sending the message. Please try again later or contact support."); Logger.openlog.LogMB(this, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message, Logger.Severity.ERROR); butSend.Enabled = true; return; } } _secureMessage.Attachments = _listAttachments; EmailMessages.Insert(_secureMessage); SecurityLogs.MakeLogEntry(Permissions.WebMailSend, 0, Lan.g(this, "Web Mail sent")); MsgBox.Show(this, "Message Sent"); DialogResult = DialogResult.OK; }