Program rule to show two options if the number is more than 34 and to hide if the number is less than 34

I have made a DHIS 2 form to collect information regarding maternal and child health and need support to formulate a program rule for the following.

In the form, there is a section to enter the period of amenorrhea (POA), if the POA is less than 34 I want the following options to show namely

  1. Corticosteroids been administered during pregnancy?
  2. Magnesium sulphate been administered during pregnancy?

if the POA is more than 34 weeks I want the above two options to hide.

Please kindly demonstrate a possible program rule

1 Like

Hi

  1. Create a program rule variable of source type β€˜Data element in current event’ and the data element should be the POA
  1. Create a program rule that will hide the fields when POA is > than 34
    Expression: POA > 34
    Program rule actions: hide field 1, hide field 2

The two fields will appear by default but once the value for POA is entered it will determine if the options remain visible or hidden. Hope this helps! :+1:

1 Like

Hi Gassim,

The program rule worked but when I keep the field blank the two options show but when I enter a value more than 34 weeks the two options hide.

When the value is empty

When the value is less than 34

when the value is 34 and more

is there a way for those two options to be hidden when the fields are blank

1 Like

Could you please try to create an additional program rule:

Expression: POA == β€˜β€™
Program rule actions:

  • action 1: hide field 1
  • action 2: hide field 2

So for your use case you will need two program rules the one above and this one:

Hope this solves it! Please mark post as solved if it does. Thank you! :slight_smile::+1:

2 Likes

Dear Gassim,

Your expression helped me to solve the issue the expression is {#POA} == β€˜β€™

1 Like