Table of Contents |
---|
Purpose
This method is designed to reject previously created Medication Dispense.
Specification
...
Project Name
...
Електронний рецепт
...
COVID-certificate
...
Project abreviation
...
ePrescription
...
SVC
...
Developer
...
API paragraph not found
...
Розробник методу API. Наприклад, Edenlab
...
Project Manager
...
API paragraph not found
...
@Єлизавета Гессен-Дармштадська
...
Tech Lead
...
API paragraph not found
...
@Іоанн Воїнов
...
Product Owner
...
API paragraph not found
...
@Нікодім Святогорцев
...
Вusiness analyst
...
API paragraph not found
...
@Пантелеймон Нікомедійський
...
Status
Status | ||||
---|---|---|---|---|
|
Status | ||||
---|---|---|---|---|
|
...
Version
...
API paragraph not found
...
1.0
...
Date of release
...
API paragraph not found
...
...
Link
...
...
Посилання на 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
...
Тип HTTP методу, який використовується запитом, наприклад: POST | GET…
...
Sync/Async
...
Sync
...
Метод є синхронним чи асинхронним?
Logic
Preconditions
No
Global and configurable parameters
No
Input parameters
...
Input parameter
...
Values
...
Type
...
Description
...
Example
...
id
...
String
...
Required
Filters
No
Request structure
API paragraph not found
Authorize
Verify the validity of access token
Return 401 in case validation fails
Check user scopes in order to perform this action (scope = 'medication_dispense:reject')
Return 403 in case invalid scope(s)
Headers
Content-Type:application/json
Validate request
Get legal entity from token
Extract legal_entity_id (client_id) from token
Validate FK
Validate
legal_entity_id - legal_entity_id exists
In case error - return 422 error:
Code Block | ||
---|---|---|
| ||
{:error, [{%{
description: "Legal entity not found",
params: [],
rule: :invalid
}, "$.legal_entity_id"}]} |
Validate
id - dispense.id exists
In case error - return 404 error
Request data validation
Validate context
Only users of legal entity who has created Medication Dispense and NHS Admin can reject Medication Dispense
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)
Dispense should be active in order to process it
is_active = true
status = 'NEW'
In case error - return 409 error (type: 'invalid_transition', message: 'Can't update medication dispense status from {status} to REJECTED')
Parameters that are used when processing the request
Configuration parameters
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
...
Extract user from token
Response structure
See on Apiary
Table of Contents |
---|
Purpose
This method is designed to reject previously created Medication dispense
Key points
Only authenticated and authorized users of a legal entity who has created Medication dispense can reject Medication dispense.
Medication dispense can be rejected only from ‘NEW' status.
Specification
Page Properties | |||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Logic
Update Medication dispense data in OPS DB:
set status = ‘REJECTED’
updated_by = user_id
updated_at = now().
Preconditions
No
Global and configurable parameters
No
Input parameters
Input parameter | Values | Type | Description | Example |
---|---|---|---|---|
id | String | Medication Dispense Response Identifier. Required. | b075f148-7f93-4fc2-b2ec-2d81b19a9b7b |
Filters
No
Request structure
API paragraph not found
Authorize
Verify the validity of access token
in case of error - return 401 (“Invalid access token”) in case of validation fails.
Verify that token is not expired
in case of error - return 401 (“Invalid access token”).
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).
Headers
API paragraph not found
Validate request
API paragraph not found
Request data validation
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.
Processing
API paragraph not found
Response structure
Example:
Expand | ||
---|---|---|
| ||
|
Post-processing processes
No
HTTP status codes
...
404
...
Error
...
dispense.id doesn`t exist
...
409
...
Page Properties | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
...
Error
...
invalid scope;
only users of legal entity who has created Medication Dispense and NHS Admin can reject Medication Dispense
|
...
422
...
Error
...
Backward compatibility
API paragraph not found