Report Macros

This screen is used to create/view/edit the Report Macro lookups. These are used to enable the accelerated entry of text in any text field by running a report. The primary use of these is to generate email text.

The fields are the same as for normal Macros (see Lookups|Macros) but with a different usage for the Expression field and an additional Report field.

Description - it is sensible to use a description like the above to emphasise that the macro will generate a text version of the report (and not the actual fully formatted report)

Expression - this is used to pass the data source to the report and we need to access the thing that we are going to report on. This is done using of the JXPath Extension Functions - specifically one of the party:get*() series. As you can see in the above example the expression is getting the last visit for the current patient.
Note: You need to be careful with the syntax used in the Expression. Specifically, you can only use the $xxxx argument format ($patient in the above screen shot) if the ReportMacro is to be invoked directly by the user.  If the ReportMacro is to be invoked from say an Open Office document by using the macro:eval function, then you cannot use the $xxxx argument format. Instead, simply use a period - ie party:getPatientVisit(.) and in the Open Office document the user field should be like: [macro:eval('@referral',openvpms:get(.,'patient.entity'))] - here the second argument is passing the patient entity needed by the macro expression.

Report - the Report to run

The above macro runs the Referral Letter report, using the current patient's most recent Visit. Note that if there is no current patient, then the macro simply will not expand - ie the user will be left with the '@referral' that they typed.

Report macros can use:

  • OpenOffice documents
  • Microsoft Word documents
  • JasperReports templates

 If you are using OpenOffice or Word documents, you may want to do some conditional text handling (ie if sex=male use 'he', if female use 'she', else use 'it'.  This is possible - see here for OpenOffice, here for MS Word.

When using JasperReports templates, there are a number of issues to be aware of:

  • a fixed size font should be used
  • special properties need to be defined to indicate to JasperReports how to divide the report into a grid
  • fields should start on grid boundaries to avoid text being excluded

The easiest approach is to:

  • define all dimensions in pixels
  • set the character width and height to a round number
  • ensure the page height and width is divisible by the character size

To set the character size to 10x10 pixels in iReport:

  1. right click on the report in Report Inspector
  2. select Properties
  3. scroll down to Properties in the displayed table
  4. click on the elipsis; this will display a dialog containing the defined properties.
  5. add property net.sf.jasperreports.export.text.character.width with value 10
  6. add property net.sf.jasperreports.export.text.character.height with value 10

Set the page width and height to a multiple of the character width and height. E.g. 500x500

See also JasperReports - Text Export Sample

Syndicate content