A report definition in SanteDB's BI services framework represents an asset which is ultimately rendered to one or more output formats (like HTML, XLS, etc.).

Data sources for reports can be either a view or a query which can be referenced or inline with the report definition itself.

Report Definition Files

Report definition files define one or more data sources (query or view), metadata (including permission), and one or more views. These views represent different ways of representing data. For example you may have a report with a tabular view and a chart view.

<?xml version="1.0" encoding="utf-8" ?>
<BiReportDefinition xmlns="" id="" label="">
      <add>SanteSuite Contributors</add>
      <div xmlns="">
        <p>A simple report</p>
    <view ref="" name="main-date"/>
    <add id="" label="" name="chart">
      <div xmlns="" 
         <!-- Report Content -->

The view contents are defined using XHTML and the content is generated using view components defined in the namespace.

Report View Components

There are several built-in view components which you can use for creating your report. They are:




Aggregate one of the reports data sources


Render a localized string into the report


Repeat the contents of for each row contained in the data source


Conditional rendering of report components


Bind the contents to a particular column in the current row.


Render a pie, line, bar, radar, donut or combination chart.

Aggregate Component

The aggregate component is used to aggregate a particular data source. This is useful for showing totals, averages, counts, etc.

<bi:aggregate source="dataSourceName"

The aggregation functions currently supported are:




Adds the particular field or expression together


Counts the number of non-null values


Counts the unique instances of a value or expression


The minimum value for the value or expression in the dataset


The maximum value


Average value

You can either aggregate a field, or an expression, for exam

        <td><bi:aggregate source="main" fn="sum" format="#,###">n_patients</bi:aggregate>
        <td><bi:aggregate source="main" fn="avg" format="#,###">n_patients / cohort</bi:aggregate>

Locale Component

The locale component will replace the value of the element with the correct string from the current locale.


Repeat Component

The repeat component is an iterator which opens a dataset and repeats until the rows in the data source are exhausted.

<bi:repeat source="dataSourceName"> 
    <!-- HTML HERE -->

The contents of the repeat element is any content, for example, this component is used to create tables:

<table border="1">
        <bi:repeat source="main">
            <th>Total Patients</th>
            <th><bi:aggregate fn="count" source="main">name</bi:aggregate>

Switch Component

The switch component is used to provide conditional rendering of components.

<bi:switch value="valueOrExpression">
    <bi:when op="eq|lt|lte|gt|gte" value="valueOrExpression" not="true|false">
        <!-- HTML HERE -->
        <!-- HTML HERE -->

For example, the switch statement can be used to provide iconography:

<bi:switch value="this_month">
    <bi:when op="lt" value="last_month">
        <i class="fas fa-arrow-down"></i>
    <bi:when op="gt" value="last_month">
        <i class="fas fa-arrow-up"></i>
        <i class="fas fa-equals"></i>

Value Component

The value component allows the rendering of report data elements or expressions.

<bi:value when="[changed]" format="formatString">expressionOrField</bi:value>

The when changed indicates that the value should only be emitted when the previous rows' value is not equal to this row's value. For example:

        <bi:repeat source="patientVisits">
                <td><bi:value when="changed">name</bi:value></td>
                <td><bi:value format="yyyy-MM-dd">visitDate</bi:value>
            <td><bi:aggregate fn="count-distinct">name</bi:aggregate> <bi:locale></bi:locale></td>
            <td><bi:aggregate fn="count">visitDate</bi:aggregate></td>            

This may output a table such as:










Chart Component

The charting component allows for quick creation of basic charts using the data found in the data source.

<bi:chart type="pie|line|radar|donut|bar" source="dataSourceName">
    <bi:title>title of chart</bi:title>
    <bi:labels data="categoryField" format="formatString"/>
    <!-- Axis Series (allows multiple) -->
    <bi:axis type="linear|time" data="categoryOrField" label="label" format="formatString"/>
    <!-- One or more datasets -->
    <bi:dataset label="datasetLabel" backgroundColor="rgba()" 
        borderColor="rgba()" type="bar|line" fill="true|false" 

For example, to create a simple pie chart:

<bi:chart type="pie" source="main">
    <bi:title>Patients By Gender</bi:title>
    <bi:labels data="gender"/>
    <bi:dataset label="# of Patients" fill="true" aggregate="sum">id</bi:dataset>

It is also possible to create composite charts

<bi:chart source="main" type="bar">
    <bi:title>Patient Trends<bi:title>
    <bi:axis type="time" data="date" format="yyyy-MM" label="Month"/>
    <bi:dataset label="Males" aggregate="sum" fill="true" 
        backgroundColor="rgba(0,0,255,0.5)">gender == 'M' ? 1 : 0</bi:dataset>
    <bi:dataset label="Females" aggregate="sum" fill="true"
        backgroundColor="rgba(0,255,0,0.5)">gender == 'F' ? 1 : 0</bi:dataset>

Last updated