ЕСОЗ - публічна документація

RC_Rx_Reject Medication Dispense by Pharmacy User

Purpose

This method is designed to reject previously created Medication dispense

Key points

  1. Only authenticated and authorized users of legal entity who has created Medication dispense can reject Medication dispense

  2. Medication dispense can be rejected only from ‘NEW' status.

Specification

Apiary

Authorization

  1. Verify the validity of access token

    • in case of error - return 401 (“Invalid access token”) in case of validation fails

  2. Verify that token is not expired

    • in case of error - return 401 (“Invalid access token”)

  3. Check user scopes in order to perform this action (scope = 'medication_dispense:reject')

    • return 403 (“Your scope does not allow to access this resource. Missing allowances: medication_dispense:reject”) in case of invalid scope(s)

Validations

Validate Medication dispense

  • Get Medication dispense identifier from the URL

    • Check Medication dispense exists in DB (OPS)

      • Return 404 ('not_found') in case of error

    • Check Medication dispense belongs to legal entity

      • Return 404 ('not_found') in case of error

Validate User

  • Extract user_id from token

    • Return 404 ('not_found') in case employee didn’t create medication dispense

Validate transition

  • Get status of Medication dispense by $.id in OPS DB. Check that Medication dispense is in status ‘NEW’

    • in case of error - return 409 ("Can't update medication dispense status from {status} to REJECTED")

For more information look at RC_Rx_Medication dispense status modelarchived

Service logic

  1. Update Medication dispense data in OPS DB:

    1. set status  =  ‘REJECTED’

    2. updated_by = user_id

    3. updated_at = now()

ЕСОЗ - публічна документація