ЕСОЗ - публічна документація
[DRAFT] Create license [API-005-009-003-0188]
Сторінка знаходиться в процесі розробки. Інформація на ній може бути застарілою.
https://e-health-ua.atlassian.net/wiki/spaces/EN/pages/17591304241 (remove the link block before publishing the document)
- 1 Properties of a REST API method document
- 2 Purpose
- 2.1 Key points
- 3 Logic
- 4 Configuration parameters
- 5 Dictionaries
- 6 Input parameters
- 7 Request structure
- 8 Headers
- 9 Request data validation
- 10 Authorize
- 10.1 Validate request
- 10.2 Validate legal entity
- 10.3 Validate license type
- 10.4 Validate license dates
- 11 Processing
- 12 Response structure examples
- 13 HTTP status codes
- 14 Post-processing processes
- 15 Technical modules where the method is used
Properties of a REST API method document
Document type | Метод REST API |
---|---|
Document title | [DRAFT] Create license [API-005-009-003-0188] |
Guideline ID | GUI-0011 |
Author | @Viacheslav Tybin (SoE eHealth) |
Document version | 1 |
Document status | DRAFT |
Date of creation | ХХ.ХХ.ХХХХ (дата фінальної версії документа – RC або PROD) |
Date of update | ХХ.ХХ.ХХХХ (дата зміни версії) |
Method API ID | API-005-009-003-0188 |
Microservices (namespace) | IL |
Component | Legal Entities |
Component ID | COM-005-009 |
Link на API-специфікацію | |
Resource | {{host}}/api/licenses |
Scope | license:write |
Protocol type | REST |
Request type | POST |
Sync/Async | Sync |
Public/Private | Public |
Purpose
This WS allows to create a license for a legal entity
Key points
Only authenticated and authorized user with an appropriate scope can create licenses.
The license can be created for PRIMARY_CARE, EMERGENCY, OUTPATIENT, or PHARMACY legal entity.
The license can be created for legal entities in ACTIVE or SUSPENDED statuses.
Only an additional license can be created with this WS.
The additional license can be created for legal entities with an active primary license.
Logic
Save new license in licenses table (PRM DB)
Configuration parameters
N/A
Dictionaries
LICENSE_TYPE
LEGAL_ENTITY_<LEGAL_ENTITY_TYPE>_ADDITIONAL_LICENSE_TYPES
Input parameters
Input parameter | Mandatory | Type | Description | Example | |
---|---|---|---|---|---|
1 |
|
|
|
|
|
2 |
|
|
|
|
|
Request structure
See on API-specification
Headers
https://e-health-ua.atlassian.net/wiki/spaces/ESOZ/pages/18415648793
Request data validation
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 = 'license:write')
return 403 (“Your scope does not allow to access this resource. Missing allowances: license:write”) in case of invalid scope(s)
Validate request
Validate request using JSON schema
in case of error - return 422
Validate legal entity
Extract legal entity id from access token. Check that legal entity is in ‘ACTIVE’ or ‘SUSPENDED’ status
in case of error - return 422 (“Legal entity must be in active or suspended status”)
Validate license type
Check that additional license was passed in request ($.is_primary = false)
in case of error - return 422 (“Only additional license can be created”)
Check that license type in request exists in
LICENSE_TYPE
dictionaryin case of error - return 422 (“value is not allowed in enum”)
Check that license type in request exists in chart parameter
LEGAL_ENTITY_<LEGAL_ENTITY_TYPE>_ADDITIONAL_LICENSE_TYPES
based on legal entity typein case of error - return 409 (“Legal entity type and license type mismatch")
Check that legal entity has active primary license (request: select id from licenses where is_active=true and is_primary=true and legal_entity_id=$.legal_entity.id and (expiry_date >= current_date() or expiry_date is null); returns at least one value)
in case of error - return 404 (“No active primary license found for legal entity”)
Check that legal entity does not have license with type same as in request ($.type)
in case of error - return 409 (“License with type $.type is already present”) where $.type = license type from request
Validate license dates
Check that $.issued_date is not greater than $.active_from_date
in case of error - return 422 (“License can not be issued later than active from date”)
Check that $.active_from_date is not greater than $.expiry_date
in case of error - return 422 (“License can not have active from date later than expiration date”)
Check that $.expiry_date is not lesser than current_date
in case of error - return 409 (“License is expired”)
Processing
N/A
Response structure examples
See on API-specification
HTTP status codes
Response code | HTTP Status code | Message | Internal name | Description | |
---|---|---|---|---|---|
1 | Базові | ||||
2 |
| 201 | Response |
|
|
3 |
| 401 | Invalid access token |
|
|
4 |
| 403 | Your scope does not allow to access this resource. Missing allowances: license:write |
|
|
5 |
| 404 | No active primary license found for legal entity |
|
|
6 |
| 409 | Legal entity type and license type mismatch |
|
|
7 |
| 409 | License with type $.type is already present |
|
|
8 |
| 409 | License is expired |
|
|
9 |
| 422 | Legal entity must be in active or suspended status |
|
|
10 |
| 422 | License can not be issued later than active from dateLicense can not have active from date later than expiration date |
|
|
11 |
| 422 | License can not have active from date later than expiration date |
|
|
12 |
| 422 | Only additional license can be created |
|
|
13 |
| 422 | Value is not allowed in enum |
|
|
14 | Специфічні | ||||
15 |
|
|
|
|
|
Post-processing processes
N/A
Technical modules where the method is used
ЕСОЗ - публічна документація