...
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 (according configured parameter PREPERSON_TERMINATIONDEACTIVATION_SCHEDULE).
After starting it gets value from global parameter config DAYS_FOR_PREPERSON_TERMINATIONVERIFICATION.
Select all entries from mpi.prepersonssprepersons with status=active and expires_at is not null verified is false:
if preperson has required set of medical events (TBD) Observation.codes =
height
andweight
andsex
and Observation.status =valid
:set expires_at verified = nulltrue
set updated_at = current_datetime()
set updated_by = system_user()
else if preperson has no required set of medical events:
if expiresinseted_at < current_datetimedate() - DAYS_FOR_PREPERSON_EXPIRATIONVERIFICATION
set status = inactive
set is_active = falseset updated_at = current_datetime()
set updated_by = system_user()
else if expiresinserted_at >= current_datetimedate() - DAYS_FOR_PREPERSON_EXPIRATIONVERIFICATION, then skip the preperson.