Hiding and locking stages

Hi everyone,

I am wondering if anyone could tell me if it is possible to hide, from the user, a program stage that already contains data? Deciding for example that a stage be locked or hidden from the user after being filled three times.


1 Like

Hi @dmbantu,
Thanks for asking! Please feel free to share your experience and why you are facing this situation? If it’s not possible, you can always request a feature on jira.dhis2.org . It’s also recommended to discuss this with the community too beyond the technical support for other options or standard solutions. :+1:

@Markus mind seeing this question. Thanks! :grin::pray:

Hi @Gassim,

Here are the scenarios in the form of diagrams and description.


I have two repeatable stages (A e B). If a certain condition is met in program stage A, program stage B is opened. A program rule has been created for this.

Problems have arisen for the following use case.

I would like to hide or lock a program stage A after it has been filled several times (the number of events the user must fill is known in advance – three, …. 10 times for example). Unless we lock or hide the stage if the number of events is reached, the user will continue entering data indefinitely. So, we must hide or lock stage A to block future data entry, but the user may continue entering data for stage B.

NB: Program stage B will also be locked if certain conditions are met.

I’d appreciate it if @Markus - as you have tagged him- can guide me on this.

Hi there @dmbantu !
Interesting use case!

The “Hide program stage” program rule will not hide data already entered, but it will prevent the users from adding more events in that stage. Is it an option to make a program rule that will have a “Hide program stage” action that hides program stage A, when the conditions for Locking program stage A is met?
This will prevent the user from adding more events to the stage that is “Hidden” but other stages can be added normally.
“Hide program stage” might not be the best name for this program rule action, it could perhaps be named “Hide the option of adding more events in program stage” (but that is a long name :slight_smile: )

P.S. You could make a separate condidition for Hiding (the option of adding events in) program stage B separately, if you want to “lock” program stage B based on a separate condition.


1 Like

Hi @Markus,

As it is not possible to hide a program stage that already has data, What can I do to prevent the user from entering events?

Maybe the description in the previous was not clear enough. Below is the main use case.

The user will fill program stage A several times and I want to say if the number of events reaches 10, no user can be allowed to enter more events. For example, after 10th event, if the user tries to click the add button, we must issue a message telling them that you have reached the limit. I am afraid that without this restriction, they will go beyond the limited number of events…

Program stage A does not depend on any other stage. It’s program stage B that depends on the program stage A.

Thanks and hoping to get more feedback.

Hi @dmbantu - what you describe sounds like it would be covered by the “Hide program stage” program rules, if I do not misunderstand you. If program stage A has 10 events, and you trigger a program rule to hide program stage A, the previously added events will be visible, but the buttons for adding another event will be hidden. Preventing anyone from adding an event number 11. Was this what you already tried?

Hi @Markus,

What I want is exactly what you have just said.

I have tried this:

I created a program rule expression: V((programe_stage_name)== ‘Program stage A’ && V(event_count) == 10 and program rule action Hide program stage A., but after event 10, the add button is still shown.


1 Like

Ok thanks.
The V{event_count} would not be what you want here, as it contains the number of events across all program stages.

Do you have a data element in the program stage A that would always be filled in? If you do you can try this expression:
d2:count(#{dataElementAlwaysFilledIn}) >= 10

The #{dataElementAlwaysFilledIn} should be a program rule variable of type “Dataelement in latest event in program stage”.

Then it might work the way you want I think!


1 Like

Hi @Markus ,

Yes, there is a data element that would always be fiiled in. I followed your instructions and below is the result I got on demo:

After having filled the program stage A 10 times and clicking on add button, program stage B is shown. until now everything is ok because program stage A is not there.

But when I select date and fill data for program stage B and click on the add button to enter more data for this stage, Program stage A is shown

This time, if click on program stage A, it allows to add more events to this stage.

I hoped to see only Program stage B as soon as the condition d2:count(#{dataElementAlwaysFilledIn}) >= 10 in program stage A was met.


Can I see your program rule? Screenshot of all the three steps?

Hi @ Marcus,

Here are the screen shots

Thanks again.

Hi @Markus,

Hi, Is there any more feedback on my post above?

Thank you

Hi @dmbantu
I see that your expression in the rule specifies that

V{program_stage_id} == ‘Jc…’

I believe that you should simply remove this part of your expression and this will work as you expect. You want this rule to run and have effect no matter which program stage you have selected, so therefore the expression part that check the program stage id should simply be removed. When its there, the rule will only be true(and the stage hidden) when the user is working in the stage specified.

I think this would fix it!


My first stage is repeatable as we need get multiple data from patients and the second one is non-repeatable but the context is once the user gets into second stage , we need to lock the first stage. I mean only after all the of the collection of data from stage 1 is completed the stage 2 should be filled but once after stage 2 is started patient should not be able to enter data in stage 1. Is it possible to do it?

in less, I need to hide program stage 1 from option and lock form fill up of program stage 1 when stage 2 is started?

will this work—> V((programStage)== ‘प्रशुती सम्बन्धी विवरण’