Conditional logic in the participant registration

Hi, i would like to add a conditional show in the registration when i enroll a participant. Can you help, please

Thank you.

As general, You can set conditions based on program attributes by defining problem rules. You can find many examples of program rules on the play.dhis2 instances.

If you need specific example, please explain your use case a little more .
Good luck

1 Like

@LutfullahShifaa thank you, what i want to do is when i select the checklist “Profession” and i click on “Autres(Preciser)” it should display a track entity attribute
image

Okay, follow the below steps to achieve it.

  1. Go to maintenance / Program and Program rule variable
  2. Click on (+) button to create new Program rule variable
  3. Select your program / give it a name (eg. profession_variable)
  4. Select [Source Type = Tracked Entity Attribute] and then select your Tracked entity attribute (Profession)
  5. Save it and go to Program rule
  6. Create a new Program rule / select your program and give it a name
  7. Go to next tab (enter program rule expression)
  8. From Variables, select your variable and set the expression (profession_variable != ‘Autres (Preciser)’ . Make sure you write it correctly.
  9. Go to next tab (define program rule action)
  10. Add new action (hide field) and select the attribute as Tracked entity attribute hide

This is a reverse strategy which will help you to show the attribute.
Good Luck

1 Like

Here are the steps done, i create first the program rule varibales as seen below


Then i create the program rule

Did it work ?

@LutfullahShifaa no he did not work, i do not know what i missed

@Ornella check the expression in the program rule .
Is the value ‘Autres’ or it is ‘Autres (Preciser)’ ?

@LutfullahShifaa it is “Autres”

Did you run browser cache cleaner ?

Hi, @Ornella @LutfullahShifaa

Please uncheck the ‘Use code for option set’ box. This will ensure that the condition will check for the text value ‘Autres’ directly, instead of using the code. This should help the rule work as expected.

Let me know if further clarification is needed!

1 Like

@LutfullahShifaa i uncheck “use code for optiom"till does not work” still does not work

@Ornella

Please make sure to clear the cache after unchecking the ‘Use code for option set’ option. Sometimes the changes don’t take effect immediately due to cached data. You can clear the cache from your browser or from the DHIS2 app settings and try again."

Here are the steps for clearing the cache in DHIS2 Web:

Steps to Clear Cache in DHIS2 Web:

  1. From the dropdown menu, select “Cache cleaner”.
  2. Click on “Clear application cache” and “Clear browser cache”.
  3. Wait for a confirmation message indicating that the cache has been cleared.

Alternatively (via Browser cache clearing):

  1. Open your browser settings (the three dots at the top-right corner in Chrome).
  2. Select “Settings” from the dropdown.
  3. Scroll down and click on “Privacy and Security”.
  4. Click on “Clear browsing data”.
  5. Make sure “Cached images and files” is checked.
  6. Select a time range (choose “All time” to fully clear).
  7. Click “Clear data”.
1 Like

Agree with @LutfullahShifaa—confirm you’ve cleared cache and refreshed your browser?

1 Like

i clear the App and browser cache, here is for the app that i have already cleared

Sometimes restarting the session can help. Try logging out of DHIS2, then logging back in to see if the issue is resolved.

This should help in case the session needs to refresh properly.

unfortunately it does not work, did someone try it and see if it is working?

I made a demonstration on the Play instance with the program called ‘Test - Ornella,’ and it worked as expected. Here are the screenshots to show the process.

image

image

1 Like

@Ornella
Is your problem resolved or still persisting?

1 Like

It works now, i saw the problem in mine i put “#” when i remove it and replace by “A” it works.

3 Likes