ЕСОЗ - публічна документація
Update license
- 1 Purpose
- 1.1 Key points
- 2 Specification
- 3 Logic
- 4 Preconditions
- 5 Input parameters
- 6 Filters
- 7 Request structure
- 8 Authorize
- 9 Headers
- 10 Validate request
- 11 Request data validation
- 11.1 Validate legal entity
- 11.2 Validate license
- 11.3 Validate license dates
- 12 Processing
- 13 Response structure
- 14 Post-processing processes
- 15 HTTP status codes
- 16 Backward compatibility
Purpose
This WS allows to update a previously created license for a legal entity
Key points
Only authenticated and authorized user with an appropriate scope can update licenses.
The license can be updated for PRIMARY_CARE, EMERGENCY, OUTPATIENT, or PHARMACY legal entity.
The license can be updated for legal entities in ACTIVE or SUSPENDED statuses.
Only an additional license can be updated with this WS.
The additional license can be updated for legal entities with an active primary license.
Specification
Link | Посилання на Apiary або Swagger | |
Resource | /api/licenses/{{id}} | Посилання на ресурс, наприклад: /api/persons/create |
Scope | license:write | Scope для доступу |
Components | Legal Entities | Зазначається перелік бізнес компонентів, які використовують цей метод, наприклад: ePrescription |
Microservices | API paragraph not found | Перелік мікросервісів, які використовує метод API, наприклад: Auth, ABAC |
Protocol type | REST | Тип протоколу, який використовується запитом, наприклад: SOAP | REST |
Request type | PATCH | Тип запиту API, наприклад: GET, POST, PATCH… |
Sync/Async | Sync | Метод є синхронним чи асинхронним? |
Public/Private/Internal | Public |
|
Logic
Check if any attribute has changed comparing request and licenses table data (PRM DB). If any, then:
Update license data according to received request in licenses table (PRM DB)
Set updated_at = now()
Set updated_by = user_id.
Preconditions
Legal Entity exists and has Primary license
Input parameters
Input parameter | Values | Type | Description | Example |
---|---|---|---|---|
id |
| String | Required | d290f1ee-6c54-4b01-90e6-d701748f0851 |
Filters
No
Request structure
See on Apiary
Example:
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)
Headers
Content-Type:application/json
Validate request
Validate request using JSON schema
in case of error - return 422
Request data validation
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
Check that updated license exists in database
in case of error - return 404 (“License was not found”)
Check that updated license has
is_primary=false
flagin case of error - return 409 (“Only additional license can be updated”)
Check that additional license flag was passed in request ($.is_primary = false)
in case of error - return 422 (“Additional license can not be changed to primary”)
Check that updated license belongs to legal entity from access token
in case of error - return 409 (“License doesn't correspond to your legal entity")
Check that license type in request equals updated license type
in case of error - return 409 (“License type can not be updated”)
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 returns at least one value)
in case of error - return 404 (“No active primary license found for legal entity”)
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
API paragraph not found
Response structure
See on Apiary
Example:
Post-processing processes
No
HTTP status codes
HTTP status code | Message | What caused the error |
---|---|---|
200 | Response |
|
401 | Invalid access token |
|
403 | Your scope does not allow to access this resource. Missing allowances: license:write |
|
404 |
|
|
409 |
|
|
422 |
|
|
Backward compatibility
API paragraph not found
ЕСОЗ - публічна документація