Any possibility to limit a repeatable program stage?

Hi @ferdinandmussavene ! Sorry for keeping you on hold.

I recommend you to try with a fairly simple solution and see whether it works for you:

Scenario 1:
1.
Create a program rule that will trigger only for the applicable Program Stage (If you only have one in the program, it does not matter).

  1. Create an expression that will look like this:
    V{program_stage_id} == ‘program Stage uid’ && V{event_count} >= 7
    This will make sure that you only count events in that particular program stage.

  2. In the program rule actions, select:
    a) Hide Program Stage (Select applicable program stage)
    b) Show Error or Error on Complete (Fill in the field for static text: eg. Number of visits is limited to 7).

Expected behaviour:
When the user creates event Nr. 8, they will be able to fill in data, but when they click complete, they will get an error with a message. It will not be possible to create new events anymore.

You can also add other program rule actions like:
Hide sections (if your data entry form uses sections) or
Hide data elements.
This way you will ensure that the form nr 8 will show without any fields and the user will not have a chance to fill in the form before receiving an error.

Scenario 2:

Similar program rule with several “OR” options.

V{program_stage_id} == ‘program Stage uid’ && V{event_count} = 3 ||

d2:hasValue(#{program rule variable for the data element in current event: FOUND_PATIENT}) && == #{program rule variable for the data element in current event: FOUND_PATIENT} == 0 ||

d2:hasValue(#{program rule variable for the data element in current event: REASONS}) && == #{program rule variable for the data element in current event: REASONS} == ‘code for option: DEATH’ ||

d2:hasValue(#{program rule variable for the data element in current event: PATIENT WITHIN AREA}) && == #{program rule variable for the data element in current event: PATIENT WITHIN AREA} == 0

Then as a Program Rule Action, you could have Show Warning.
You can also split this rule into 3 different rules with different notifications.

Hope that this can be a starting point for you.

Feel free to provide feedback and questions.

Best regards,

Yury