...
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.prepersons with status=active and deactivation_date is not null verified is false:
if preperson has Observation.codes =
height
andweight
andsex
and Observation.status =valid
:set deactivation_date verified = nulltrue
set updated_at = current_datetime()
set updated_by = system_user()
else if preperson has no required set of medical events:
if deactivationinseted_date at < current_date() - PREPERSON_DEACTIVATION
set status = inactiveset is_active = false
set updated_at = current_datetime()
set updated_by = system_user()
else if deactivationinserted_date at >= current_date() - PREPERSON_DEACTIVATION, then skip the preperson.