Home ›
Make the current context available to macros
Donate to this project
Submitted by tanderson on Thu, 21/03/2013 - 15:40
Development Project Status: Completed
Total cost estimate (ex-Tax):
$520
Due date for completion of this stage:
21/03/2013 Release:
1.7
Current Percentage Funded:
100.00% Project funding:
Public pledges can be made to this forum topic or email me directly by clicking here (link only works in the forum). Development will not commence until fully funded.
Project description:
This project will make the current application context available to macros using variables.
The variables will be available to macros:
- during editing
- when sending mail
- when sending SMSes
- when editing report parameters
Variable | Description | Example |
---|---|---|
$patient | The current patient | openvpms:get($patient, "name") |
$customer | The current customer | party:getBillingAddress($customer) |
$practice | The current practice | party:getCorrespondenceAddress($practice) |
$location | The current practice location | party:getTelephone($location) |
$stockLocation | The current stock location | openvpms:get($stockLocation, "description") |
$supplier | The current supplier | openvpms:get($supplier, "notes") |
$product | The current product | openvpms:get($product, "label") |
$deposit | The current deposit account | openvpms:get($deposit, "accountNumber") |
$till | The current till | date:formatDate(openvpms:get($till, "lastCleared")) |
$clinician | The current clinician | openvpms:get($clinician, "name") |
$user | The current user | openvpms:get($user, "name") |
$invoice |
The current invoice. Only valid
|
openvpms:get($invoice, "amount") |
$visit |
The visit for the current patient. Only valid:
|
|
Comments
Re: Make the current context available to macros
Hi,
This is great, however can we please also add in macros for:
- Ref vet title
- Ref vet first name
- Ref vet surname
- Ref vet practice
- Customer title
- Customer first name
- Customer last name
- Account balance
- Clinician description
- Patient sex, breed, age, etc... If easy to do while we do the rest.
Thanking you,
Adrian
Re: Make the current context available to macros
You should be able to get most of these using the variables in the following expressions:
The only one not available is the referral vet/practice, but this should be straight forward to add, by adding functions to support:
You can then access their properties, e.g.:
-Tim
Re: Make the current context available to macros
Hi,
We at Eastside will pledge 50% of this project. We are excited to get it up an running (with the additions mentioned above).
A question... Would it be much of an addition to allow simple calculations to be run from within macros?
Basically:
- addition
- subtraction
- multiplication
- division
- to the power of....
e.g. Macro to calculate Body Surface Area from weight?
you type weight and macro and it gives you the BSA?
5kg dog... you type 5BSA and it does the calculation....
Re: Make the current context available to macros
Math operators can already be used in macros as they use a variation of the xpath language.
To calculate the BSA of a cat for example, you could specify your macro as:
math:roundAmount(10.4 * java.lang.Math.pow($number, 0.67) div 100)
(The syntax is a bit clumsy...)
Re: Make the current context available to macros
Hi Tim,
I will fund the other half of this project with Adrian.
Sam Snelling @ Advanced Vetcare
Re: Make the current context available to macros
I've uploaded a snapshot of OpenVPMS 1.7 to http://demo.openvpms.org/alpha/login that includes this change.
You can access it with the user name guest and password User1234.
I've gone a little further than the original spec in that you can use the archetype dot notation e.g. given the variable $patient you can access its name using $patient.name, identifier using $patient.id etc.
This is simpler than the old style of openvpms:get($patient, "name") and openvpms:get($patient, "id")
I've included the following sample macros:
-Tim