REST API method / Метод REST API (настанова) (remove the link block before publishing the document)
Properties of a REST API method document
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.
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.
Configuration parameters
Description of the configuration parameters that are used when processing a request in the system
Dictionaries
Provides a list of links to dictionaries that are available in Confluence
Input parameters
Description of input parameters
Input parameter | Mandatory | Type | Description | Example | |
---|---|---|---|---|---|
1 | id |
| String | Required | d290f1ee-6c54-4b01-90e6-d701748f0851 |
2 |
Request structure
See on API-specification (посилання на сторінку з API-специфікацією)
Description of the REST API request structure, example
Headers
Key | Value | Mandatory | Description | Example | |
---|---|---|---|---|---|
1 | Content-Type | application/json | M | Тип контенту | Content-Type:application/json |
2 |
Request data validation
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
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
A list of processes related to receiving, changing or transmitting data according to the logic defined in the REST API
Response structure examples
See on API-specification (посилання на сторінку з API-специфікацією)
Description of the REST API response structure, example
HTTP status codes
Response code | HTTP Status code | Message | Internal name | Description | |
---|---|---|---|---|---|
1 | Базові | ||||
2 | 200 | Response |
| ||
3 | 401 | Invalid access token |
| ||
4 | 401 | Unauthorized | Помилка підтвердження | ||
5 | 403 | Your scope does not allow to access this resource. Missing allowances: license:write |
| ||
6 | 1000 | 404 | Composition not found | COMPOSITION_NOT_FOUND_404 | Не знайдено медичний висновок |
7 | 404 | License was not found |
| ||
8 | 404 | No active primary license found for legal entity | |||
9 | 409 | License doesn't correspond to your legal entity |
| ||
10 | 409 | License type can not be updated | |||
11 | 409 | License is expired | |||
12 | 409 | Only additional license can be updated | |||
13 | 422 | Additional license can not be changed to primary | |||
14 | 422 | Legal entity must be in active or suspended status | |||
15 | 422 | License can not be issued later than active from date | |||
16 | 422 | License can not have active from date later than expiration date | |||
17 | Специфічні | ||||
18 | 422 | Only for active MPI record can be created medication request! |
Post-processing processes
Description of actions performed on data after processing
Technical modules where the method is used
List of pages describing technical modules where the method is used