Please correct me if I am wrong, but my understanding is that the Period Type setting in a Program Stage should limit the number of events a user can create within a specific timeframe (e.g., one event per day for the same Event Date).
However, I believe I have found a bug, which is reproducible on PlayDHIS (v2.42.4). Despite the restrictions, the system still allows multiple events on the same day.
Steps to reproduce:
In the Maintenance app, set a Program Stage to Repeatable and select Daily as the Period Type.
Clear the browser cache.
Open the Capture app and select the specific Program.
Attempt to add multiple events with the same Event Date for a single enrollment.
Actual behavior: The user is still able to create and save multiple events within the same day without any validation errors.
This feature is a little bit in limbo at the moment - it was implemented (although not perfectly) in Tracker Capture and was even considered for removal (Does anyone use period types for a tracker program?)
Therefore, it has not been prioritized to be implemented in Capture yet (Jira) - but that is why CoP posts like these are great to see that there is a need for it in implementation.
Could you explain your usecase for us? That would also be very helpful.
I’ve added a link to this CoP post in the Jira with the feature request that Karoline posted.
If you have a minute, please… adding more info about the use case and how important the feature is would definitely contribute to giving the feature a little push. Additionally, explaining your use case would help the developers consider it before the software development part.
(BTW, I’m not sure how I missed your post, but luckily Karoline got to it. Thanks @Karoline! )
Which will check the date of the previous event, if it is the same as the current date (same day) then it should show an error, and if the date of the previous event is the same as the event_date that the event is being entered for (an event happened a week ago and then I decide to go back and create an new event on the same day of that day), it should also show error.
I’m hoping that this will work, if you think it will satisfy your use-case, would you please test it and validate?
Thank you!
update:
@m.siusko , I see you’ve marked the post as solved? Would you please explain what worked? Thank you!
This is good to know. Could you clarify a bit more? I don’t understand what you mean by “within one tracked entity instance”? What’s unique about that TEIs that is different from the other TEIs that are in the same program?
If you could explain the real world scenario please, it will help a lot. Thanks!
Sorry, I didn’t imagine d2:lastEventDate will apply globally!!
I would like to suggest a workaround:
Let’s create a data element “Last Event Date” that will be automatically filled with a program rule. Create a program rule with the action to fill the data element with the event_date each time the event is saved.
We will use the same strategy as above but instead of the d2:lastEventDate, we will use our new data element:
a. Create a program rule variable lastEntryDateVar for the data element “Last Entry Date” with source type “Data element from previous event”.
b. Create a program rule with a show error action so that it stops from saving a new event with the condition: d2:hasValue('lastEntryDateVar') && (#{lastEntryDateVar} == V{current_date} || #{lastEntryDateVar} == V{event_date})
Do you think this workaround would work? Please let me know if you get the time to test it.
Action: Show warning “One visit per day!” on “Last Event Date”.
The value is being assigned to the DE “Last Event Date”, but the show error action is not triggering. Also, it is always assigning the current date…
P.S. The only way I solved this issue was by using two DEs:
“Current Event Date”
PRV Source: DE in current event
DE: “Current Event Date”
PR: Auto-assign event date
“Previous Event Date”
PRV Source: DE from previous event
DE: “Current Event Date”
PR: Auto-assign event date
The logic is as follows:
During the first event creation, the DE “Current Event Date” is automatically filled with the event date.
When you try to create another event:
The DE “Current Event Date” is automatically filled with the event date.
The DE “Previous Event Date” takes the value from the DE “Current Event Date” of the previous event.
Finally, a PR with a condition something like this: V{program_stage_id} == 'zGxUC78i0pe' && d2:hasValue(#{Previous_Event_date}) && #{Current_Event_date_B} == #{Previous_Event_date}
shows an error.