I need to count the number of events associated with a specific program stage and use program rules to trigger actions based on that count. Specifically, I want to:
Count events related to a program stage.
Trigger actions (e.g., show/hide fields or set values) based on the event count or status.
Is it possible to achieve this with program rules? Any best practices or examples would be appreciated!
While i am looking to avoid using V{event_count} because it counts all events associated with an enrollment
I am not sure whether this is the best solution to achieve it, but we use a data element “Event number” to store the number of events from a specific stage.
We use 2 program rule variable:
“Event Number previous” (which retries the value of the data Element “Event number” from last event in the given stage.
“Event number” which is the value of current DE '“Event number”
We use 2 program rules, to assign the value “1” for the first event (Condition = !d2:hasValue(#{Event Number previous}) && !d2:hasValue(#Event Number)", and another Program rule for the following events, where we assign the value ("Event Number preivous +1) to the data element “Event Number” (condition = d2:hasValue(Event number previous}) && !d2:hasValue(Event number) && (#{Event Number - Event Number previous} <2)