Purpose
Automatically deactivate prepersons to prevent fraud if they doesn’t have appropriate set of medical events.
Job logic
Job starts once in 24 hours by default (configured parameter PREPERSON_SCHEDULE).
After starting it gets value from global parameter PREPERSON_EXPIRATION.
Select all entries from mpi.prepersonss with status=active and expires_at is not null:
if preperson has required set of medical events (TBD):
set expires_at = null
set updated_at = current_datetime()
set updated_by = system_user()
else if preperson has no required set of medical events:
if expires_at < current_datetime() - PREPERSON_EXPIRATION
set status = inactive
set is_active = false
set updated_at = current_datetime()
set updated_by = system_user()
else if expires_at >= current_datetime() - PREPERSON_EXPIRATION, then skip the preperson.