OpenVPMS uses JXPath to perform expression evaluation within archetypes, macros, and reports.
The following extension functions can be used within expressions. They are grouped as General, Date, Expression, List, Party, Math, Macro, History, Product, Reminder, Supplier and User functions.
In the examples below you will see arguments like $patient, $customer, $visit, etc. This is a convenient shorthand for openvpms:get(.,'xxxx.entity') where xxxx is patient, customer, etc. You can also use Application Fields and here also there needs to be a $ prefix, eg $OpenVPMS.location to access the current Practice Location.
Note that the $ shorthand is only available in the GUI environment. Specifically, it can be used in macros invoked the by user, but not in macros invoked by macro:eval() when generating forms and letters.
To enclose string arguments, you can use either " or ', ie "ABC" and 'ABC' are equivalent.
Function | Description |
---|---|
openvpms:get(object, node)
Note that in the case where the node is an object reference (such as the node patient in the act.customerAppointment) then the node 'patient.objectReference' will return the patient object and one can then use this to access the patient details. In this case (see examples) using the / syntax to access the child node provides a shorthand. |
Returns the named node. If the object is null, then the default value is returned, or a null string if no default value is provided. The node name may be a single or composite name. The former returns the immediate node. A composite name is multiple node names separated by ".". Two special node names are defined:
Examples
Object Reference Examples (the first two are equivalent)
|
openvpms:set(object, node, value)
|
Sets the named node to the supplied value.
The node name may be a single or composite name. The former sets the immediate node. A composite name is multiple node names separated by ".". Examples
Note that this is a powerful low level function which should be avoided if there is a dedicated function for the task (as there is indeed for the above two examples). Indeed after build 7516, this function cannot be used in reports and macros, and can only be used in demographic updates. |
openvpms:lookup(object, node)
|
Returns the name of a lookup node. If object is null, then the default value is returned, or a null string if no default value is provided. The node name may be a single or composite name. The former returns the immediate node. A composite name is multiple node names separated by ".". Examples
|
Note that the date: functions return a timestamp. If you want a printable result then you will need to use date:format to transform the timestamp into printable text - something like:
date:format(date:add(openvpms:get(.,"startTime"),"2yr"),"d MMMM yyyy")
Function | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
date:now() date:today() date:tomorrow() date:yesterday() |
Returns the current date and time Returns the current date, with the time set to 00:00 Returns tomorrow's date, with the time set to 00:00 Returns yesterday's date, with the time set to 00:00 Note that java.util.Date.new() - which may be see in earlier code - is equivalent to date:now(). |
||||||||||||||||||||||||
date:add(dateTime, period)
|
Adds (or subtracts) a period to a date/time. The period is of the form:
({+|-}(0..9)+(h|d|m|w|q|y)+{s|e}) where:
Examples Given: dateTime = 4/10/2015 and date:now() = 30/6/2016 05:39
|
||||||||||||||||||||||||
date:format(dateTime, pattern)
|
Formats a date/time according to a SimpleDateFormat pattern. Examples Given: dateTime = 3:30:05pm 20/8/2012
|
||||||||||||||||||||||||
date:formatDate(date)
|
Formats a date using the current locale's MEDIUM format. Examples Given: dateTime = 10:38 am 15/7/2013
|
||||||||||||||||||||||||
date:formatDate(date, style)
|
Formats a date using the specified format for the current locale. Examples Given: dateTime = 11:00am 15/7/2013
|
||||||||||||||||||||||||
date:formatTime(time)
|
Formats a time using the current locale's MEDIUM format. Examples Given: dateTime = 3:30:05pm 20/8/2012
|
||||||||||||||||||||||||
date:formatTime(time, style)
|
Formats a time using the specified format for the current locale. Examples Given: dateTime = 3:30:05pm 20/8/2012
|
||||||||||||||||||||||||
date:formatDateTime(datetime)
|
Formats a date-time using the MEDIUM format for the current locale. Examples Given: dateTime = 3:30:05pm 20/8/2012
|
||||||||||||||||||||||||
date:formatDateTime(datetime, style)
|
Formats a date-time using the specified format for the current locale. Examples Given: dateTime = 3:30:05pm 20/8/2012
|
||||||||||||||||||||||||
date:formatDateTime(datetime, dateStyle, timeStyle)
|
Formats a date-time using the specified date and time styles for the current locale Examples Given: dateTime = 9:58:12am 28/7/2013
|
Function | Description |
---|---|
expr:concatIf(value1, value2)
|
Concatentates two strings, if both are not null/empty. If either is null/empty, returns an empty string. Examples
|
expr:concatIf(value1, value2, value3)
|
Concatentates three strings, if all are not null/empty. If any is null/empty, returns an empty string. Examples
|
expr:if(condition, value)
|
Evaluates the result of condition. If true, returns value, otherwise returns null. Examples
|
expr:if(condition, trueValue, falseValue)
|
Evaluates the result of condition. If true, returns trueValue, otherwise returns falseValue. Examples
|
expr:ifempty(value, elseValue)
|
Returns the first argument if it is not null or empty, or the second argument if it is. Examples
|
expr:trim(value, maxLength)
|
Truncates value if its length exceeds maxLength, otherwise returns value unchanged.
|
expr:var(name)
|
Returns the value of the named variable if it exists, otherwise returns null. Examples
|
expr:var(name, value)
|
Returns the value of the named variable if it exists, otherwise returns value. Examples
|
The following functions operate on lists of objects.
Function | Description |
---|---|
list:join(objects, node)
|
Iterates through a list of objects, joining the string value of the specified node, separated by commas.
|
list:join(objects, node, separator)
|
Iterates through a list of objects, joining the string value of the specified node, separated by separator.
Example
returns a comma separated list of the patient's aliases |
list:names(objects)
|
Concatenates object names, comma separated.
|
list:names(objects, separator)
|
Concatenates object names, separated by separator
|
list:sort(objects, node)
|
Sorts objects on a node.
|
list:sortNames(objects)
|
Sorts and concatenates the names of the objects, separated by commas.
|
list:sortNames(objects, separator)
|
Concatenates object names, separated by separator
|
list:sortNamesOf(node)
|
Sorts and concatenate the object names of the specified node, separated by commas.
|
list:values(object, node)
|
Returns the values of a collection for the specified object. The node argument may refer to a single node, or a composite node. Null values are ignored.
|
list:values(node)
|
Returns the values of a collection for the current object. The node argument may refer to a single node, or a composite node. Null values are ignored.
|
list:distinct(object, node)
|
Returns the distinct values of a collection for the specified object. The node argument may refer to a single node, or a composite node. Null values are ignored.
|
list:distinct(node)
|
Returns the distinct values of a collection for the current object. The node argument may refer to a single node, or a composite node. Null values are ignored.
|
The following functions operate on party archetypes, such as customers, patients, suppliers, and organisations.
Function | Description |
---|---|
party:getPartyFullName(party)
|
Returns the full name of the specified party Examples
|
party:getPartyFullName(act)
|
If the act has a customer node, then the full name of the customer will be returned. If there is no customer node, but there is a patient node, the full name of the owner of the patient will be returned. Examples
|
party:getPatientOwner(patient)
|
Returns the owner of a patient. Examples
|
party:getPatientOwner(act)
|
Returns the owner of a patient associated with an act. Examples
|
party:getPatientCurrentOwner(act)
|
Returns the current owner of a patient associated with an act. Examples
|
party:setPatientInactive(patient)
|
Flags a patient as being inactive. Examples
|
party:setPatientDeceased(patient)
|
Flags a patient as being deceased. This also:
Examples
|
party:setPatientDesexed(patient)
|
Flags a patient as being desexed. Examples
|
party:getPreferredContacts(party)
|
Returns a formatted string of preferred contacts for a party. Examples
|
party:getBillingAddress(party)
|
Returns a formatted billing address for a party. This looks for:
Returns an empty string if there is no location contact. Examples
|
party:getBillingAddress(act)
|
Returns a formatted billing address for a customer associated with act. If the act has a customer node, then this customer will be passed to party:getBillingAddress(party) If there is no customer node, but there is a patient node, the owner of the patient will be passed to party:getBillingAddress(party) Returns an empty string if there is no location contact. Examples
|
party:getCorrespondenceAddress(party)
|
Returns a formatted correspondence address for a party. This looks for:
Returns an empty string if there is no location contact. Examples
|
party:getCorrespondenceAddress(act)
|
Returns a formatted correspondence address for a customer associated with act. If the act has a customer node, then this customer will be passed to party:getCorrespondenceAddress(party) If there is no customer node, but there is a patient node, the owner of the patient will be passed to party:getCorrespondenceAddress(party) Returns an empty string if there is no location contact. Examples
|
party:getTelephone(party)
|
Returns a formatted telephone number for a party. This looks for:
Returns an empty string if there is no phone contact. Examples
|
party:getTelephone(act)
|
Returns a formatted telephone number for a customer associated with act. If the act has a customer node, then this customer will be passed to party:getTelephone(party) If there is no customer node, but there is a patient node, the owner of the patient will be passed to party:getTelephone(party) Returns an empty string if there is no phone contact. Examples
|
party:getHomeTelephone(party)
|
Returns a formatted home telephone number for a party. This looks for:
Returns an empty string if there is no phone contact. Examples
|
party:getHomeTelephone(act)
|
Returns a formatted home telephone number for a customer associated with act. If the act has a customer node, then this customer will be passed to party:getHomeTelephone(party) If there is no customer node, but there is a patient node, the owner of the patient will be passed to party:getHomeTelephone(party) Returns an empty string if there is no phone contact. Examples
|
party:getWorkTelephone(party)
|
Returns a formatted work telephone number for a party. This looks for the phone contact with WORK purpose. Returns an empty string if there is no such contact. Examples
|
party:getWorkTelephone(act)
|
Returns a formatted work telephone number for a customer associated with act.
If the act has a customer node, then this customer will be passed to party:getWorkTelephone(party) If there is no customer node, but there is a patient node, the owner of the patient will be passed to party:getWorkTelephone(party) Returns an empty string if there is no phone contact. Examples
|
party:getMobileTelephone(party)
|
Returns a formatted mobile telephone number for a party. This looks for the phone contact with MOBILE purpose. Returns an empty string if there is no such contact. Examples
|
party:getMobileTelephone(act)
|
Returns a formatted mobile telephone number for a customer associated with act.
If the act has a customer node, then this customer will be passed to party:getMobileTelephone(party) If there is no customer node, but there is a patient node, the owner of the patient will be passed to party:getMobileTelephone(party) Returns an empty string if there is no phone contact. Examples
|
party:getFaxNumber(party)
|
Returns a formatted fax number for a party. Returns an empty string if there is no fax contact. Examples
|
party:getFaxNumber(act)
|
Returns a formatted fax number for a customer associated with act.
If the act has a customer node, then this customer will be passed to party:getFaxNumber(party) If there is no customer node, but there is a patient node, the owner of the patient will be passed to party:getFaxNumber(party) Returns an empty string if there is no fax contact. Examples
|
party:getEmailAddress(party)
|
Returns a formatted email address for a party. Returns an empty string if there is no email contact. Examples
|
party:getEmailAddress(act)
|
Returns a formatted email address for a customer associated with act.
If the act has a customer node, then this customer will be passed to party:getEmailAddress(party) If there is no customer node, but there is a patient node, the owner of the patient will be passed to party:getEmailAddress(party) Returns an empty string if there is no email contact. Examples
|
party:getWebsite(party)
|
Returns the website for a party. Returns an empty string if there is no website contact. Examples
|
party:getContactPurposes(contact)
|
Returns a formatted string of contact purposes for a contact. |
party:identities(party)
|
Returns a formatted string of a party's identities. |
party:getAccountBalance(customer)
|
Returns the account balance for a customer. Examples
|
party:getAccountBalance(act)
|
Returns the account balance for a customer associated with act. If the act has a customer node, then this customer will be passed to party:getAccountBalance(customer) If there is no customer node, but there is a patient node, the owner of the patient will be passed to party:getAccountBalance(customer) Examples
|
party:getPatientReferralVet(patient)
|
Returns the referral vet for a patient. This is the patient's associated veterinarian from the first matching Referral (either a Referred From or Referred To relationship) active at the current time. Examples
|
party:getPatientReferralVet(act)
|
Returns the referral vet for a patient linked to act. This is the patient's associated veterinarian from the first matching Referral (either a Referred From or Referred To relationship) active at the act's start time. Examples
|
party:getPatientReferralVetPractice(patient)
|
Returns the referral vet practice for a vet associated with the supplied patient, active at the current time. Examples
|
party:getPatientReferralVetPractice(act)
|
Returns the referral vet practice for a vet associated with the supplied act's patient, active at the act's start time. Examples
|
party:getReferralVetPractice(vet, date)
|
Returns the referral vet practice for a vet, for the specified date. |
party:getPatientAge(patient)
|
Returns the age of the patient. Examples
|
party:getPatientMicrochip(patient)
|
Returns a patient's microchip, or an empty string if none exists. Examples
|
party:getPatientMicrochip(act)
|
Returns the microchip for a patient linked to act. Examples
|
party:getPatientMicrochips(patient)
|
Returns a patient's microchips, or an empty string if none exists. If there are more than one, then the values are separated by commas, eg Examples
|
party:getPatientMicrochips(act)
|
Returns the microchips for a patient linked to act. Examples
|
party:getMicrochip(party)
|
Returns the most recent active entityIdentity.microchip for party. Examples
|
party:getMicrochip(act)
|
Returns the most recent active entityIdentity.microchip for a patient linked to act. Examples
|
party:getPatientPetTag(patient)
|
Returns the pet tag for a patient,or an empty string if none exists. Examples
|
party:getPatientPetTag(act)
|
Returns the pet tag for a patient linked to act. Examples
|
party:getPatientRabiesTag(patient)
|
Returns the rabies tag for a patient,or an empty string if none exists. Examples
|
party:getPatientRabiesTag(act)
|
Returns the rabies tag for a patient linked to act. Examples
|
party:getPatientWeight(patient)
|
Returns the formatted weight for a patient, or an empty string if the patient has not been weighed. This uses the most recent recorded weight for the patient.
|
party:getPatientWeight(act)
|
Returns the formatted weight for a patient linked to act, or an empty string if the patient has not been weighed. This uses the most recent recorded weight for the patient. Examples
|
party:getWeight(patient)
|
Returns the patient weight in kg. If the patient has no recorded weight, returns 0. This uses the most recent recorded weight for the patient. Examples
|
party:getWeight(patient, units)
|
Returns the patient weight in the specified units. If the patient has no recorded weight, returns 0. This uses the most recent recorded weight for the patient. Examples
|
party:getWeight(act)
|
Returns the weight (in kilograms) for a patient linked to act, or 0 if there is no patient, or the patient has no weight recorded. This uses the most recent recorded weight for the patient. Examples
|
party:getWeight(act, units)
|
Returns the weight in units for a patient linked to act, or 0 if there is no patient, or the patient has no weight recorded. This uses the most recent recorded weight for the patient. Examples
|
party:getPatientDesexStatus(patient)
|
Returns the desex status of a patient. Examples
|
party:getPatientDesexStatus(act)
|
Returns the desex status of a patient linked to act. Examples
|
party:getPatientVisit(patient)
|
Returns the most recent Visit (i.e. act.patientClinicalEvent) for a patient. Examples
|
party:getPractice() |
Returns the practice object which can then be used to access other practice nodes. Note however, that the OpenVPMS.practice Application Fields form is more convenient. Example
|
party:getPracticeAddress() | Returns the practice address as a single line, or an empty string if the practice has no location contact. If you need it in multi-line format use say party:getBillingAddress(party:getPractice()) |
party:getPracticeTelephone() | Returns the practice WORK telephone, or an empty string if the practice has no phone contact with the purpose Work. |
party:getPracticeFaxNumber() | Returns the practice fax number, or an empty string if the practice has no fax contact |
party:getAppointments(party, interval, units)
|
Returns the Pending appointments for a customer or patient starting from now to the specified interval.
Examples
|
|
Returns the BPay Customer Reference Number for a party. This is the id of the party plus a check digit generated using the Luhn 10 algorithm. Examples
|
party:getBpayID(act)
|
Returns a the BPay CRN (see above) for a customer associated with act.
If the act has a customer node, then this customer will be passed to party:getBpayID(party) If there is no customer node, but there is a patient node, the owner of the patient will be passed to party:getBpayID(party) Examples
|
party:getLetterheadContacts(location)
|
Returns:
This function is normally invoked as: |
Function | Description |
---|---|
math:round(value, n) |
Rounds value to n decimal places. Examples
|
math:pow(value, n) |
Returns valuen Examples
|
The following function can be used in document template content files. Its primary use is to provide standardised text strings for multiple documents.
Function | Description | ||||
---|---|---|---|---|---|
macro:eval(macro)
|
Expands the specified macro.
Examples Given: the macro fn_bloggs contains the expression:
|
||||
macro:eval(macro, expr)
|
Expands the specified macro, using expr to provide the context for the macro. Examples Given: the standard @qid macro which uses the dispensingVerb macro
|
The patient history functions are restricted for use within Jasper Reports. They are designed to be used in sub-report expressions. E.g.:
$P{dataSource}.getExpressionDataSource("history:medication(openvpms:get(.,'patient.entity'))")
Function | Description |
---|---|
history:charges(patient)
|
Returns all invoice item acts for a patient, ordered on descending start time.
|
history:charges(patient, productTypeName)
|
Returns all invoice item acts for a patient, that have the specified product type name, ordered on descending start time.
|
history:charges(patient, date)
|
Returns all invoice item acts for a patient on the specified date, ordered on descending start time.
|
history:charges(patient, from, to)
|
Returns all invoice item acts for a patient between the specified dates, ordered on descending start time. If a date is null, indicates it is unbounded. The second example gets the charges for the last 60 days.
|
history:charges(patient, productTypeName, date)
|
Returns all invoice item acts for a patient that have the specified product type name, on the specified date, ordered on descending start time.
|
history:charges(patient, productTypeName, from, to)
|
Returns all charge acts for a patient that have the specified product type name, between the specified dates, ordered on descending start time. If a date is null, indicates it is unbounded. The second example gets the Vaccinations for the last 6 months.
|
history:medication(patient)
|
Returns all medication acts for a patient, ordered on descending start time.
|
history:medication(patient, productTypeName)
|
Returns all medication acts for a patient, that have the specified product type name, ordered on descending start time.
|
history:medication(patient, date)
|
Returns all medication acts for a patient on the specified date, ordered on descending start time.
|
history:medication(patient, from, to)
|
Returns all medication acts for a patient between the specified date/times, ordered on descending start time. If a date is null, indicates it is unbounded. The first example gets medications from 1/1/2010 through to 00:00:00 today, the second those in the last 12 hours.
|
history:medication(patient, productTypeName, date)
|
Returns all medication acts for a patient that have the specified product type name, on the specified date, ordered on descending start time.
|
history:medication(patient, productTypeName, from, to)
|
Returns all medication acts for a patient that have the specified product type name, between the specified date/times, ordered on descending start time. If a date is null, indicates it is unbounded.
|
Function | Description |
---|---|
price(product,taxExPrice)
|
Returns the price for a product, given a tax-exclusive price.
|
price(product,taxExPrice, taxInclusive)
|
Returns the price for a product, given a tax-exclusive price.
|
round(price)
|
Rounds a price according to the practice currency rounding convention.
|
taxRate(product)
|
Returns the tax rate for a product, expressed as a percentage.
|
Reminders functions returning lists of act.patientReminder acts are restricted for use within Jasper Reports. They are designed to be used in sub-report expressions. E.g.:
$P{dataSource}.getExpressionDataSource("reminder:getReminders(., 1, 'YEARS')")
Function | Description |
---|---|
getReminders(act, dueInterval, dueUnits)
|
Returns a list of reminders for a customer's patients for the customer associated with the supplied act.
|
getReminders(act, dueInterval, dueUnits, includeOverdue)
|
Returns a list of reminders for a customer's patients for the customer associated with the supplied act, optionally including overdue reminders.
|
getReminders(customer, dueInterval, dueUnits)
|
Returns a list of reminders for a customer's patients.
|
getReminders(customer, dueInterval, dueUnits, includeOverdue)
|
Returns a list of reminders for a customer's patients.
|
getDocumentFormReminder(act)
|
Returns a reminder associated with a Form act, if any. For forms linked to an invoice item, this If there are multiple reminders with the same due date, the reminder with the lesser Id will be used. For forms not linked to an invoice item that have a product with reminders, a reminder with the nearest due date to that of the form's start time will be returned. For forms that don't meet the above, null is returned.
|
getReminders(patient, date)
|
Returns all reminders for a patient starting on the specified date.
|
getReminders(patient, from, to)
|
Returns all reminders for a patient starting on or after from and before to.
|
getReminders(patient, productTypeName, date)
|
Returns all reminders for a patient starting on the specified date, having a product with the specified product types.
|
getReminders(patient, productTypeName, from, to)
|
Returns all reminders for a patient starting on or after from and before to, having a product with the specified product types.
|
Function | Description |
---|---|
accountId(supplier, location)
|
Returns the account identifier that a practice location uses when corresponding with a supplier. Examples
|
accountId(supplierId, location)
|
Returns the account identifier that a practice location uses when corresponding with a supplier. This form accepts the supplier identifier, and can be used when there is no other way to access the supplier details. Examples
|
Function | Description |
---|---|
user:format(user, style)
|
Formats a user name according to the specified style. Styles are configured for the practice via the Short User Name Format, Medium User Name Format and Long User Name Format options. Examples
|