Prefilled emails from document templates

Donate to this project

Development Project Status: Completed

Total cost estimate (ex-Tax): 
Due date for completion of this stage: 
Current Percentage Funded: 
Project funding: 

You can either donate money to this project by entering the amount above and clicking the 'Add to cart' button, or you can pledge an amount by clicking here to email your commitment. If you make a pledge, then when we have 100% funding commitments, you will be notified by email and you can then make your actual donation. Note that development will not commence until all funds are received.

Project description: 


OpenVPMS supports ad-hoc emails of:

  • customer charges and estimates
  • customer, patient and supplier documents
  • reports

E.g., to email a patient document, the Print button is selected in Patients - Medical Records - Documents. The displayed Print window has a Mail button. Selecting this displays a Write window with:

  • the Subject set to the document template name
  • the document attached

This project will extend this functionality so that emails are pre-filled with text defined in the associated Document Template.

The text may optionally contain macros, to enable text to be generated based on what is being mailed.

This will save time and ensure consistency when sending emails.


The Document Template archetype will be extended to include an Expand Macros On Email flag. If selected, any macros in the Email Subject and Email Body fields will be expanded when the email is generated.

To retain backward compatibility with existing statement and reminder emails, this flag will default to off.

Macro Evaluation

Where possible, macros will evaluated against the object being mailed and will have the current context supplied as variables.

E.g. a patient medical history template may have:

  • Email Subject: Medical history for @patientname
  • Email Body: @medhistoryreferral

The Email Subject and Email Body have no restriction on the number of macros present.

Mail Attachment Macro evaluated against
Patient Form act.patientDocumentForm
Patient Image act.patientDocumentImage
Patient Letter act.patientDocumentLetter
Patient Medication Label act.patientMedication
Prescription act.patientPrescription
Reminder act.patientReminder
Patient History party.patientpet
Customer Form act.customerDocumentForm
Customer Letter act.customerDocumentLetter
Customer Attachment act.customerDocumentAttachment
Customer Invoice act.customerAccountChargesInvoice
Customer Credit act.customerAccountChargesCredit
Customer Credit Adjust act.customerAccountCreditAdjust
Customer Debit Adjust act.customerAccountDebitAdjust
Customer Estimate act.customerEstimation
Customer Payment act.customerAccountPayment
Customer Refund act.customerAccountRefund
Customer Counter Sale act.customerAcccountChargesCounter
Customer Statement party.customerperson
Supplier Form act.supplierDocumentForm
Supplier Letter act.supplierDocumentLetter
SQL Report  


Statement and Reminder emails

Statement and reminder generation currently does no macro expansion of the Email Subject and Email Body fields i.e., the fields are treated as static text.

If the statement or reminder template has Expand Macros on Email set to true, macos will need to be expanded.




Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Re: Prefilled emails from document templates

I assume that the text can infact contain multiple macros - ie - the body text could be:
Dear @custname, herewith the invoice for @patientnames visit.

Regards, Tim G

[I just realised that one needs a tailored macro to generate "Fido's" - because @patientname's will not expand]

Re: Prefilled emails from document templates

There's no restriction on the number of macros in the subject or body fields.

The reason @patientname's won't expand is because macros must be surrounded by whitespace in order to be evaluated.

Re: Prefilled emails from document templates


This looks like it fits our requirements.

One question though. Would this be able to be used for invoices/credits/refunds/estimates, etc? It would be useful if it could be used for these as well.



Re: Prefilled emails from document templates

Can now.


Re: Prefilled emails from document templates

wonderful, can we please have this costed.





Re: Prefilled emails from document templates

Done. If funded, this project will be scheduled for OpenVPMS 1.9.


Re: Prefilled emails from document templates

Hi All,

We would like to see this project progress to development asap and we are willing to contribute funds.  Can we have a show of hands for those who would be willing to share the development costs for this project ?


Tony De Keizer

Re: Prefilled emails from document templates

Hi Tony,

We will put in some $...

Re: Prefilled emails from document templates

Thanks Adrian for getting funding for this project up and running.

Syndicate content