Versions Compared

Key

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

...

...

...

...

...

...

...

...

...

...

...

...

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

Parameter

Name

Description

Format

Value

Default value

MEDICATION_REQUEST_REQUEST_SCHEDULE

(Cron Format)

How often to perform

termination

this task

Cron Format

`* * * * *`

MEDICATION_REQUEST_REQUEST_EXPIRATION

(Minutes, integer > 0)

Medication request

Request

request lifetime period

Minutes

30

...

Job logic

...

  1. Read MEDICATION_REQUEST_REQUEST_

...

  1. EXPIRATION parameter value

...

  1. Fetch records from `medication_request_requests`, where:

    1. status = 'NEW'

    2. inserted_at < NOW() -

...

    1.  MEDICATION_REQUEST_REQUEST_EXPIRATION

  1. Update

...

  1. status for all records:

    1. status  =  EXPIRED

    2. updated_by =

...

    1.  SYSTEM_USER

    2. updated_at = timestamp

  1. if the medication request 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 )and do not include current MRR in the calculation in case when calculation was before MRR changed status