How to use program rule to hide stage using Tracked entity attribute value

Hello there, I am using dhis2 version 2.38.3.1. I was trying to hide a program stage based on value entered on tracked entity attribute. I added a program rule with the action of hiding a stage with a program rule expression of A{sex } != ‘G2’- meaning if the selected sex isn’t with the option code G1, hide the selected stage. how can I solve this?

Hi @blen , in response to your inquiry, you can use a program rule for this.
Start by creating a program rule variable, and choose “tracked entity attribute” as the source type.
Next, for your program rule, the program rule expression would be A{program_rule_variable} == ‘Female’, then in the program rule actions, select “Hide program stage”, and select the program stage to hide if the gender = female.

I have created a sample program on DHIS 2 Demo - Sierra Leone, version 2.38.4.3 called “DHIS2 Community - Test”. You can check it out


I hope our response is able to solve the issue you were facing. With :heavy_heart_exclamation: from the Dhistance Team.

DHISTANCE.com: The Easiest DHIS2 Setup. Up and running in 5 minutes! No technical knowledge needed!

Great Support with Data Security/Confidentiality.

Hi @e4eDHIS2 @Gassim

I noticed that the option to hide a program stage has been removed from the list of program rule actions. Is there a specific reason for its removal, or are there alternative methods to hide a program stage based on the value selected from a tracked entity attribute?

Looking forward to your response.

Best regards,
AJ

1 Like

@akashjindal

The action was previously called “Hide program stage” but has been renamed to “Prevent adding new events to stage” in newer versions of DHIS2. This change was made to prevent confusion among users, as mentioned here.

1 Like

Hi @Quoda and @Gassim

Thank you for your response. We have already explored the option you suggested, but it does not meet our needs. Specifically, it does not hide the stage when we create the program rule. The terminology used, “Prevent adding new events to stage,” also leads to some confusion; it implies that the rule would prevent the addition of an event to a stage rather than hiding the stage itself. If there is an example of this rule being applied in any of the programs on the play instances, could you point us to it? Such a reference would be extremely helpful.

Many thanks in advance.

Akash

Hi @akashjindal ,

An example of this rule is Hide Postpartum visit in the RMNCH program on Play.

If the pregnancy outcome in “Care at Birth” stage is not Live Birth, then you cannot add a new event to the Postpartum care visit stage.

The behavior is slightly different for two scenarios:

  1. There is an existing event for the program stage in the enrollment: the stage sub-heading is still shown, the event is still shown, and its data values are visible, but you cannot add a new event, as the [:plus: New Pospartum event] button is greyed out and locked.
  2. There is no previous event for the program stage in the enrollment. Then the entire sub-heading and context window for the postpartum stage is not visible on the enrollment dashboard.
1 Like