Hide stage doesn't work

Hi community,

I am facing with a problem by firing program rule actions, which suppose to hide stages based on the orgunit group.
The PR condition is simple :
d2:inOrgUnitGroup(‘Country_AZ’) then 6 staged should be hidden, and
another one d2:inOrgUnitGroup(‘Country_GE’) then it should hide 4 stages

But none of them works, although during the verbose mode I can see the PR evaluated true, but actions doesn’t take effect.

In order to check I have created dummy program, with stages. There all rules works perfectly fine.
Any ideas or suggestion what it may cause?

Thank you.
Regards,
Ulanbek

Hi

I would like to double check with you with the naming “hide stage” because the action in later versions of DHIS2 has been renamed to “prevent adding new events to stage.” Therefore, it will not be “hidden” whereas it’ll not be possible to ‘add new events’ to those stages.

However, I am guessing that this is already understood since the actions took the desired effect in the dummy program, so my action is what is the different in configuration between the dummy program and the actual program?

Thanks!

Hi @Gassim

Thank you for your reply. Actually I am using exactly “prevent adding new events to stage” action type, which has no effects on the program. Another interesting part is in the same program if there is only a stage required to hide it works perfectly fine… :frowning:

So I have no idea why the other rules doesn’t work…

Hi @Ulanbek

Thanks for the clarification. So the program rule works as expected if there’s only one program stage to hide but then when there’s more than one program rule that is expected to hide other stages things break?

Thanks!

Exactly @Gassim

Trying to debug and find the source… :thinking::confused:

2 Likes

Hi @Gassim

I have tried to find the source of the problem, but failed.

Moreover I have created the same situation on DHIS 2 Demo - Sierra Leone as the programs in version 40.3 were empty.

What to be achieved:
We have 2 organisations units groups: BADJIA_BAOMA and BB.
Depending on the orgUnit in some group we need to hide some program STAGES, in other word apply “prevent adding new events to stage” action type.

For the BADJIA_BAOMA orgunitgroup we need to hide stages: Diagnosis & treatment and Household investigation
For the BB orgunitgroup we need to hide stages: Case outcome and Diagnosis & treatment

For the first program rule: “Hide stage for BADJIA_BAOMA” it defined the orgUnit belongs to the BADJIA_BAOMA orgUnits Group and the result is below:

As you can see we have not exactly what we want.
Also I noticed the strange behaviour of the HIDEPROGRAMSTAGE action type, which can selectively hide or ignore stages.

Below the metadata to add into play instances (2.39 or 2.40)

{
“programRuleActions”: [
{
“created”: “2024-04-28T06:03:08.605”,
“programRule”: {
“id”: “uuYsMz7T2k6”
},
“programRuleActionType”: “HIDEPROGRAMSTAGE”,
“programStage”: {
“id”: “hYyB7FUS5eR”
},
“id”: “Dup2Mf8Lor3”
},
{
“created”: “2024-04-28T06:03:08.605”,
“programRule”: {
“id”: “ppi2vm1g0T8”
},
“programRuleActionType”: “HIDEPROGRAMSTAGE”,
“programStage”: {
“id”: “hYyB7FUS5eR”
},
“id”: “YwZn7pu992B”
},
{
“created”: “2024-04-28T06:03:08.605”,
“programRule”: {
“id”: “uuYsMz7T2k6”
},
“programRuleActionType”: “HIDEPROGRAMSTAGE”,
“programStage”: {
“id”: “eHvTba5ijAh”
},
“id”: “gseDGALK99B”
},
{
“created”: “2024-04-28T06:03:08.605”,
“programRule”: {
“id”: “ppi2vm1g0T8”
},
“programRuleActionType”: “HIDEPROGRAMSTAGE”,
“programStage”: {
“id”: “C0aLZo75dgJ”
},
“id”: “p6q2FhAL35h”
}
],
“organisationUnitGroups”: [
{
“code”: “BADJIA_BAOMA”,
“name”: “BADJIA_BAOMA”,
“created”: “2024-04-28T06:01:08.151”,

        "sharing": {
            "owner": "xE7jOejl9FI",
            "external": false,
            "users": {},
            "userGroups": {},
            "public": "rw------"
        },
        "id": "IZhMP5GYNcg",
        
        "organisationUnits": [
            {
                "id": "ZpE2POxvl9P"
            },
            {
                "id": "TSyzvBiovKh"
            },
            {
                "id": "g8upMTyEZGZ"
            },
            {
                "id": "MxKoMIVvl8b"
            },
            {
                "id": "nX05QLraDhO"
            },
            {
                "id": "azRICFoILuh"
            },
            {
                "id": "Umh4HKqqFp6"
            },
            {
                "id": "WAjjFMDJKcx"
            },
            {
                "id": "KfUCAQoOIae"
            },
            {
                "id": "pMEnu7BjqMz"
            },
            {
                "id": "RzgSFJ9E46G"
            },
            {
                "id": "bG0PlyD0iP3"
            },
            {
                "id": "jNb63DIHuwU"
            },
            {
                "id": "EuoA3Crpqts"
            },
            {
                "id": "AnXoUM1tfNT"
            },
            {
                "id": "DiszpKrYNg8"
            },
            {
                "id": "egv5Es0QlQP"
            }
        ]
    },
    {
        "code": "BB",
        "name": "Biriwa-Bombali",
        "created": "2024-04-28T06:02:13.029",
       
        "sharing": {
            "owner": "xE7jOejl9FI",
            "external": false,
            "users": {},
            "userGroups": {},
            "public": "rw------"
        },
        "shortName": "BB",
        "id": "Gu7iA32yvnJ",
        
        "organisationUnits": [
            {
                "id": "gP6hn503KUX"
            },
            {
                "id": "nDwbwJZQUYU"
            },
            {
                "id": "OjTS752GbZE"
            },
            {
                "id": "ZxuSbAmsLCn"
            },
            {
                "id": "duGLGssecoD"
            },
            {
                "id": "tEgxbwwrwUd"
            },
            {
                "id": "C1zlHePEQe6"
            },
            {
                "id": "OI0BQUurVFS"
            },
            {
                "id": "dqHvtpUqLwB"
            },
            {
                "id": "GQcsUZf81vP"
            },
            {
                "id": "OuwX8H2CcRO"
            },
            {
                "id": "XzmWizbR343"
            },
            {
                "id": "wzvDhS0TkAF"
            },
            {
                "id": "mepHuAA9l51"
            },
            {
                "id": "aQoqXL4cZaF"
            },
            {
                "id": "mt47bcb0Rcj"
            },
            {
                "id": "wNYYRm2c9EK"
            },
            {
                "id": "PybxeRWVSrI"
            },
            {
                "id": "uNEhNuBUr0i"
            },
            {
                "id": "Dbn6fyCgMBV"
            },
            {
                "id": "Uwcj0mz78BV"
            },
            {
                "id": "LZclRdyVk1t"
            },
            {
                "id": "cgqkFdShPzg"
            },
            {
                "id": "ObV5AR1NECl"
            },
            {
                "id": "E7IDb3nNiW7"
            }
        ]
    }
],
"programRules": [
    {
        "name": "Hide stage for BADJIA_BAOMA",
        "created": "2024-04-28T06:03:08.614",
        "program": {
            "id": "qDkgAbB5Jlk"
        },
        "programRuleActions": [
            {
                "id": "p6q2FhAL35h"
            },
            {
                "id": "YwZn7pu992B"
            }
        ],
        "condition": "d2:inOrgUnitGroup( 'BADJIA_BAOMA' )",
        "id": "ppi2vm1g0T8"
    },
    {
        "name": "Hide stage for Bombali ",
        "created": "2024-04-28T06:03:56.606",
        "program": {
            "id": "qDkgAbB5Jlk"
        },
        "programRuleActions": [
            {
                "id": "gseDGALK99B"
            },
            {
                "id": "Dup2Mf8Lor3"
            }
        ],
        "condition": "d2:inOrgUnitGroup( 'BB' )",
        "id": "uuYsMz7T2k6"
    }
]

}

Could you have a look please?
Thank you

1 Like

Thanks for providing this test case @Ulanbek! It turns out the source of the problem lies in the app, which shouldn’t take much time for me to fix. But in the meantime you can use the following workaround if you like: Redefine the program rules such that only one rule is using HIDEPROGRAMSTAGE on a given program stage. In the example above, this entails replacing the two program rules with three new rules called “Hide Diagnosis & treatment”, “Hide Household investigation”, and “Hide Case outcome”.

1 Like

Hi @superskip

Thank you for your reply. Should I report it as bug or you will do it?

BTW do you think will this bug be fixed in the version 40.4? And if yes when we should expect it?

Regards,
Ulanbek

1 Like

Hi @Ulanbek, I’ve made the bug report now: [DHIS2-17301] - Jira
The next version of 2.40 is scheduled around the end of May/beginning of June. This fix will probably be part of the next release.

1 Like

Thank you @superskip

1 Like

Hi @superskip

I have tried the solution you have provided. It doesn’t work… :frowning: I have the same results - the stages are still there. Recreated PRs few times, but nothing happened.

I believe there may be a connection with the issue [DHIS2-16524] - Jira, please check just in case

Regards,
Ulanbek

Hi @Ulanbek

In case it was unclear, the three new program rules should use the following conditions:

“Hide Diagnosis & treatment”: d2:inOrgUnitGroup('BB') || d2:inOrgunitGroup('BADJIA_BAOMA')
“Hide Household investigation”: d2:inOrgUnitGroup('BADJIA_BAOMA')
“Hide Case outcome”: d2:inOrgUnitGroup('BB')

And as always it is important to clear the cache (or update database version) after updating the program rules. I can’t see why this workaround should not work :thinking: