...
Job starts once in 24 hours by default (configured parameter PREPERSON_TERMINATIONDEACTIVATION_SCHEDULE).
After starting it gets value from global parameter PREPERSON_TERMINATIONDEACTIVATION.
Select all entries from mpi.prepersonss with status=active and expiresdeactivation_atdate is not null:
if preperson has required set of medical events (TBD):
set expiresdeactivation_at date = null
set updated_at = current_datetime()
set updated_by = system_user()
else if preperson has no required set of medical events:
if expiresdeactivation_at date < current_datetimedate() - PREPERSON_EXPIRATIONDEACTIVATION
set status = inactive
set is_active = false
set updated_at = current_datetime()
set updated_by = system_user()
else if expiresdeactivation_at date >= current_datetimedate() - PREPERSON_EXPIRATIONDEACTIVATION, then skip the preperson.