Program rule not working

Hi @Calle_Hedberg,

image
As shown in the diagram, I have 2 data elements: 1 in program stage A and another in program stage B.

I am struggling to a program rule working.

USE CASE: If If DEs patient référé à l’hopital-A or patient référé à l’hopital-B have no value or the answer is No in both data elements then Hide program stage C.

This is the program rule I have built to hide program stage C, but it is not working.

Program rule expression

!d2:hasValue(#{patient référé à l’hopital-A}) || #{patient référé à l’hopital-A} == false || !d2:hasValue(#{patient référé à l’hopital-B) || #{patient référé à l’hopital-B} == false

Program action: Hide program stage

Program stage to hide: C

Am I missing something, or the problem is with logical operators?

Thanks

!d2:hasValue(#{patient référé à l’hopital-A}) || #{patient référé à l’hopital-A} == false || !d2:hasValue(#{patient référé à l’hopital-B) || #{patient référé à l’hopital-B} == false

try replacing ! infront of the expression d2.hasValue();

Hi @Roshan.Konda ,

Which word should I use to replace !?

Thanks

This would read: (if there is no value for hospital A, or no hospital A is false or there is no value for hospital B or hospital B is false, then trigger the action (which would be to Hide C). This means that if any of the 4 pieces here are true, then the action would be true, which I don’t think you want.

Pulling your original request:
If DEs patient référé à l’hopital-A or patient référé à l’hopital-B have no value or the answer is No in both data elements then Hide program stage C.
I think what you are trying to say is that if EITHER A or B have no value, or if A and B are false, then trigger the action (Hide C)

I think this would look like the following:

!d2:hasValue(#{patient référé à l’hopital-A}) || !d2:hasValue(#{patient référé à l’hopital-B)
|| 
(#{patient référé à l’hopital-A} == false && #{patient référé à l’hopital-B} == false)

The top half is satisfied if either A or B are empty, the bottom half is satisfied if both A and B are false. The middle || allows for the expression to be true if either of these pieces are met

1 Like

@ferdinandmussavene does the above help out? Let me know if I’m misinterpreting your need, or if this doesn’t work as you expect.

Hi @Matthew_Boddie,

Sorry. I had internet problems since yesterday afternoon.

Neither the top half nor the bottom half is working. For the bottom half it’s I who had not been clear: what I want is if either A or B are false (A and B are in two different stages as shown in the diagram) hide C program stage…

On demo, I registered a person, but when I select B program stage, C is also shown but it should hidden until the condition is satisfied.( if #{patient refere a lhopital-B is empty or #{patient refere a lhopital-B==false) - this DE is in B program stage

NB: The same should be applied when I select A program stage. if #{patient refere a lhopital-A is empty or #{patient refere a lhopital-A==false) - this DE is in A program stage


A, B and C are are configured as no auto-generate program stages.

Thanks for your patience