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:
The expression is provided with:
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
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:
concat(substring($file,1,number(not(contains($file,'!')))*string-length($file)),
substring-before($file,'!'), ' - ', $patient.name, ' ', $customer.lastName, ' - ', date:format(openvpms:get(.,'startTime'), 'd MMM yyyy'))