...
Job starts once in 24 hours by default (configured parameter PREPERSON_DEACTIVATION_SCHEDULE).
After starting it gets value from global parameter PREPERSON_DEACTIVATION.
Select all entries from mpi.prepersonssprepersons with status=active and deactivation_date is not null:
if preperson has required set of medical events (TBD)Observation.codes =
height
andweight
andgender
and Observation.status =valid
:set deactivation_date = null
set updated_at = current_datetime()
set updated_by = system_user()
else if preperson has no required set of medical events:
if deactivation_date < current_date() - PREPERSON_DEACTIVATION
set status = inactive
set is_active = false
set updated_at = current_datetime()
set updated_by = system_user()
else if deactivation_date >= current_date() - PREPERSON_DEACTIVATION, then skip the preperson.