Make the current context available to macros

Donate to this project

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

  • if in checkin, consult, checkout workflows
  • if an invoice is selected in the charges workspace
openvpms:get($invoice, "amount")
$visit

The visit for the current patient. Only valid:

  • if a patient visit is selected
  • if in the checkin, consult, or checkout workflow
 
     

 

JIRA: https://openvpms.atlassian.net/browse/OVPMS-1296

Comments

Comment viewing options

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

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:

  • Customer title: openvpms:lookup($customer, "title")
  • Customer first name: openvpms:get($customer, "firstName")
  • Customer last name: openvpms:get($customer, "lastName")
  • Account balance: party:getAccountBalance($customer)
  • Clinician description: openvpms:get($clinician, "description")
  • Patient sex: openvpms:lookup($patient, "sex")
  • Patient breed: openvpms:lookup($patient, "breed")
  • Patient age: party:getPatientAge($patient)

The only one not available is the referral vet/practice, but this should be straight forward to add, by adding functions to support:

  • party:getPatientReferralVet($patient)
  • party:getPatientReferralVetPractice($patient)

You can then access their properties, e.g.:

  • Referring vet title:  openvpms:lookup(party:getPatientReferralVet($patient), "title")
  • Referring vet first name:  openvpms:get(party:getPatientReferralVet($patient), "firstName")

-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:

Macro Name Expression
@patientname Patient Name $patient.name
@customername Customer Name $customer.name
@suppliername Supplier Name $supplier.name
@customeraddress Customer Billing Address party:getBillingAddress($customer)
@customertitle Customer Title $customer.title
@customerfirstname Customer First Name $customer.firstName
@customerlastname Customer Last Name $customer.lastName
@reftitle Referral Vet Title openvpms:lookup(party:getPatientReferralVet($patient), "title")
@reffirstname Referral Vet First Name openvpms:get(party:getPatientReferralVet($patient), "firstName")
@reflastname Referral Vet Last Name openvpms:get(party:getPatientReferralVet($patient), "lastName")
@customerbalance Customer Account Balance party:getAccountBalance($customer)
@cliniciandesc Clinician Description $clinician.description
@patientbreed Patient Breed $patient.breed
@patientspecies Patient Species $patient.species
@patientsex Patient Sex $patient.sex
@patientage Patient Age $patient.age
@patientDOB Patient Date Of Birth date:formatDate($patient.dateOfBirth)
@refpractice Referral Practice Name openvpms:get(party:getPatientReferralVetPractice($patient), "name")
     

-Tim

Syndicate content