I am trying to add a program rule in Capture App, which assigns a value to a data element, and this value is coming from a data element from a previous event. The data elements are not the same, but the value is the same. I have tried both the “Data element from the newest event in the current program” and the “Data element from previous event” variable rules but no data is being assigned.
Would you please share the program rule expression and its description? What’s the condition? It’d be helpful for me to be able to test in play.dhis2.org. Additionally, what’s the expression in the action itself.
@Gassim I am trying this on the test envirnoment. Under the Child Program Event. The idea is to have the captured at Apga AScore to be assigned to Weight on the next event; adding of the next person. The variable name is agpascore_2, the program rule is apgascore_assgin_value.
I have made the source type “Data element from the previous event”
@Tangy I think I understand what the problem is: program rule variables may only use values from the events associated with the selected enrollment (when we’re talking about a tracker program). So when you create a new person the program rule variables will always be based on this person’s events and never the events of the previous person.
I must admit it’s not obvious from names like “Data element from the newest event in the current program” what it means in the context of a tracker program, even when you know it must be confined to the currently selected enrollment. The documentation helps clarify their meaning however, please see Programs - DHIS2 Documentation
Sorry for the late reply, hope this hit the nail on the head..!
@Tangy I did a little bit of testing in an event program, and can confirm that the rule engine is only informed of the selected event, any other events in the program will not be taken into consideration. So the information in the image looks correct to me, and I think you have correctly identified what the causes the problem!