Program Indicators Create and Edit - LogicalOutcomes/DHIS2-FAQ GitHub Wiki
Task:
- Create and edit Program Indicators in DHIS2.
Notes:
-
Program indicators are expressions based on data elements and attributes of tracked entities which can be used to calculate values based on a formula.
-
Indicators are disconnected from the value of Data Elements, and therefore can be changed without affecting the underlying raw data.
-
Commonly used numbers (e.g. 3.14) can be saved as a Constant to reduce the need to be manually entered into formulas.
Instructions:
Create a Program Indicator:
1) Go to the Maintenance app
2) Click 'Program indicator'
Program indicators consist of an aggregation type, an analytics type, an expression and a filter.
Creating a Program indicator is a three-step process:
Step 1: Fill out program indicator details:
*Note that the Short name needs to be less than 50 characters. Find more information on Aggregation type and Analytics type below.
Step 2: Fill out the program indicator expression:
The expression defines how the indicator is calculated. The expression can contain references to various entities which will be substituted with a related value when the indicator is calculated:
- Data elements: Will be substituted with the value of the data element for the time period and organisation unit for which the calculation is done. Refers to both program stage and data element.
- Attributes: Will be substituted with the value of the attribute for the person / tracked entity for which the calculation is done.
- Variables: Will be substituted with special values linked to the program, including incident date and date of enrollment for the person, current date and count of values in the expression for the time period and organisation unit for which the calculation is done.
- Constants: Will be substituted with the value of the constant.
The expression is a mathematical expression and can also contain operators.
For single event programs and tracker programs with analytics type event: the expression will be evaluated per event, then aggregated according to its aggregation type.
For tracker programs with analytics type enrollment: the expression will be evaluated per enrollment, then aggregated according to its aggregation type.
Step 3: Fill out the program indicator filter:
The filter is applied to events, and filters the data source used for the calculation of the indicator. I.e. the filter is applied to the set of events before the indicator expression is being evaluated. The filter must evaluate to either true or false. It filter is applied to each individual event. If the filter evaluates to true then the event is included later in the expression evaluation, if not it is ignored. The filter can, in a similar way as expressions, contain references to data elements, attributes and constants.
The program indicator filter can in addition use logical operators. These operators can be used to form logical expressions which ultimately evaluate to either true or false. For example, you can assert that multiple data elements must be a specific value, or that specific attributes must have numerical values less or greater than a constant.
Both program indicator expressions and filters can use data elements or attributes which may have different value types. To calculate expression values and/or to use the filtering options, value types must be entered, using the correct syntax. The table below provides examples of syntax per value type. It shows how each value type is coded and how it should be presented in the expression or filter fields.
Expression and filter examples per value type
The program indicator expression and filter support a range of functions. The functions can be applied to data elements and attributes.
Functions to use in a program indicator expression or filter
A filter that uses both an attribute with a text value type and a data element with a number value type looks like this:
A{cejWyOfXge6} == 'Female' and 3{A03MvHHogjR.a3kGcGDCuk6} <= 2
A filter that uses "hasValue" function looks like this:
d2:hasValue(#{mCXR7u4kNBW.NFkjsNiQ9PH})
An expression that uses the "daysBetween" function looks like this:
d2:daysBetween (#{mCXR7u4kNBW.k8ja2AiflAe}, '2015-06-01'
The program indicator expression and filter support a range of variables:
An expression that uses the "event_date" and "incident_date" variables looks like this:
d2:daysBetween(V{incident_date},V{event_date})