This section is about sending and reading program rules, and explains the program rules data model. The program rules gives functionality to configure dynamic behavior in the programs in DHIS.
The program rules data model consists of programRuleVariables, programRules and programRuleActions. The programRule contains an expression - when this expression is true, the child programRuleActions is triggered. The programRuleVariables is used to address data elements, tracked entity data values and other data values needed to run the expressions. All programRules in a program share the same library of programRuleVariables, and one programRuleVariable can be used in several programRules’ expressions.
The following table gives a detailed overview over the programRule model.
|program||The program of which the programRule is executed in.||Compulsory|
|name||The name with which the program rule will be displayed to dhis configurators. Not visisble to the end user of the program.||Compulsory|
|description||The description of the program rule, can be used by configurators to describe the rule. Not visisble to the end user of the program.||Compulsory|
|programStage||If a programStage is set for a program rule, the rule will only be evaluated inside the specified program stage.||optional|
The expression that needs to be evaluated to true in order for the program rule to trigger its child actions. The expression is written using operators, function calls, hard coded values, constants and program rule variables.
|priority||The priority to run the rule in cases where the order of the rules matters. In most cases the rules does not depend on being run before or after other rules, and in these cases the priority can be omitted. If no priority is set, the rule will be run after any rules that has a priority defined. If a priority(integer) is set, the rule with the lowest priority will be run before rules with higher priority.||optional|
The following table gives a detailed overview over the programRuleAction model.
|programRule||The programRule that is the parent of this action.||Compulsory|
The type of action that is to be performed.
|location||Used for actionType DISPLAYKEYVALUEPAIR and DISPLAYTEXT to designate which widget to display the text or keyvalyepair in. Compulsory for DISPLAYKEYVALUEPAIR and DISPLAYTEXT.||See description|
|content||Used for user messages in the different actions. See the actionType overview for a detailed explanation for how it is used in each of the action types. Compulsory for SHOWWARNING, SHOWERROR, WARNINGONCOMPLETION, ERRORONCOMPLETION, DISPLAYTEXT and DISPLAYKEYVALUEPAIR. Optional for HIDEFIELD and ASSIGN.||See description|
|data||Used for expressions in the different actions. See the actionType overview for a detailed explanation for how it is used in each of the action types. Compulsory for ASSIGN. Optional for SHOWWARNING, SHOWERROR, WARNINGONCOMPLETION, ERRORONCOMPLETION, DISPLAYTEXT, CREATEEVENT and DISPLAYKEYVALUEPAIR||See description|
|dataElement||Used for linking rule actions to dataElements. See the actionType overview for a detailed explanation for how it is used in each of the action types. Optional for SHOWWARNING, SHOWERROR, WARNINGONCOMPLETION, ERRORONCOMPLETION, ASSIGN and HIDEFIELD||See description|
|trackedEntity- Attribute||Used for linking rule actions to trackedEntityAttributes. See the actionType overview for a detailed explanation for how it is used in each of the action types. Optional for SHOWWARNING, SHOWERROR and HIDEFIELD.||See description|
|programStage||Only used for CREATEEVENT rule actions. Compulsory for CREATEEEVENT.||See description|
|programStage- Section||Only used for HIDESECTION rule actions. Compulsory for HIDESECTION||See description|
The following table gives a detailed overview over the programRuleVariable model.
the name for the programRuleVariable - this name is used in expressions.
Defines how this variable is populated with data from the enrollment and events.
|dataElement||Used for linking the programRuleVariable to a dataElement. Compulsory for all sourceTypes that starts with DATAELEMENT_.||See description|
|trackedEntity- Attribute||Used for linking the programRuleVariable to a trackedEntityAttribute. Compulsory for sourceType TEI_ATTRIBUTE.||See description|
|useCodeFor- OptionSet||If checked, the variable will be populated with the code - not the name - from any linked option set. Default is unchecked, meaning that the name of the option is populated.|
|programStage||Used for specifying a specific program stage to retreive the programRuleVariable value from. Compulsory for DATAELEMENT_NEWEST_EVENT_PROGRAM_STAGE.||See description|