...
...
...
...
Table of Contents |
---|
Purpose
This procedure job is designed to expire previously created Request for Medication request after ended time-life in ACTIVE status.
Procedure logic for transition
...
Get list Medication request
SELECT * FROM requests_for_medication_request RMR
WHERE RMR.status == NEW
AND RMR.expiry_to <= current_date() |
...
Medication requests. All active medication requests where dispense_valid_to in the past must be expired.
Process configuration
Name | Description | Format | Default value |
---|---|---|---|
MEDICATION_REQUEST_AUTOTERMINATION_SCHEDULE | How often to perform this task | Cron Format | `* * * * *` |
Job logic
Fetch records from `medication_requests`, where:
status = 'ACTIVE'
dispense_valid_to < NOW()
Update status for all records:
status = EXPIRED
updated_by = SYSTEM_USER
updated_at = timestamp
Write changes to audit log
Write changes to event manager
if the medication request is based on the activity with quantity:
Recalculate and set remaining_quantity for the activity as described at Create Medication Request: Validate based_on (p. 2.d.1 )