Expression Features in Macros
Submitted by EastsideVetEmerg on Sun, 03/03/2013 - 13:01
Hi,
I am having trouble getting the expression features to work as described in section 5 of http://www.openvpms.org/documentation/creating-and-using-macros
In particular I would like to be able to define macros to that can for example insert the patient name/client name/clinician name/clinician description/date/time etc. If the lookup could pull products associated with the current invoice that would be even more amazing....
If someone could help explain to me how to define these lookups and the such that would be really appreciated.
Thanks,
Adrian
Re: Expression Features in Macros
I think you are talking about document merging
http://www.openvpms.org/document-merging-with-open-office-writer
Macros are mostly used to automate patient history or label writing.
http://www.openvpms.org/documentation/creating-and-using-macros
the availability of certain lookups will depend on the macros context ie which screen its being used on...the easiest way to learn by doing and modifying existing macros
What are you trying to achieve and where.??
Re: Expression Features in Macros
Note that macros may depend on the context of where they are invoked.
The @pat, @cust, @owner, @clin macros will only work if the context they are being invoked from has been saved. E.g. @clin won't work in a patient note if the patient note hasn't been saved with the clinician.
In fact, if you are editing a patient note and enter @clin after the clinician has changed but not saved, the previous clinician's name will be displayed.
I suspect you won't be able to get a list of products associated with the current invoice, without some additional supporting functions. What are you trying to do?
-Tim
Re: Expression Features in Macros
Hi Ben And Tim,
Thank you for that. It is helpful and I think it would be great if it could be put into the http://www.openvpms.org/documentation/creating-and-using-macros notes to help people understand this better.
I don't think I can see a way to achieve all the things I want. What I am trying to achieve:
1) I have a Macro that is basically a consult template. At the top of each is a space for clinicians to enter their name, the current date and time and the referral vet. I would like to add into the Consult Macro other macros that automatically insert this information. Currently it seems it will do the clinician and I have worked out how to do the referral vet practice. The date and time gets auto-expanded in the macro editing area so will/may not work (i.e. it seems about as fast to write @tod @now as it is to just write the current date and time). Some of these macros had been disabled and some I just added in now.
2) We are trying to use open to mail histories directly to referring vets rather than printing a pdf to email or creating a letter to email from an external program. I have a template that goes along the lines of ..
Re: Expression Features in Macros
Correct; those macros require an act (e.g. patient history item etc) in order to extract their information.
They cannot work inside an email. You have raised an interesting point however. You want to be able to merge data from a number of sources into an email. I think the best to support this would be to:
1. Add support for text based Jasper Reports templates. These would enable you to create reports like discharge summaries, suitable for email
2. Add support to merge and mail text based Jasper Reports. Here, you would be able to launch an email editor from a template which would pre-populate the necesssary fields, but allow you to edit the result prior to sending it.
E.g. to mail a discharge summary, you would select the patient visit, click "Mail from Template" (say), and select the "Discharge Summary" template. The Discharge Summary template would be passed the visit; from this it can work out the referring vet practice, what medication was supplied, the patient, and customer name.
The email editor would then be displayed with all of the required details pre-populated.
-Tim
Re: Expression Features in Macros
Hi Tim,
I don't know enough about the system to know the best way to achieve this so I will take your word for it. Is it possible to continue to just have the mail button but then be able to run a macro that inserts this information rather than creating a whole new button/template type etc to create an email?
Costing?
Cheers,
Adrian
Re: Expression Features in Macros
Possibly, but macros aren't really good for this.
I could supply a variables to the mail editor that your macros could refer to, e.g:
Your macros could then refer to these variables to expand to the appropriate text.
E.g. the patient macro @pat would be:
openvpms:get($patient, "name");
There is no easy way of getting a list of products from the invoice, to format:
Re: Expression Features in Macros
Hi Tim,
So if I understand correctly there are two options.
1) Variables option mentioned above where we could add macro expression values in the mail editor. I could have my little "Dear @refvetprac, Please find attached.... template".
But this is about as sophisticated as this will get.
2) A more complex option where macros could run like jasper reports and produce lists of products associated with an invoice and this would emerge as text in places like the mail editor (and presumably other places like notes?
Sorry, just want to be clear before we request costing and the such...
Cheers,
Adrian
Re: Expression Features in Macros
Not quite what I envisaged. My two options were to add support to:
1. provide variables for the current customer, patient, invoice etc, that can be referred to in macros.
You could do much of your sample email using these, with the exception of the listing of medication products
2. merge and mail text based Jasper Reports.
Here, you would be able to launch an email editor from a template which would pre-populate the necesssary fields, but allow you to edit the result prior to sending it.
You've suggested a third option which is superior:
3. define a macro which applies a text-based Jasper Report
Here, you would specify the name of the report to evaluate. It would be supplied with variables such as the current customer, patient, and invoice. The report would generate text which would replace the macro text.
So you could define a macro, @dischargesummary which would run a Jasper Report to generate text in an email, or notes for example.
Beautiful.
Re: Expression Features in Macros
Hi,
Ok. Can we please cost options 1 & 3?
Thanking you,
Adrian
Re: Expression Features in Macros
I've created two projects for these:
-Tim