Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents

...

This method is designed to reject previously created Medication dispense.

Key points

  1. Only authenticated and authorized users of a legal entity who has created

...

  1. Medication dispense can reject Medication dispense.

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

Specification

Page Properties

Link

https://uaehealthapiehealthmisapi1.docs.apiary.io/#reference/public.-reimbursement/medication-dispense/reject-medication-dispense

Посилання на Apiary або Swagger

Resource

/api/medication_dispenses/{{id}}/actions/reject

Посилання на ресурс, наприклад: /api/persons/create

Scope

medication_dispense:reject

Scope для доступу

Components

ePrescription, Reimbursement

Зазначається перелік бізнес компонентів, які використовують цей метод, наприклад: ePrescription

Microservices

API paragraph not found

Перелік мікросервісів, які використовує метод API, наприклад: Auth, ABAC

Protocol type

REST

Тип протоколу, який використовується запитом, наприклад: SOAP | REST

Request type

PATCH

Тип запиту API, наприклад: GET, POST, PATCH…

Sync/Async

Sync

Метод є синхронним чи асинхронним?

Logic

...

  1. Update Medication dispense data in OPS DB:

    1. set status  =  ‘REJECTED’

    2. updated_by = user_id

    3. updated_at = now().

Preconditions

No

Global and configurable parameters

...

Input parameter

Values

Type

Description

Example

id

String

Medication Dispense Response Identifier. Required.

b075f148-7f93-4fc2-b2ec-2d81b19a9b7b

Filters

No

Request structure

...

  1. Verify the validity of access token

    Return 401
    • 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 in case
    • return 403 (“Your scope does not allow to access this resource. Missing allowances: medication_dispense:reject”) in case of invalid scope(s).

Headers

Content-Type:application/jsonAPI paragraph not found

Validate request

API paragraph not found

Request data validation

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:

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

id - dispense.id exists

In case error - return 404 error

Request data validation

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'

...

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 Medication dispense status model.

Parameters that are used when processing the request

...

Access to the method is defined by the scope medication_dispense:reject. Permission for this scope is determined by the System administrator by configuring scopes in the context of clients and roles.

Dictionaries

API paragraph not found

Processing

Change dispense status

Update dispense status to REJECTED

...

Parameter

...

Source

...

Description

...

payment_id

...

Request: $.payment_id or NULL

...

If payment_id exists in request - update record with payment_id

...

status

...

Const: REJECTED

...

See: Status Charts (reimbursement)

...

updated_at

...

Timestamp: now()

...

Get current date-time

...

updated_by

...

Token: user_id

...

API paragraph not found

Processing

API paragraph not found

Response structure

See on Apiary

...

Post-processing processes

No

HTTP status codes

...

404

...

Error

...

dispense.id doesn`t exist

...

409

...

Page Properties

HTTP status code

Message

What caused the error

200

Response

 

401

Invalid access token

 

403

...

Error

...

  • invalid scope;

  • only users of legal entity who has created Medication Dispense and NHS Admin can reject Medication Dispense

Your scope does not allow to access this resource. Missing allowances: medication_dispense:reject

404

Not found

  • Medication dispense exists in DB (OPS) check fails.

  • Medication dispense belongs to legal entity check fails.

  • In case employee didn’t create medication dispense.

409

Can't update medication dispense status from {status} to REJECTED

...

422

...

Error

...

Backward compatibility

API paragraph not found