How to automate patient tracking

Hi there @fernando

I understand you would like to use a program rule to display a warning or block user input if a maximum number of events has been reached.

I was not able to find precisely what you are looking for: calculate within a program rule the total number of events for a particular program stage in the enrollment.

However, it is possible to calculate the total number of values for a particular data element across the enrollment, and show that as a warning. I would recommend you calculate this for one of the required data elements in your program stage (or any auto-assigned value within the stage).

Example: on Play 2.36.3, the RMNCH program. A warning box is under the first data element in the stage showing the total number of values for “diastolic blood pressure” in the enrollment.

Set the program rule condition to “true” and the program rule expression uses d2:count function

You could use similar method to show an error if d2:count({required_data_element_id}) exceeds maximum allowed stages.

Note you could also substitute the d2:count(<required_data_element_id>) for V{event_count}. This would calculate the total number of events in the enrollment across all stages – even those without a value for the “required” data element.