23.7 [Work in progress] Manage validation rules

23.7.1 About validation rules

A validation rule is based on an expression. The expression defines a relationship between data element values. The expression forms a condition with certain logical criteria.

The expression consists of:

  • A left side

  • A right side

  • An operator

A validation rule asserting that the total number of vaccines given to infants is less than or equal to the total number of infants.

In the Maintenance app, you manage the following validation rule objects:

Object type

What you can do

Validation rule

Create, edit, clone, delete, show details, and translate

Validation rule group

Create, edit, clone, delete, share, show details, and translate

Validation notification

Create, edit, clone, delete, show details, and translate

23.7.1.1 About sliding windows

You can use sliding windows to group data across multiple periods as opposed to selecting data for a single period . Sliding windows have a size, that is to say, the number of days to cover, a starting point and an end point. The example below shows disease surveillance data:.

  • The data in the orange section, selects data based on the current period. There is a threshold, which is calculated once for each week or period, and this is shown in the “Result” section.

  • The data in the blue section is the sliding window. It selects data from the past 7 days. The “Result” shows the total number of confirmed cases of a disease.

  • The validation rule makes sure users are notified when the total number of cases breaks the threshold for the period.

Different behaviour of validation rules

With sliding windows

Without sliding windows

Used only for event data.

Used for event data and aggregate data.

Data selection is based on a fixed number of days (periodType).

Data selection is always based on a period.

The position of the sliding window is always relative to the period being compared.

Data is always selected for the same period as the period being compared.

See also: How to use sliding windows when you’re Creating or editing a validation rule .

23.7.1.2 About validation rule groups

A validation rule group allows you to group related validation rules. When you run a validation rule analysis , you can choose to run all of the validation rules in your system, or just the validation rules in one group.

23.7.1.3 About validation notifications

You can configure a validation rule analysis to automatically send notifications about validation errors to selected user groups. These messages are called validation notifications . They are sent via the internal DHIS2 messaging system.

You can send validation rule notifications as individual messages or as message summaries. This is useful, for example, if you want to send individual messages for high-priority disease outbreaks, and summaries for low-priority routine data validation errors.

23.7.2 Create or edit a validation rule

  1. Open the Maintenance app and click Validation > Validation rule .

  2. Click the add button.

  3. Type a Name .

    The name must be unique among the validation rules.

  4. (Optional) In the Code field, assign a code.

  5. (Optional) Type a Description .

  6. Select an Importance : High , Medium or Low .

  7. Select a Period type .

  8. Select an Operator : Compulsory pair , Equal to , Exclusive pair , Greater than , Greater than or equal to or Not equal to .

    The Compulsory pair operator allows to require that data values must be entered for a form for both left and right sides of the expression, or for neither side. This means that you can require that if one field in a form is filled, then one or more other fields must also be filled.

    The Exclusive pair allows to assert that if any value exist on the left side then there should be no values on the right side (or vice versa). This means that data elements which compose the rule on either side should be mutually exclusive from each other, for a given time period / organisation unit /attribute option combo.

  9. Create the left side of the expression:

    1. Click Left side .

    2. Select Sliding window if you want to view data relative to the period you are comparing. See also About validation rules .

    3. Select a Missing value strategy . This selection sets how the system evaluates a validation rule if data is missing.

      Option

      Description

      Skip if any value is missing

      The validation rule will be skipped if any of the values which compose the expression are missing. This is the default option.

      Always select this option you use the Exclusive pair or Compulsory pair operator.

      Skip if all values are missing

      The validation rule will be skipped only if all of the operands which compose it are missing.

      Never skip

      The validation rule will never be skipped in case of missing data, and all missing operands will be treated effectively as a zero.

    4. Type a Description .

    5. Build an expression based on the available data elements, program objects, organisation units, counts and constants.

      In the right pane, double-click the data objects you want to include in the expression. Combine with the mathematical operators located below the left pane.

    6. Click Save .

  10. Create the right side of the expression:

    1. Click Right side .

    2. Select a Missing value strategy . This selection sets how the system evaluates a validation rule if data is missing.

      Option

      Description

      Skip if any value is missing

      The validation rule will be skipped if any of the values which compose the expression are missing. This is the default option.

      Always select this option you use the Exclusive pair or Compulsory pair operator.

      Skip if all values are missing

      The validation rule will be skipped only if all of the operands which compose it are missing.

      Never skip

      The validation rule will never be skipped in case of missing data, and all missing operands will be treated effectively as a zero.

    3. Select Sliding window if you want to view data relative to the period you are comparing. See also About validation rules .

    4. Type a Description .

    5. Build an expression based on the available data elements, program objects, organisation units, counts and constants.

      In the right pane, double-click the data objects you want to include in the expression. Combine with the mathematical operators located below the left pane.

    6. Click Save .

  11. (Optional) Choose which Organisation unit levels this rule should be evaluated for. Leaving this empty will cause the validation rule to be evaluated at all levels.

  12. (Optional) Click Skip this rule during form validation to avoid triggering this rule while doing data entry

  13. Click Save .

23.7.3 Create or edit a validation rule group

  1. Open the Maintenance app and click Validation > Validation rule group .

  2. Click the add button.

  3. Type a Name .

  4. (Optional) In the Code field, assign a code.

  5. (Optional) Type a Description .

  6. Double-click the Validation rules you want to assign to the group.

  7. Click Save .

23.7.4 Create or edit a validation notification

  1. Open the Maintenance app and click Validation > Validation notification .

  2. Click the add button.

  3. Type a Name .

  4. (Optional) In the Code field, assign a code.

  5. Select Validation rules .

  6. Select Recipient user groups .

  7. (Optional) Select Notify users in hierarchy only .

    If you select this option, the system will filter the recipient users. (The system derives the recipient users from the recipient user groups.) The filter is based on which organisation unit the recipient user belongs to. The users linked to organisation units which are ancestors of the organisation unit where the violation took place will receive validation notifications. The system will ignore other users and these users won’t receive validation notifications.

  8. Create the message template:

    1. Create the Subject template .

      Double-click the parameters in the Template variables field to add them to your subject.

    2. Create the Message template .

      Double-click the parameter names in the Template variables field to add them to your message.

  9. Click Save .

23.7.5 Clone metadata objects

Cloning a data element or other objects can save time when you create many similar objects.

  1. Open the Maintenance app and find the type of metadata object you want to clone.

  2. In the object list, click the options menu and select Clone .

  3. Modify the options you want.

  4. Click Save .

23.7.6 Change sharing settings for metadata objects

You can assign different sharing settings to metadata objects, for example organisation units and tracked entity attributes. These sharing settings control which users and users groups that can view or edit a metadata object.

Some metadata objects also allows you to change the sharing setting of data entry for the object. These additional settings control who can view or enter data in form fields using the metadata.

Note

The default setting is that everyone ( Public access ) can find, view and edit metadata objects.

  1. Open the Maintenance app and find the type of metadata object you want to modify.

  2. In the object list, click the context menu and select Sharing settings .

  3. (Optional) Add users or user groups: search for a user or a user group and select it. The user or user group is added to the list.

  4. Change sharing settings for the access groups you want to modify.

    • Can edit and view : The access group can view and edit the object.

    • Can view only : The access group can view the object.

    • No access (only applicable to Public access ): The public won’t have access to the object.

  5. Change data sharing settings for the access groups you want to modify.

    • Can capture data : The access group can view and capture data for the object.

    • Can view data : The access group can view data for the object.

    • No access : The access group won’t have access to data for the object.

  6. Click Close .

23.7.7 Delete metadata objects

Note

You can only delete a data element and other data element objects if no data is associated to the data element itself.

Warning

Any data set that you delete from the system is irrevocably lost. All data entry forms, and section forms which may have been developed will also be removed. Make sure that you have made a backup of your database before deleting any data set in case you need to restore it at some point in time.

  1. Open the Maintenance app and find the type of metadata object you want to delete.

  2. In the object list, click the options menu and select Delete .

  3. Click Confirm .

23.7.8 Display details of metadata objects

  1. Open the Maintenance app and find the type of metadata object you want to view.

  2. In the object list, click the options menu and select Show details .

23.7.9 Translate metadata objects

DHIS2 provides functionality for translations of database content, for example data elements, data element groups, indicators, indicator groups or organisation units. You can translate these elements to any number of locales. A locale represents a specific geographical, political, or cultural region.

Tip

To activate a translation, open the System Settings app, click > Appearance and select a language.

  1. Open the Maintenance app and find the type of metadata object you want to translate.

  2. In the object list, click the options menu and select Translate .

    Tip

    If you want to translate an organisation unit level, click directly on the Translate icon next to each list item.

  3. Select a locale.

  4. Type a Name , Short name and Description .

  5. Click Save .