REST API method / Метод REST API (настанова) (remove the link block before publishing the document)
Properties of a REST API method document
Purpose
This WS is designed to update contract by NHS by creating new contract request.
Logic
This WS is designed to update contract by NHS by creating new contract request. Contract request is created with contract number, and parent contract is added to request. NHS Admin can change only fields that are on nhs side.
Request has a similar structure as in Public. Create Contract Request
. For Create contract request by NHS, the contract_number
in the request is required, it is used to change the existing contract by the NHS.
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 | contract_type | CAPITATION REIMBURSEMENT | String | Required |
|
2 | id |
| String | Contract_request ID. Required | 09106b70-18b0-4726-b0ed-6bda1369fd52 |
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 | Authorization | Bearer c2778f3064753ea70de870a53795f5c9 | M | Перевірка користувача | Authorization:Bearer c2778f3064753ea70de870a53795f5c9 |
3 |
Request data validation
Verify role
Extract from token:
Validate client_id (is_blocked=false)
in case of error return 403 Error ('Client is blocked')
Check legal_entity is active
in case error return 403 - ('Client is not active')
Check legal_entity.type = 'NHS'
in case error return 403 forbidden
Digital signature
Decode content that is encrypted in an electronic digital signature.
Use Digital signature WS. Method checks digital signature and returns result.
Validate EDRPOU
Check that EDRPOU in Certificate details exists and not empty
in case of error return 422 error ('Invalid EDRPOU in DS')
Check that EDRPOU in Certificate details is equal to EDPOU in legal entity
Get client_id from token.
Find prm.legal_entities id by client_id
Compare EDRPOU in Certificate with 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
Validations
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.
contract_number is in request
in case error return 409, "Contract number should be in payload"
check there is a contract with such contract_number
in case of error return 422 error ('Contract with such contract number does not exist')
contrat status = VARIFIED
in case of error return 409 error ('Can not update terminated contract')
Contract.is_suspended = false
in case error 409, "suspended contract should be updated by contractor_owner"
Check only next fields are different from contract
nhs_signer_id
nhs_signer_base
nhs_contract_price (for capitation contracts only)
nhs_payment_method
issue_city
Misc
assignee_id
in case error return 422, "Not allowed to change field $.field"
Validate end_date:
if $contract_number and $end_date is passed in request:
the year of $end_date must be greater or equal then the $start_date
in 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
Processing
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
type
medical_program_id (for reimbursement contracts)
In case there is such contract request change its' status to 'TERMINATE'
Save contract request
status=APPROVED
parent_contract_id=contract_id
update fields from request, other fields should be taken from contract.
Mapping for request
contract request | old contract | edited fields by nhs | other |
---|---|---|---|
contractor_legal_entity_id | contractor_legal_entity_id |
|
|
contractor_owner_id | contractor_owner_id |
|
|
contractor_base | contractor_base |
|
|
contractor_payment_details | contractor_payment_details |
|
|
contractor_rmsp_amount | contractor_rmsp_amount |
|
|
start_date | start_date |
|
|
end_date | end_date |
|
|
nhs_legal_entity_id |
|
| token.client_id |
nhs_signer_id |
| nhs_signer_id |
|
nhs_signer_base |
| nhs_signer_base |
|
contractor_signed |
|
| false |
issue_city |
| issue_city |
|
status |
|
| APPROVED |
status_reason |
|
| null |
nhs_contract_price |
| nhs_contract_price |
|
nhs_payment_method |
| nhs_payment_method |
|
contract_number | contract_number |
|
|
id_form | id_form |
|
|
contractor_divisions |
|
| SELECT id from contract_divisions where contract_id=parent_contract_id; |
misc |
| misc |
|
assignee_id |
| assignee_id |
|
type | type |
|
|
medical_program_id | medical_program_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
: CONTRACT_REQUEST_APPROVED
timestamp
:TIMESTAMP
Upload signed contract request to media storage
Event manager
After contract request was created by NHS as change to existed contract this change should be shown in event manager
field | value | example |
---|
field | value | example |
---|---|---|
event_type | ContractRequestCreateEvent |
|
entity_type | {$.contract.type}ContractRequest | CapitationContractRequest/ReimbursementContractRequest |
entity_id | $.id |
|
properties.contract.old_value | $.parent_id |
|
event_time | $.update_at |
|
changed_by | $.user_id |
|
inserted_at | now() |
|
updated_at | now() |
|
Response structure examples
See on API-specification (посилання на сторінку з API-специфікацією)
Description of the REST API response structure, example
Example:
HTTP status codes
Response code | HTTP Status code | Message | Internal name | Description | |
---|---|---|---|---|---|
1 | Базові | ||||
2 | 201 | Response |
| ||
3 | 401 |
|
| ||
4 | 401 | Unauthorized | Помилка підтвердження | ||
5 | 403 |
|
| ||
6 | 1000 | 404 | Composition not found | COMPOSITION_NOT_FOUND_404 | Не знайдено медичний висновок |
7 | 409 |
| Validation failed | ||
8 | 422 |
| Validation failed | ||
9 | 422 | Invalid EDRPOU in DS | |||
10 | 422 | Not allowed to change field $.field | |||
11 | 422 | The year of end_date should be one year greater or equal to start_date | |||
12 | 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 | |||
13 | Специфічні | ||||
14 | 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