...
...
...
...
...
...
...
...
...
...
...
...
Table of Contents |
---|
...
...
Purpose
This procedure (Automatic automatic schedule task) is designed to expire previously created Medication request Request request after lifetime ends in lifetime ends in status='NEW'.
Process configuration
...
Name | Description | Format |
---|
...
Default value |
---|
MEDICATION_REQUEST_REQUEST_SCHEDULE |
...
How often to perform |
...
Get list of Medication request Requests
Code Block | ||
---|---|---|
| ||
SELECT * FROM medication_request_requests RMR
WHERE RMR.status == NEW
AND RMR.expired_at <= current_date() |
...
this task | Cron Format | `* * * * *` |
Procedure logic for transition
...
MEDICATION_REQUEST_REQUEST_EXPIRATION | Medication request request lifetime period | Minutes | 30 |
Job logic
Read MEDICATION_REQUEST_REQUEST_EXPIRATION parameter value
Fetch records from `medication_request_requests`, where:
status = 'NEW'
inserted_at < NOW() - MEDICATION_REQUEST_REQUEST_EXPIRATION
Update status for all records:
status = EXPIRED
updated_by =
...
SYSTEM_USER
updated_at = timestamp
if the medication request 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 )and do not include current MRR in the calculation in case when calculation was before MRR changed status