ЕСОЗ - публічна документація

Create license

Purpose

This WS allows to create a license for a legal entity

Key points

  1. Only authenticated and authorized user with an appropriate scope can create licenses.

  2. The license can be created for PRIMARY_CARE, EMERGENCY, OUTPATIENT, or PHARMACY legal entity.

  3. The license can be created for legal entities in ACTIVE or SUSPENDED statuses.

  4. Only an additional license can be created with this WS.

  5. The additional license can be created for legal entities with an active primary license.

Specification

Link

https://ehealthmisapi1.docs.apiary.io/#reference/public.-medical-service-provider-integration-layer/licenses/create-license

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

Resource

/api/licenses

Посилання на ресурс, наприклад: /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

POST

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

Sync/Async

Sync

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

Public/Private/Internal

Public

 

Logic

Save new license in licenses table (PRM DB)

Preconditions

Legal Entity exists and has Primary license

Input parameters

ATTRIBUTES: see on Apiary

Filters

No

Request structure

Example:

{ "type": "MSP", "license_number": "fd123443", "issued_by": "Кваліфікацйна комісія", "issued_date": "2022-02-28", "expiry_date": "2026-02-28", "active_from_date": "2022-02-28", "what_licensed": "реалізація наркотичних засобів", "order_no": "ВА43234", "is_primary": false }

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

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 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 dictionary

    • in 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 type

    • in 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”)

Dictionaries

  • LICENSE_TYPE

  • LEGAL_ENTITY_<LEGAL_ENTITY_TYPE>_ADDITIONAL_LICENSE_TYPES

Processing

API paragraph not found

Response structure

See on Apiary

Example:

{ "meta": { "code": 200, "url": "https://example.com/resource", "type": "object", "request_id": "req-adasdoijasdojsda" }, "data": { "id": "d290f1ee-6c54-4b01-90e6-d701748f0851", "type": "MSP", "license_number": "fd123443", "issued_by": "Кваліфікацйна комісія", "issued_date": "2022-02-28", "expiry_date": "2026-02-28", "active_from_date": "2022-02-28", "what_licensed": "реалізація наркотичних засобів", "order_no": "ВА43234", "legal_entity_id": "28d9c1be-08f0-403b-aa76-bff228c9904f", "is_primary": true } }

Post-processing processes

No

HTTP status codes

HTTP status code

Message

What caused the error

HTTP status code

Message

What caused the error

201

Response

 

401

Invalid access token

 

403

Your scope does not allow to access this resource. Missing allowances: license:write

 

404

No active primary license found for legal entity

 

409

  • Legal entity type and license type mismatch

  • License with type $.type is already present

  • License is expired

 

422

  • Legal entity must be in active or suspended status

  • Only additional license can be created

  • Value is not allowed in enum

  • License can not be issued later than active from date

  • License can not have active from date later than expiration date

 

Backward compatibility

API paragraph not found

ЕСОЗ - публічна документація