File Name Format

This screen allows you to create/view/edit a File Name Format.

These are used to format the names of documents generated from a Document Template.

The fields are as follows:

  • Name - the format name
  • Description - a description of the format
  • Expression - the xpath expression to format file names

The expression is provided with:

  • a $file variable. This represents the name of the template
  • the object that the template is being applied to e.g. act.customerAccountChargesInvoice, act.customerAccountPayment, act.patientDocumentLetter, act.customerDocumentForm, act.supplierDocumentAttachment
  • a $patient variable, if a patient is linked to the act
  • a $customer variable, if a customer is linked to the act, or the owner of the patient, if a there is only a patient present
  • a $supplier variable, if a supplier is linked to the act

To ensure that generated file names are valid, any illegal characters such as \, /, :, *, ?, <, >, and | are replaced with underscores.


Note that in some cases it is useful/necessary to have different templates for different practice locations. These will have different names (such as Estimate CC and Estimate EIAH), and it may not be desirable for the file name to include the location signature - ie you just want 'Estimate' rather than 'Estimate CC' or 'Estimate EIAH'.

One way to achieve this is to adopt the convention that the template name be formatted as <part1>[!<part2>] - ie something optionally followed by an ! character and more text - eg like one of the following

  1. Estimate!CC
  2. Estimate!EIAH
  3. Estimate

then we can extract the <part1> bit (ie 'Estimate') using the expression:

concat (substring($file,1,number(not(contains($file,'!')))*string-length($file)),
       substring-before($file,'!'), .....)

This works because if there is no ! present (ie case 3 above) then the first argument will be $file (ie 'Estimate'), and the second argument will be an empty string.

In cases 1 & 2 (where there is an ! present) then the first argument will be an empty string and the second the characters up to the !, ie 'Estimate'.

So - for the 'Document name - patient full name - document date' the, the full expression for the File Name format expression is:

       substring-before($file,'!'), ' - ', $, ' ', $customer.lastName, ' - ', date:format(openvpms:get(.,'startTime'), 'd MMM yyyy'))

Syndicate content