Purpose
This procedure (Automatic schedule task) is designed to expire previously created Medication request Request after lifetime ends in status='NEW'.
Process configuration
Parameter | Description | Value |
---|---|---|
MEDICATION_REQUEST_REQUEST_SCHEDULE | (Cron Format) How often to perform termination | `* * * * *` |
MEDICATION_REQUEST_REQUEST_EXPIRATION | (Minutes, integer > 0) Medication request Request lifetime | 30 |
Procedure logic for transition
- For info - status charts: Medication request Request Status Chart
Read MEDICATION_REQUEST_REQUEST_EXPIRATION parameter value.
Fetch records from `medication_request_requests`, where:
- status = 'NEW'
- inserted_at < NOW() - MEDICATION_REQUEST_REQUEST_EXPIRATION
- Update (Set values) Medication request Request
- status = EXPIRED
- updated_by = SYSTEM_USER
- updated_at = timestamp