Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

...

...

...

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 

Code Block
languagesql
SELECT * FROM medication_request MR
    WHERE MR.status == ACTIVE
        AND RM.ended_at <= 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

  1. Fetch records from `medication_requests`, where:

    1. status = 'ACTIVE'

    2. dispense_valid_to < NOW()

  2. Update status for all records:

    1. status  =  EXPIRED

    2. updated_by = SYSTEM_USER

    3. updated_at = timestamp

  3. Write changes to audit log

  4. Write changes to event manager

  5. if the medication request is based on the activity with quantity:

    1. Recalculate and set remaining_quantity for the activity as described at Create Medication Request: Validate based_on (p. 2.d.1 )