JXPath Extension Functions
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, Expression, Date, Party, Math, Macro and History 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.
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.
General Functions
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). |
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
|
Date Functions
Function | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Note that in the following, the current date and time can be accessed by using java.util.Date.new() as the dateTime argument, eg date:formatDate(java.util.Date.new()) | |||||||||||
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
|
Expression Functions
Function | Description |
---|---|
expr:if(condition, value)
|
Evaluates the result of condition. If true, returns value, otherwise returns null.
|
expr:if(condition, trueValue, falseValue)
|
Evaluates the result of condition. If true, returns trueValue, otherwise returns falseValue. Examples
|
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
|
Party Functions
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:
Returns an empty string if there is no phone 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:
Returns an empty string if there is no phone 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: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: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: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. |
party:getPracticeAddress() | Returns the practice address, or an empty string if the practice has no location contact. |
party:getPracticeTelephone() | Returns the practice telephone, or an empty string if the practice has no phone contact |
party:getPracticeFaxNumber() | Returns the practice fax number, or an empty string if the practice has no fax contact |
|
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
|
Math Functions
Function | Description |
---|---|
math:round(value, n) |
Rounds value to n decimal places. Examples
|
math:pow(value, n) |
Returns valuen Examples
|
Macro Functions
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) macro:eval(macro, .) macro:eval(macro, expr) The first two forms are equivalent.
|
Expands the specified macro Examples Given: the macro fn_bloggs contains the expression
|
History Functions
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: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, from, to)
|
Returns all medication acts for a patient between the specified dates, inclusive, ordered on descending start time. If a date is null, indicates it is unbounded.
|
history:medication(patient, productTypeName, from, to)
|
Returns all medication acts for a patient that have the specified product type name, between the specified dates, inclusive, ordered on descending start time. If a date is null, indicates it is unbounded.
|
Reminder Functions
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.
|