Info |
---|
REST API method / Метод REST API (настанова) (remove the link block before publishing the document) |
Table of Contents |
---|
Properties of a REST API method document
...
id | page_properties_method_REST API |
---|
...
Document type
...
Метод REST API
...
Guideline ID
...
GUI-0011
...
Author
...
@
...
Document version
...
1
...
Document status
...
DRAFT
...
Date of creation
...
ХХ.ХХ.ХХХХ (дата фінальної версії документа – RC або PROD)
...
Date of update
...
ХХ.ХХ.ХХХХ (дата зміни версії)
...
Method API ID
...
API-001-001-001-0001
...
Microservices (namespace)
...
MPI
...
Component
...
Auth
...
Component ID
...
COM-001-001
...
Link на API-специфікацію
...
...
Resource
...
{{host}}//api.ehealth.gov.ua/api/patients/id/encounter_package
...
Scope
...
Protocol type
...
Request type
...
Sync/Async
...
Public/Private
Purpose
Describe the purpose of the API method, add Key points (if necessary)
Logic
Description of the working algorithm of the API method and the interaction of services with each other add Service logic (if necessary)
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
...
composition_id
...
M
...
String ($uuid) (path)
...
Composition object ID
...
89678f60-4cdc-4fe3-ae83-e8b3ebd35c59
...
Request structure
See on API-specification (посилання на сторінку з API-специфікацією)
Description of the REST API request structure, example
...
title | Example |
---|
...
Headers
...
Key
...
Value
...
Mandatory
...
Description
...
Example
...
Content-Type
...
application/json
...
M
...
Тип контенту
...
Content-Type:application/json
...
Authorization
...
Bearer c2778f3064753ea70de870a53795f5c9
...
M
...
Перевірка користувача
...
Authorization:Bearer c2778f3064753ea70de870a53795f5c9
...
Request data validation
Describe the process of checking the input data transmitted in the request for compliance with the given rules and restrictions set in the API
Processing
A list of processes related to receiving, changing or transmitting data according to the logic defined in the REST API
Response structure examples
Description of the REST API response structure, example
...
title | Example |
---|
...
HTTP status codes
...
Response code
...
HTTP Status code
...
Message
...
Internal name
...
Description
...
Базові
...
1000
...
404
...
Composition not found
...
COMPOSITION_NOT_FOUND_404
...
Не знайдено медичний висновок
...
401
...
Unauthorized
...
Помилка підтвердження
...
Специфічні
...
422
...
Note |
---|
Сторінка знаходиться в процесі розробки. Інформація на ній може бути застарілою. |
Info |
---|
/wiki/spaces/EN/pages/17591304241 (remove the link block before publishing the document) |
Table of Contents |
---|
Properties of a REST API method document
Page Properties | ||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||||||||||||||||||
|
Purpose
This WS is designed to create contract request from Legal Entity side by Owner or Admin
Logic
After using thit WS request can be approved or declined by NHS side. After that, MSP must approve the request from their side (actually only for Capitation contract).
In case the request was two-sided approved, it can be two-sided signed.
Using this endpoint a reimbursement contract could be created as well as a capitation contract. The difference between those two types of contract is described here- Reimbursement version Data model
Configuration parameters
Description of the configuration parameters that are used when processing a request in the system
Dictionaries
CONTRACT_PAYMENT_METHOD
CONTRACT_TYPE
REIMBURSEMENT_CONTRACT_TYPE
ADDRESS_TYPE
COUNTRY
SETTLEMENT_TYPE
STREET_TYPE
PHONE_TYPE
SPECIALITY_TYPE
SPECIALITY_LEVEL
SPEC_QUALIFICATION_TYPE
Input parameters
Input is signed data in PKCS7 format. The data must be unpacked and validated using schema (Capitation Contract_request) or JSON schema (Reimbursement Contract_request)
In order to change signed contract contract_number should be send. In this case start_date and end_date are taken from existing contract and should not be present in payload (except in cases of contract prolongation. For these cases, validations are described below).
In case this contract request is changes for another one, the previous contract request id (Create Contract Request#previous_request) should be send in payload.
Input parameter | Mandatory | Type | Description | Example | |
---|---|---|---|---|---|
1 | contract_type | CAPITATION REIMBURSEMENT | String | Required |
|
2 | id |
| String | Contract_request ID. Required | 09106b70-18b0-4726-b0ed-6bda1369fd52 |
Request structure
See on API-specification
Expand | ||
---|---|---|
| ||
|
Dummy example (Capitation version):
Expand | ||
---|---|---|
|
Dummy example (Reimbursement version):
Expand | ||
---|---|---|
|
Headers
Key | Value | Mandatory | Description | Example | |
---|---|---|---|---|---|
1 | Content-Type | application/json | M | Тип контенту | Content-Type:application/json |
2 | Authorization | Bearer c2778f3064753ea70de870a53795f5c9 | M | Перевірка користувача | Authorization:Bearer c2778f3064753ea70de870a53795f5c9 |
3 |
Request data validation
Authorize
Verify the validity of access token
in case of error return 401 ('Invalid access token')
Check user scope contract_request:create in order to perform this action
in case of error generate 401 response ('Invalid access token')
If BLOCK_UNVERIFIED_PARTY_USERS is true, then check party's data match following condition: verification_status != NOT_VERIFIED or (verification_status = NOT_VERIFIED and updated_at <= current_date - UNVERIFIED_PARTY_PERIOD_DAYS_ALLOWED):
in case not match - return 403 ("Access denied. Party is not verified")
Digital signature
Decode content that is encrypted in an electronic digital signature.
Use Digital signature WS. Method checks digital signature and returns result.
Validate DS
We need to check DS based on legal entity legal form. DS can belong to individual entrepreneur or to legal entity. As previous version of DS can contain tax_id in EDRPOU field, not in DRFO validation must be done as described below:
Get client_id from token
Find prm.legal_entities by client_id
Check EDRPOU or DRFO matches prm.legal_entities.EDRPOU
Check if EDRPOU in Certificate details exists and not empty
Check if Certificate_details.EDRPOU=prm.legal_entities.EDRPOU
in case validation from a. didn't pass - Check that DRFO in Certificate details exists and not empty
Convert DRFO and prm.legal_entities.EDRPOU to uppercase
Compare DRFO and prm.legal_entities.EDRPOU as Cyrillic letters
Convert DRFO to Cyrillic and compare as Cyrillic letters
Check if Certificate_details.DRFO=prm.legal_entities.EDRPOU
In case validation fails - generate 422 error
Check that SURNAME in Certificate details is equal to LAST_NAME in Party
Get user_id → user_parties.party_id → parties.last_name and compare to surname from DS
Convert prm.parties.LAST_NAME and Certificate details.SURNAME to uppercase
Compare prm.parties.LAST_NAME and Certificate details.SURNAME as Cyrillic letters
In case validation fails - generate 422 error
Validate DRFO
Get parties.tax_id using party_users.party_id by user_id.
Compare DRFO in Certificate with party.tax_id
Convert DRFO and TAX_ID to uppercase
Compare DRFO and TAX_ID as Cyrillic letters
Convert DRFO to Cyrillic and compare as Cyrillic letters
In case validation fails - generate 422 error
Verify role
Extract from token:
Validate client_id (is_blocked=false)
in case of error return 403 Error ('Client is blocked')
Check contractor_legal_entity is active or suspended
in case error return 403 - ('Client is not active')
Validate request
Validate contract_type:
legal entities with types in (MSP,PRIMARY_CARE) can create only capitation contracts, legal entities with types in (PHARMACY) can create only reimbursement contracts
in case of error 409 - "Contract type "{contract_type}" is not allowed for legal_entity with type "{legal_entity_type}" "
Validate previous_request_id
select id from contract_request where id=$.previous_request_id
in case no data found return 422 ("previous_request does not exist")
Check previous_request status not in ('SIGNED')
in case error return 422 ('In case contract exists new contract request should be created')
Check that contractor_legal_entity_id of previous request is equal to contractor_legal_entity_id of current request
in case of error return 422 ('Previous request doesn't belong to legal entity')
For reimbursement contracts: Check that id_form from $.previous_request_id equal to id_form from request
in case of error return 422 ('Id_form from previous request is not equal to id_form from request')
Validate contractor_divisions
Check divisions belongs to legal_entity and divisions.status='active'
in case of error return 422 error view $divisions ('Division must be active and within current legal_entity')
Validate each division in array present exactly one time
in case of error return 422 error view $divisions ('Division duplicates')
Validate start_date
validate that start_date in a date format (^(\\d{4}(?!\\d{2}\\b))((-?)((0[1-9]|1[0-2])(\\3([12]\\d|0[1-9]|3[01]))?|W([0-4]\\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\\d|[12]\\d{2}|3([0-5]\\d|6[1-6])))?)?$)
in case of error return 422 error $start_date ('"expected \"<start_date>" to be a valid ISO 8601 date"')
the year in start_date must be equal to current or next year (current+1).
in case of error return 422 error $start_date ('Start date must be within this or next year')
Validate end_date (Note. These validations are applied for cases when the contract_number isn't passed in the request. If the contract_number is passed, validations from 7.f are applied)
validate that end_date in a date format (^(\\d{4}(?!\\d{2}\\b))((-?)((0[1-9]|1[0-2])(\\3([12]\\d|0[1-9]|3[01]))?|W([0-4]\\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\\d|[12]\\d{2}|3([0-5]\\d|6[1-6])))?)?$)
in case of error return 422 error $end_date ('"expected \"<end_date>" to be a valid ISO 8601 date"')
the year in $end_date can be next year after 'start_date' if the total period of the contract doesn't exceed 1 year.the $end_date must be greater or equal than the $start_date
in case of error return 422 ('The end_date should be greater or equal than the start_date')
the different between $end_date and $start_date should be no more than than reimbursement(capitation)_contract_max_period_dayglobal param
in case of error return 422 ('The difference between end_date and start_date is more than <reimbursement(capitation)_contract_max_period_day> days') one year')
Validate contractor_owner_id
Check employees.employee_id=contractor_owner_id and client_id=employee.legal_entity_id and employee_type in('OWNER', 'ADMIN') and status='APPROVED' and is_active=true
In case of error return 422 Error ('Contractor owner must be an active OWNER or ADMIN and within current legal entity in contract request')
If in request was sent contract_number:
check contract request number structure XXXX-1234-5678-C , where:
XXXX - series: numbers + only some letters (A, E, H, K, M, P, T, X)
1234-5678 - randomly generated numbers and letters A, E, H, K, M, P, T, X.
check there is a contract with such contract_number
in case of error return 422 error ('Contract with such contract number does not exist')
check if contract is not in status 'TERMINATED'
in case of error return 409 error ('Can not update terminated contract')
employee_divisions, start_date,
end_datecan't be updated. If there is an active contract with such contract_number copy start_date,end_dateand contractor_legal_entity_id from existing contract. It's not allowed in response.in case of error return 422 error
check submitted contract_type is the same as in existing contract with number =contract_number
in case of error 409 ('Submitted contract_type does not correspond to previously created content`)
for capitation and reimbursement contract requests:
if $contract_number and $end_date is passed in request:
the year of $end_date must be one year greater or equal then the $start_datein case of error return 422 ('The year of end_date should be one year greater or equal to start_date')
the $end_date should be equal or greater than today and less than or equal to three month from $end_date the previous contract
in case of error return 422 ('The end_date may be equal or greater than today and less than or equal to three month from end_date the previous contract')
if $contract_number w/o $end_date is passed in request:
$end_date is taken from the previous contract.
in case it is reimbursement contract:
check id_form is the same
in case of error 409 ('Submitted id_form does not correspond to previously created content`)
if medical_programs passed - validate them as described at p.13 below
Validate contractor_payment_details:
if payer_account not like ^UA[0-9]{22}$ or ^UA[0-9]{27}$ -> MFO must be required
Validate id_from is from dictionary CONTRACT_TYPE:
in case of error return 422 error ('value is not allowed in enum')
Validate there is no other active (VERIFIED) contract created by this legal_entity_id in this period(contract_request.start_date <= contract.end_date and contract_request.end_date => contract.start_date) by same contract_type and id_form (in case of reimbursement contract)
in case of error return 422 error ('Active contract is found. Contract number must be sent in request')
For capitation contract: Validate external_contractors
Check external_contractors.divisions.id is present in contractor_divisions.id
in case of error return 422 error $divisions ('The division is not belong to contractor_divisions')
Check external_contractors.contract.expires_at>start_date
in case of error return 422 error $contract.expires_at ('Expires date must be greater than contract start_date')
Set external_contractors.legal_entity_id='client_id'
division_id from the external_contractors block must be a part of the legal entity that enters into the capitation contract. In the external_contractors.legal_entity_id must be specify the legal entity that is the counter-party of this division_id.
For capitation contract: Validate external_contractor_flag:
If external_contractors is not null then external_contractor_flag must be
true
If external_contractors is null then external_contractor_flag must be set to false
in case of error return 422 error $external_contractor_flag ('Invalid external_contractor_flag')
If external_contractors wasn't sent in request then set external_contractor_flag to false.
For reimbursement contracts: Validate medical_programs:
Validate that all medical_programs with submitted ids exists
in case of error return 422 error view $medical_programs[...] ('Reimbursement program with such id does not exist')
Validate that medical_programs with submitted id is an active program
in case of error return 422 error view $medical_programs[...] ('Reimbursement program is not active')
Validate that all medical program and with MEDICATION type:
in case of error return 422 error view $medical_programs[...] (‘Program with such id is not a reimbursement program')
Check that medical_programs with submitted id correspond to id_form is in the allowed list:
in case of error return 422 error view $medical_programs[...] ('Medical program is not allowed for this action')
Note. For id_form=INSULIN_1 and PSYCHIATRY two medical programs must be present.in case of error return 409 error view $medical_programs ('The composition of medical programs does not correspond to the allowed composition')
Validate that list of medical programs in array doesn't contain duplicates ids:
in case of error return 409 error view $medical_programs (‘The list of medical programs contains duplicates')
id_form | medical_programs |
---|
id_form | medical_programs |
---|---|
PMD_1 | REIMBURSEMENT_CONTRACT_REQUEST_MEDICAL_PROGRAM_ID_DOSTUPNI_LIKY |
INSULIN_1 | REIMBURSEMENT_CONTRACT_REQUEST_MEDICAL_PROGRAM_IDS_INSULIN |
ND_1 | REIMBURSEMENT_CONTRACT_REQUEST_MEDICAL_PROGRAM_ID_NETSUKROVYY_DIABET |
PSYCHIATRY | REIMBURSEMENT_CONTRACT_REQUEST_MEDICAL_PROGRAM_IDS_PSYCHIATRY |
GENERAL | REIMBURSEMENT_CONTRACT_REQUEST_MEDICAL_PROGRAM_IDS_GENERAL |
Note. For GENERAL id_form user can specify any qty of programs (but at least one) from the configuration list. Also user can update list of medical programs using logic from p.7
Processing
Determine parent contract (optional)
In case contract request contains parameter '$.contract_number':
find contract that matches transmitted '$contract_number':
if there is no contract with specified contract number, return 422 error ('Contract with such contract number does not exist')
if contract is in 'Terminated' status, return 409 error ('Can not update terminated contract')
set parent_contract_id value as contract.id
Search pending contract requests
Find there is no contract request
for same contractor_legal_entity_id
within same period [start_date, end_date]
status in ('NEW', 'IN_PROCESS','APPROVED', 'NHS_SIGNED', 'PENGIND_NHS_SIGN')
id_form
In case there is such contract request change its status to 'TERMINATE'
Save contract request
Insert record to IL.contract_request in status 'NEW'
set - contractor_legal_entity_id=$client_id
Save signed contract request to media storage
Get url for contract request upload
Parameter | Source |
---|---|
action | 'GET' |
bucket | 'CONTRACT_REQUEST' |
resource_id | :CONTRACT_REQUEST_ID |
resource_name | :INITIAL_CONTRACT_REQUEST |
timestamp | :TIMESTAMP |
Upload signed contract request to media storage.
Response structure examples
See on API-specification
Expand | ||
---|---|---|
| ||
|
Expand | ||
---|---|---|
| ||
|
HTTP status codes
Response code | HTTP Status code | Message | Internal name | Description | |
---|---|---|---|---|---|
1 | Базові | ||||
2 | 201 | Response |
| ||
3 | 401 | Invalid access token |
| ||
4 | 403 | Access denied. Party is not verified | |||
5 | 403 | Client is blocked |
| ||
6 | 403 | Client is not active | |||
7 | 409 | Validation failed | |||
8 | 409 | Contract type "{contract_type}" is not allowed for legal_entity with type "{legal_entity_type} | |||
9 | 409 | Can not update terminated contract | |||
10 | 409 | Submitted contract_type does not correspond to previously created content | |||
11 | 409 | Submitted id_form does not correspond to previously created content | |||
12 | 409 | The composition of medical programs does not correspond to the allowed composition | |||
13 | 409 | The list of medical programs contains duplicates | |||
14 | 409 | Validation failed | |||
15 | 422 | Active contract is found. Contract number must be sent in request' | |||
16 | 422 | Contractor owner must be an active OWNER or ADMIN and within current legal entity in contract request | |||
17 | 422 | Contract with such contract number does not exist | |||
18 | 422 | Division must be active and within current legal_entity | |||
19 | 422 | Division duplicates | |||
20 | 422 | expected \"<start_date>" to be a valid ISO 8601 date | |||
21 | 422 | expected \"<end_date>" to be a valid ISO 8601 date | |||
22 | 422 | Expires date must be greater than contract start_date | |||
23 | 422 | $external_contractor_flag ('Invalid external_contractor_flag | |||
24 | 422 | In case contract exists new contract request should be created | |||
25 | 422 | Id_form from previous request is not equal to id_form from request | |||
26 | 422 | Invalid external_contractor_flag | |||
27 | 422 | Medical program is not allowed for this action | |||
28 | 422 | Previous request doesn't belong to legal entity | |||
29 | 422 | previous_request does not exist | |||
30 | 422 | Program with such id is not a reimbursement program | |||
31 | 422 | Reimbursement program with such id does not exist | |||
32 | 422 | Reimbursement program is not active | |||
33 | 422 | Start date must be within this or next year | |||
34 | 422 | The end_date should be greater or equal than the start_date | |||
35 | 422 | The end_date may be equal or greater than today and less than or equal to three month from end_date the previous contract | |||
36 | 422 | The division is not belong to contractor_divisions | |||
37 | 422 | The difference between end_date and start_date is more than <reimbursement(capitation)_contract_max_period_day> days') one year | |||
38 | 422 | value is not allowed in enum | |||
39 | 422 | Validation failed | |||
40 | Специфічні | ||||
41 |
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
Page Properties Report | ||||
---|---|---|---|---|
|
...