-
Notifications
You must be signed in to change notification settings - Fork 363
feat: Event scheduling using program rule [DHIS2-16911] #19868
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
|
...ava/org/hisp/dhis/programrule/action/validation/ScheduleEventProgramRuleActionValidator.java
Outdated
Show resolved
Hide resolved
...is-service-core/src/main/java/org/hisp/dhis/programrule/DefaultProgramRuleActionService.java
Outdated
Show resolved
Hide resolved
final UID programStage = validationEffect.field(); | ||
|
||
if (!DateUtils.dateIsValid(scheduledAt)) { | ||
return Optional.of(ProgramRuleIssue.warning(programRule, ValidationCode.E1319, scheduledAt)); |
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.
Should we validate this when creating the rule action, like the other validations around program stage?
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're not certain whether the user will provide a plain date, a d2
: function, or a variable (e.g., V{current_date}
).
So validation can only occur after the expression is fully evaluated and transformed into an actual date.
...er/src/main/java/org/hisp/dhis/tracker/imports/programrule/executor/ScheduleEventHelper.java
Outdated
Show resolved
Hide resolved
dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/tracker/imports/RuleEngineTests.java
Outdated
Show resolved
Hide resolved
@@ -54,7 +54,7 @@ public enum ProgramRuleActionType { | |||
WARNINGONCOMPLETE("warningoncomplete"), | |||
SHOWERROR("showerror"), | |||
ERRORONCOMPLETE("erroroncomplete"), | |||
CREATEEVENT("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.
Remind me, what are the consequences for this renaming an existing action type? Will there be instances out there that has the create event action type somewhere in their DB which would start to fail?
I know we never supported it yet. But just thinking, if some values exist in the DB?
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.
Yes, it's possible since we're not restricting the creation of CREATEEVENT via APIs (only UI does not support it). Added CREATEEVENT again
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.
For me now the PR is in good shape but we should have a clear plan on how to avoid duplication of scheduled events.
dhis-2/dhis-api/src/main/java/org/hisp/dhis/programrule/ProgramRuleActionService.java
Outdated
Show resolved
Hide resolved
dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/tracker/imports/RuleEngineTests.java
Outdated
Show resolved
Hide resolved
|
https://dhis2.atlassian.net/browse/DHIS2-16911
This PR implements the initial support for scheduling events (
ProgramRuleActionType.CREATEEVENT
) via program rules, triggered from either an enrollment or event context.It provides the bare minimum functionality required to schedule events based on rule effects.
In the next step, we will handle deduplication logic to avoid scheduling duplicate events when rules are evaluated multiple times.