Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 33 Next »

Once you have successfully defined the data that you wish your report to produce, the next step is to determine how you want this data to be output to your users. The reporting module provides a flexible framework for defining and designing your report outputs, using what we call Report Renderers. There are several Report Renderers that ship with the Reporting Module. They vary in complexity and in the amount of configuration that they accept and require. Additional Report Renderers can be easily registered by any other module with a single new class definition. The renderers that come shipped with the reporting module are described in detail below.

This section assumes that the user is running a released version of the module above 0.8

Report Design Manager

You can access or add any of these types of renderers by first clicking in the Report Administration section and then in the Report Designs link.

1Report Administration
2Report Design Manager.

In this section you can add a renderer and link it to a Report Definition (keep reading for a detail explanation). This way the renderer will become an output option for that report.

On this page you will find a list of all Report Designs that a user creates and that can be edited.

3

Another way to add a renderer is from the Output Designs box on the Report Editor page when creating a Report Definition.

Report Renderers

The Report Renderers could be easily divided in two types: configurable and non-configurable renderers. Please keep reading to learn more about the currently available type of renderers and their configuration (if any).

Default Web Renderer

The only Report Renderer that is available by default for all report definitions is the Default Web Renderer which will output the data of your report to be readable directly from OpenMRS. This basically means that the data cannot be exported or taken out of the system. The main characteristics of this renderer are:

  • No configuration needed.
  • Handles multiple data set definitions.
  • Produce a nicely formatted web-optimized display for the data, with each data set contained within its own tab.

Since this renderer is a default one for all the reports that a user might create, it won’t appear among the options listed in the Report Design Manager, but it should always be as an output option when running a report.

1Listed options under Report Design Manager page.
2

This type of renderer should always be a default output option for any user-defined report.

3Expected output

CSV Report Renderer

This comma-separated value renderer will allow you to export the data of your report to a flat file suitable for importing into Excel, SAS or another external analysis tool. The main characteristics of this renderer are:

  • This renderer only output the first data set found within the report, so it is suitable for report definitions that contain only a single data set.
  • It allows you to change the filename extension of the final file.
  • Even when the output is pre-configured to be a comma-separated value file, the user can change both the field delimiter and text delimiter (see examples below).
1Select the CSV option from the drop-down list and click on the Add another button.
2

On the configuration page, only the description field is optional.

The filename extension, field delimiter and text delimiter fields have default values.

3If you run your report, the new added design will appear as an output option of the Report Definition you previously linked it to and it will be added to the list displayed on the Report Designs Manager page as well.
4Running the same report used earlier in the Default Web Renderer example, the expected output should be a file with csv extension containing columns separated by a comma and with a text delimiter which is the closing quotation mark (the text delimiter is the character that follows a field, in this example the field is composed of the opening quotation mark and the word: type).
5Now let's say you would like your fields to be separated by a dash, then you would have to modify the field delimiter like this:
6Then the expected output file is a character-separated value (the character is a dash).

TSV Report Renderer

There’s not much difference between the CSV  and TSV (tab-separated value) renderers, both share the same characteristics. The main discrepancy is that the user cannot change the field delimiter value which always will be a Tab. The filename extension and the text delimiter are the only fields that can be modified.

1The Field Delimiter value will always be a Tab.
2If you run your report, the new added design will appear as an output option of the Report Definition you previously linked it to and

it will be added to the list displayed on the Report Designs Manager page as well.



3The expected output is a file with tsv extension and the columns are separated by a tab with a text delimiter which is the closing quotation mark (the text delimiter is the character that follows a field, in this example the field is composed of the opening quotation mark and the word: type).

HTML Report Renderer

It is a very basic renderer that produces an HTML file that contains the data of your report. Its main characteristics are:

  • No configuration is needed.
  • Handles multiple data set definitions and each one is rendered to a table in the HTML output file.
1Select the HTML (Dafault) option from the drop-down list and click on the Add another button.
2Only the description field is optional. The report definition used for this example has more than one data set definition.
3If you run your report, the new added design will appear as an output option of the Report Definition you previously linked it to and it will be added to the list displayed on the Report Designs Manager page as well.
4The expected output is an HTML file.
5If you inspect the page source code should be something like this:

XML Report Renderer

A very basic renderer which produces an XML file that contains the data of your report. Its main characteristics are:

  • No configuration is needed.
  • Handles multiple data set definitions.
  • The output format of the XML document is the following:

 

<?xml version="1.0"?>
  <dataset name="theNameOfTheDataSetInTheReport">
    <rows>
      <row>
        <eachColumnLabel>eachColumnValueAsString</eachColumnLabel>
        ...
      <row>
      ...
    <rows>
   </dataset>
   ...
1Select the XML option from the drop-down list and click on the Add another button.
2Only the description field is optional. The report definition used for this example has more than one data set definition.
3If you run your report, the new added design will appear as an output option of the Report Definition you previously linked it to and it will be added to the list displayed on the Report Designs Manager page as well.
4The expected output is an XML file with the format mentioned earlier.

XLS Report Renderer

The output of this type of renderer will be an xls file and its main characteristics are:

  • No configuration needed.
  • Handles multiple data set definitions and each one will be put in a new tab (worksheet) inside the .xls document.
  • From its configuration page you can choose to change the output to a custom Excel document.

 

1Select the Excel (Default) option from the drop-down list and click on the Add another button.
2

Only the description field is optional. The report definition used for this example has more than one data set definition.

From this page you can change the output of this design to be a custom Excel document.

3If you run your report, the new added design will appear as an output option of the Report Definition you previously linked it to and it will be added to the list displayed on the Report Designs Manager page as well.
4The expected output should be a .xls document with a tab (worksheet) for each data set definition.

Excel Report Renderer

The Excel Report Renderer allows you to upload an Excel document with .xls extension that might contain all of the layout, formatting, formulas, graphs, and other styling that you might want in your final report. Then this document is used as a template to render the output data. This Report Design handles multiple data set definitions and can be configured in different ways, keep reading to learn more about the configuration options.

To access this Report Design follows these steps:

1Select the Excel-based Template option from the drop-down list and click on the Add another button.
2

The description field is optional.

From this page you can change the output of this design to be a XLS Report Renderer.

3Keep reading to learn more about the configuration options.

Excel Report Renderer Configuration and Access Options

SectionConfiguration and Access InformationExamples
Expressions
NameConfigurationComments
PrefixDefault is #This value is required
SuffixDefault is #This value is required

Both will help to identify in the template pieces of text that are expected to be replaced with data.

If you stick  with the default values, then everything that is between the # character will be replaced:

#myDataset.myValue#

You can change to the Suffix and Prefix to be an character, for example the $ character, then you should be able to access your data in your template this way:

$myDataset.myValue$

Repeating Sections

The output data of your report might have rows and columns of information instead of just having one single value. If this is your case, then you should configure Repeating Sections to access all of your rows and/or columns.

As a side note, if the data of your report has a lot of rows and columns, might be possible that the XLS Report Renderer  is more suitable for you.

The following options literally mean if a sheet | row | column should be repeated in a template.

NameConfigurationComments
SheetNumber of the sheet to be repeated.This option should be a number and not the name of the sheet.
RowNumber or range of numbers separated with a dash that indicates the rows to be repeated. 
ColumnNumber or range of numbers separated with a dash that indicates the columns to be repeated. 
DatasetName of the Data Set the sheet | row | column option should work with.if you work with any of the options above, you should explicitly indicate which Data Set should be used to render and which sheet for the row and column options.

For the following examples let's assume that our report output the following table using the encountersByType key as name for the Data Set Definition:

Option NameWhat we wantWhat our template should haveWhat our configuration should haveWhat to expect
SheetA sheet for each type of Encounter.
RowOne row in our template for each row in the output data.

We only want to repeat the row number 5, if we want to repeat also the heading of the row ( Type and Num ) then we should indicate this in our configuration by typing 4-5 instead of 5.

Notice that along with the row number we should indicate the sheet number, even if we don't want the output shown in the sheet example.

ColumnOne column in our template for each type.
Designing Properties

You can define any key-value property that your template might need.

NameConfigurationComments
KeyTo identify the property.In the template you can access any property by suffixing its key to the word "property".
ValueValue for the property defined. 
What we wantWhat our template should haveWhat our configuration should haveWhat to expect
Define a property named "customReportTitle" that contains a title for my report.
Miscellaneous
  • About Indicator Data Set Definition:
    • if the output data of your report contains only a single Data Set Definition of type Indicator then its values can be accessed via its indicator number. For example: #1.A#.
    • But If the report contains multiple Data Set Definitions then indicator values must be prefixed with the Data Set Definition name.  For example: #myDataSet.1.A#
    • Since Reporting 0.7.2.2 you can specify the number of trailing digits. Assume an Indicator Data Set Definition whose output is single value(5 for this example):

      AddOutput
      #1.A|0#5
      #1.A|1#5.0
      #1.A|2#5.00
      #1.A|3#5.000
  • Parameters:
    • Every parameter to the report is available by its name prefixed with the word "parameter". Additionally, if this parameter is of type date you can formatted the output by adding a Java date and time patter String:

      AssumeIn the templateExpected output
      A date whose key value is "endDate" is asked to the user.
      Without any format:
      With a Java date and time patter:
  • Contextual information:

    VariableDescription
    #context.generatedBy#Contains the name of the user who generated the report. In some setups, this will be the default scheduled program user.
    #context.generationDate#Contains the date on which the report was generated and can be formatted as a parameter of type date.

     

     

Here is another example for the Excel-based Template Report Design Renderer

For technical guidance consult the Java ExcelTemplateRendererTest class.

Text Template Renderer

This Report Design Renderer evaluates a template and produces an HTML or XML or any other text-based report output. Its main characteristics are:

  • Handles multiple data set definitions.
  • Handles templates with scripting in Groovy an Velocity.
1Select HTML/text-based template option from the drop-down list and click on the Add another button.
2

Only the description field is optional. Let's assume a Data Set Definition that can be accessed with the name "encountersByTypeByGender" and the following template.

<?xml version="1.0"?>
<dataset>
    <rows>
        <%     
            dataset = reportData.dataSets.get("encountersByTypeByGender");
            for (row in dataset) { 
        %>
            <row>
                <% 
                    for (column in dataset.metaData.columns) { 
                        colValue = row.getColumnValue(column);
                        colValue = (colValue instanceof java.util.Date) ? util.format(colValue, 'dd/MMM/yyyy') : util.format(colValue);
                %>
                    <$column.label>$colValue</$column.label>
                <% 
                     }
                %>
            </row>
        <% 
            }
        %>
    </rows>
</dataset>



3If you run your report, the new added design will appear as an output option of the Report Definition you previously linked it to and it will be added to the list displayed on the Report Designs Manager page as well.
4The expected output is a text file, an XML in this example.

To learn more about how to add different types of data to your template using Groovy please check here.

For technical guidance consult the Java TextTemplateRendererTest class.

 

  • No labels