Assign a value from a different event in Capture App

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.

Please assist

1 Like

Hi @Tangy

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.

Thanks!

Hi @Gassim
Program rule variable

Expression

Action

1 Like

Hi! The condition checks if #{LG3333} has a value, but the correct variable name seems to be #{3333}.

1 Like

@superskip those a just values names I added, not he actual value names. THe value names are correct in the system.

@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”

Did anyone check this out? I still need assistance.

@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..!

1 Like

Thank you @superskip

I just came across something. Since I am not using tracker, I am using capture for events. Is the below correct:

1 Like

@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! :100:

1 Like