If I select “Yes, complete enrollment and events” while there are mandatory fields pending, it will fail, and THEN, if I simply try to “Complete enrollment only” nothing happens, the enrollment is not “completed”.
In the other hand, if I go straight to “complete enrollment only” DHIS2 will complete the enrollment. Is there any way I can reinforce capturing all mandatory fields OR complete events before the enrollment can be completed?
I would like to point out that I tried with a handful of “Error on complete” PR but I have not had any luck.
Thank you for your post. I believe you are using the Capture app, please which version of the Capture app are you using? I would like to reproduce this on play.dhis2.org.
Also, I believe you are using the button straight from the dashboard as the screenshot below?
It appears that the ‘Complete enrollment only’ works seperately from the events, and I am able to reproduce the scenario that you mentioned. I’ll will ask the tracker team about this. Thanks!
When you say “…mandatory fields have been captured”: I presume these are event fields? If so, is it an option to enforce the user to fill in these before saving an event? (i.e., the event can’t be saved at all before the mandatory fields are filled in).
You can enforce this by changing the validationStrategy for a programStage to “ON_UPDATE_AND_INSERT”. Currently, you will have to do this using the API (or modify the DB directly). Let me know if you need any help.
(From version 2.43 the default for validationStrategy will likely be “ON_UPDATE_AND_INSERT” and we will likely add a way to change it from the maintenance app)
If you need to check whether all events have been created, I think this could be possible using program rules if you are not dealing with repeatable program stages (you have the event_count variable that can be utilised). I will have to look more into this to confirm though. see follow up post below.
(And thanks for mentioning the bug when you click “complete enrollments and events” and it fails. Will look into improving/fixing this)
Tested the last part a bit (check whether all events have been created). Using event_count should indeed work if you know the number of events you are expecting. Use a program rule with a condition like: V{event_count} < [expected event count]. Add a program rule action “Error on complete”. For this action, there is a little trick to ensure that the action is only used for the enrollment and not the events: you will have to make sure that you select a program rule variable for “Tracked entity attribute to display error next to” (This is not very intuitive, hopefully we can improve on this at a later point).
Thank you for taking your time to respond. I tried that solution and seems to work, however, the condition “V{event_count} < [expected event count]” seems to break the enrollment section (Does not allow me to create a new event, because it says it cannot be completed?")
The problem is that, I do expect around 3 events, however, one of them open other events, so it can go up to 8 possible events (which is not the case for the majority of enrollments…
If you have other thoughts, that would be much appreciated.