-
Notifications
You must be signed in to change notification settings - Fork 354
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
chore: Validate completedAt for Event and Enrollment [DHIS2-18222] #18881
Conversation
71941b5
to
255a89d
Compare
Completed events/enrollments can transition to other states again right? Does this logic you describe then apply in the same way if an event was previously completed? |
Yes, I updated the description to state that the completed fields are updated only if there is a transition. |
...st/java/org/hisp/dhis/tracker/imports/validation/validator/enrollment/DateValidatorTest.java
Show resolved
Hide resolved
...c/main/java/org/hisp/dhis/tracker/imports/validation/validator/enrollment/DateValidator.java
Outdated
Show resolved
Hide resolved
...er/src/main/java/org/hisp/dhis/tracker/imports/validation/validator/event/DateValidator.java
Outdated
Show resolved
Hide resolved
...c/main/java/org/hisp/dhis/tracker/imports/validation/validator/enrollment/DateValidator.java
Outdated
Show resolved
Hide resolved
Quality Gate passedIssues Measures |
This PR fixes the logic around completion of enrollments and events.
Enrollments
A saved enrollment follows these rules:
COMPLETED
, fieldscompletedAt
andcompletedBy
must be populatedCANCELLED
, fieldscompletedAt
must be populated andcompletedBy
must be nullACTIVE
, fieldscompletedAt
andcompletedBy
must be nullEvents
A saved event follows these rules:
COMPLETED
, fieldscompletedAt
andcompletedBy
must be populatedCOMPLETED
, fieldscompletedAt
andcompletedBy
must be nullFields logic
completedBy
is always calculated by the system, if required by the status, and it will be set to current user.completedAt
is set by the client or calculated by the system if not present, only when the status required it. The use case for it is Android sync where an event/enrollment is completed on day X and the sync happens on day Y, we still wantcompletedAt
to be X.completedBy
andcompletedAt
are set only if the status is changing. Otherwise, the value for those fields present in the DB will not be updated.If the status do not require
completedAt
field to be set but the client set it, a validation error is returned.