Assign the organization unit level value into program rule expressoin

Hi All DHIS2 members
I want to assign the organization unit level value to program rule expressoin (1,2,3, or 4) into program rule expression

The scenario is that when the user presses on the tree and selects one item of the organization unit level (for example, level 3), I want to assign the value of the organization unit level to a variable so that it can be used in a program rule expression.

I would be glad to help me and thanks in advance.

Hi Sami

It’d be great if you could explain more about the use case and why this functionality is helpful.

There is a built-in variable V{orgunit_code} you’d need to configure the orgnization unit codes to indicate which level it is in, and then use this V{orgunit_code} variable in the program rule expression.

Hope this helps!

Thank You @Gassim , but where I can find or configure the orgization unit code

Hi @sami.oracle10g!

You can check it out in the configuration of the OU metadata object from the Maintenance app → Organization Unit → select the OU settings, see screenshot below:

Thanks!

Thank you, however my system has been launched, and I am unable to make significant changes to it. Do you have any other suggestions, please?

1 Like

Other than using the org_unit code, I’m not sure! Maybe someone from the community has an idea, but AFAIK there is no direct way to get the orgnaization unit level value in the program rule expression.

G’day,
Other than using V{orgunit_code} or d2:inOrgUnitGroup I can find no other way to do this currently…
Can recommend to raise a JIRA ticket for the core team to review the potential on adding this function to the system e.g. having variables V{orgunit_level} or d2:inOrgUnitlevel available to use.
Good idea to have imho!

2 Likes

I did

1 Like

I think @dmnscar option is the best in case you could create Organization Unit Groups. You could put all level 1 in a group like OU_level_1, and so on. Then just checking the belongship to that group in a ProgramRule and assining the specific value.

1 Like