Assistance required with program rule expression for multiple org units

Hi all,

I have a tracker program notification that I want to express based on a program rule expressions. The program rule should only come into affect for specific org units and only when a specific event has taken place. I managed to get the expression to work for one org unit (see below).

V{orgunit_code} == ‘XXX_R_CEN’ && #{RTT_Has rabies vaccine been administered} ==‘true’

I would, however, like to apply the expression to multiple org units, but cannot get the rule applied for multiple org units simultaneously. I tried the following to, but had no success:

V{orgunit_code} == ‘XXX_R_CEN’ && #{RTT_Has rabies vaccine been administered} ==‘true’ ||
V{orgunit_code} == ‘ZAN_H_KDH’ && #{RTT_Has rabies vaccine been administered} ==‘true’ ||
V{orgunit_code} == ‘ZAN_H_MAH’ && #{RTT_Has rabies vaccine been administered} ==‘true’ ||
V{orgunit_code} == ‘ZAN_H_MMR’ && #{RTT_Has rabies vaccine been administered} ==‘true’ ||
V{orgunit_code} == ‘ZAN_H_MAK’ && #{RTT_Has rabies vaccine been administered} ==‘true’

Any assistance or guidance would be greatly appreciated.

Kind regards,

Andre

@ACoetzer1988 my first thought (haven’t tested though) would be to include () around each line, prior to the ||. so
(V{orgunit_code} == ‘XXX_R_CEN’ && #{RTT_Has rabies vaccine been administered} ==‘true’) ||
(V{orgunit_code} == ‘ZAN_H_KDH’ && #{RTT_Has rabies vaccine been administered} ==‘true’) ||
(V{orgunit_code} == ‘ZAN_H_MAH’ && #{RTT_Has rabies vaccine been administered} ==‘true’) ||
(V{orgunit_code} == ‘ZAN_H_MMR’ && #{RTT_Has rabies vaccine been administered} ==‘true’) ||
(V{orgunit_code} == ‘ZAN_H_MAK’ && #{RTT_Has rabies vaccine been administered} ==‘true’)
Or break it into org unit code ORs,with a single AND, like below:
(V{orgunit_code} == ‘ZAN_H_MAK’ ||V{orgunit_code} == ‘ZAN_H_MMR’ ||V{orgunit_code} == ‘ZAN_H_MAH’|| V{orgunit_code} == ‘ZAN_H_KDH’||V{orgunit_code} == ‘XXX_R_CEN’)
&&
#{RTT_Has rabies vaccine been administered} ==‘true’

1 Like

Hi @Matthew_Boddie,

Thanks for the help! The second option (below) worked, thanks.

(V{orgunit_code} == ‘ZAN_H_MAK’ ||V{orgunit_code} == ‘ZAN_H_MMR’ ||V{orgunit_code} == ‘ZAN_H_MAH’|| V{orgunit_code} == ‘ZAN_H_KDH’||V{orgunit_code} == ‘XXX_R_CEN’)
&& #{RTT_Has rabies vaccine been administered} ==‘true’

I did learn a hard lesson though. Copying your text created an apostrophe that was not recognised by DHIS2. So I had to replace the copied apostrophe with a newly typed one to get the rule to action.

That being said, lesson learned and expression working - thanks! :smiley:

Andre

1 Like

Hi @Matthew_Boddie,

Follow-up question, if you dont mind.

The expression works, but only triggers the rule for two org units (XXX_R_CEN and ZAN_MAH).

(V{orgunit_code} == ‘ZAN_H_MAK’ ||V{orgunit_code} == ‘ZAN_H_MMR’ ||V{orgunit_code} == ‘ZAN_H_MAH’|| V{orgunit_code} == ‘ZAN_H_KDH’||V{orgunit_code} == ‘XXX_R_CEN’)
&& #{RTT_Has rabies vaccine been administered} ==‘true’

I can move those two org units to any position in the expression and it will still trigger the rule. So that rules out a problem in the expression itself (according to my limited experience).

I have checked that the other three org unit codes are correct and even tried changing one code in both the org unit and expression. I also checked to see that the Org unit code does not perhaps have a space that I missed in the expression. No luck with any of those tries.

Have you ever experienced anything like this?

My mind went to the additional space, and was a little disheartened to see you checked for that. Based on your description it kind of feels like there might still be some odd apostrophes going on?

Sorry that I don’t have a specific answer for you, but I do have a potential workaround:
(d2:left(V{orgunit_code},4) == ‘ZAN_’)
basically for my instance, to get around specific orgUnit Code distinctions, we only take the left most X characters, and use that as our program rule trigger. Perhaps this gets around the issue and creates a more simple expression for you?

1 Like

@ACoetzer1988 this turn out ok for you? Figure out what was going on?

Hi @Matthew_Boddie

Sorry for the delay in letting you know. The simplified expression works much better and triggers the rule as expected, which is great news since it certainly helps keep the expression nice and tidy.

I had initially struggled with the rule not expressing for one of the org units (a newly created health facility in the org tree), but deleting the org unit and re-creating it resolved the problem of it being excluded from the rule.

So everything seems to be working as expected now, thanks!

1 Like