-
Notifications
You must be signed in to change notification settings - Fork 363
feat: Prevent duplicate event creation from SCHEDULEEVENT rule action [DHIS2-19849] #21433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to review the logic:
If the program stage is non-repeatable, the system will skip scheduling a new event if an existing one is already present for the same enrollment.
If the program stage is repeatable, the scheduling logic will proceed and allow the new event to be created.
I don't think this is enough to prevent duplicates. If the program stage is repeatable then every time there is a small change to the event (like change the value of a data value, update the status), a new event is scheduled. We need to prevent this kind of creation. The scheduled event should be created only once, no matter the type of the program stage
@@ -106,8 +107,8 @@ public Map<ProgramRuleActionType, ProgramRuleActionValidator> programRuleActionV | |||
ProgramRuleActionType.HIDEFIELD, | |||
getProgramRuleActionValidatorByClass(BaseProgramRuleActionValidator.class)) | |||
.put( | |||
ProgramRuleActionType.CREATEEVENT, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to keep the base validator for CREATEEVENT?
@@ -81,9 +81,10 @@ public void preheatAdd(TrackerObjects trackerObjects, TrackerPreheat preheat) { | |||
|
|||
List<String> notRepeatableProgramStageUids = | |||
trackerObjects.getEvents().stream() | |||
.map(Event::getProgramStage) | |||
.map(Event::getProgram) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need to change this code?
We are potentially introducing a lot of unnecessary data into the Preheat.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this change here? Do you need to rebase?
Just a thought, would be a good first version if we only allow one scheduled event to exist even if it is a repeatable program stage? So if there already is a scheduled event for that program stage, then no new scheduled event is created. @enricocolasante @zubaira thoughts? |
@ameenhere that's what we agreed upon. |
|
DO NOT MERGE. This PR should be merged after this one. #19868.
https://dhis2.atlassian.net/browse/DHIS2-19849
This PR continues the work from #19868. It introduces a validation step in the rule-engine–based scheduling logic to avoid creating duplicate events.
If the program stage is non-repeatable, the system will skip scheduling a new event if an existing one is already present for the same enrollment.
If the program stage is repeatable, the scheduling logic will proceed and allow the new event to be created.