This screen is used to create/view/edit the Report Macro lookups. These are used to:
If you are having problems, see here.
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. See below.
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 - i.e. the user will be left with the '@referral' that they typed.
Report macros can use:
OpenOffice and Word documents
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.
JasperReports templates
When using JasperReports templates, there are a number of issues to be aware of:
The easiest approach is to:
To set the character size to 10x10 pixels in iReport:
Set the page width and height to a multiple of the character width and height. E.g. 500x500. Note also:
See also JasperReports - Text Export Sample
Report macros can be run in documents using the macro:eval function.
To access the document (e.g. Patient Letter or Form) that launched them:
to run the macro, where <code> is the report macro code.