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

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

« Previous Version 3 Next »

Purpose

This method is designed to reject previously created Medication Dispense

Status Charts (reimbursement)

Specification

Apiary

WS logic

Authorize user

  1. Verify the validity of access token
    1. Return 401 in case validation fails
  2. Check user scopes in order to perform this action (scope = 'medication_dispense:reject')
    1. Return 403 in case invalid scope(s)

Validate request

Get legal entity from token

  1. Extract legal_entity_id (client_id) from token

Validate FK

1. Validate legal_entity_id - legal_entity_id exists

In case error - return 422 error:

{:error, [{%{
        description: "Legal entity not found",
        params: [],
        rule: :invalid
      }, "$.legal_entity_id"}]}

2. Validate id - dispense.id exists

In case error - return 404 error

Validate context

  1. Only users of legal entity who has created Medication Dispense and NHS Admin can reject Medication Dispense
    1. medication_dispense.legal_entity_id = client_id (context) or client_id (context) (type) in TOKENS_TYPE_ADMIN

In case error - return 403 error (type: forbidden)

Validate status (transition)

  1. Dispense should be active in order to process it
    1. is_active = true
    2. status = 'NEW'

In case error - return 409 error (type: 'invalid_transition', message: 'Can't update medication dispense status from {status} to REJECTED')

Change dispense status

Update dispense status to REJECTED

Parameter

Source

Description

payment_idRequest: $.payment_id or NULLIf payment_id exists in request - update record with payment_id
statusConst: REJECTED

See: Status Charts (reimbursement)

updated_atTimestamp: now()Get current date-time
updated_byToken: user_idExtract user from token
  • No labels