Info |
---|
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 change status of contract request to APPROVED by NHS ADMIN SIGNER. NHS employee can change status of contract request through Admin portal
Logic
To approve contract next fields must be signed by NHS employee and sent by same NHS employee in base64 format (all fields below are required): In DS EDRPOU/DRFO must be equal to contractor_legal_entity.edrpou
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 | b075f148-7f93-4fc2-b2ec-2d81b19a9b7b |
2 |
Request structure
See on API-specification (посилання на сторінку з API-специфікацією)
Description of the REST API request structure, example
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
Validate token
Verify the validity of access token
Return 401 in case validation fails
Check if token is not expired
in case error return 401 - "Token is expired"
Validate user
extract user_id from token
...
Check if user is active
in case error return 403 - (user is not active)
check nhs_legal_entity is active
in case error return 403 - (Client is not active)
Check user role = "NHS ADMIN SIGNER"
in case error return 403 "User is not allowed to perform this action"
Validate scopes
Check user scopes in order to perform this action (scope = 'contract_requests:update')
Return 403 in case invalid scope(s) "Your scope does not allow to access this resource. Missing allowances: contract_requests:update"
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
Validate request
Check that all fields are present in signed content
"id"
"contractor_legal_entity":
"id"
"name"
"edrpou"
next_status
"text"
Check next_status
for contract type CAPITATION='APPROVED'. In case error return 422 "Incorrect next_status"
for contract type REIMBURSEMENT='PENDING_NHS_SIGN'. In case error return 422 "Incorrect next_status"
Validate contract request id
Check contract request with contract_request.id = $.id exists
in case of error return 404 ("not_found")
Check contract_requests.id = $.id
in case of error return 422 ("Signed content does not match the previously created content")
Validate contract_request.status=IN_PROCESS
in case error return 409 - "Incorrect status of contract request to modify it"
Validate nhs side fields are not empty - in case error return 422 "Field $ could not be empty"
nhs_signer_id
nhs_legal_entity_id
nhs_signer_base
nhs_contract_price - for capitation only
nhs_payment_method
issue_city
medical_program_id - for reimbursement only
Validate contractor_legal_entity_id
Legal_entities.id = $.contractor_legal_entity_id and Legal_entities.status='ACTIVE' and is_active=true,
in case error return 422 ('Legal entity is not active')
$contractor_legal_entity.edrpou in request=prm.legal_entities.edrpou
$contractor_legal_entity.name in request=prm.legal_entities.name
Validate contractor_owner_id
Employee is_active=true and status='APPROVED' and employees.legal_entity_id=contractor_legal_entity_id
in case error return 422, $contractor_owner_id ('Contractor owner must be active within current legal entity in contract 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')
Capitation only: Validate contractor_employee_divisions
Check contractor_employee_divisions is not null
in case of error return 422 error ('contractor_employee_divisions can not be empty')
Employees from employee_divisions has employee_type='DOCTOR', status='APPROVED'
in case of error return 422 error view $employee ('Employee must be an active DOCTOR')
Check contractor_employee_divisions.division_id is present in contractor_divisions.id
in case of error return 422 error $divisions ('The division is not belong to contractor_divisions')
Validate start_date
start_date > now()
in case error return 422 $start_date ("Contract request start date should be in future")
Reimbursement only: Validate medical_program_id is an ID of an ACTIVE medical program.
Check uploaded documents
Invoke Media Content Storage to check documents exist.
Return validation error if it's not
Processing
Generate contract number
In case contract_number is null generate new contract number according to the rules
Save response data to DB
After response is generated response.data should be saved to DB contract_requests.data
Validate status
if contract_request.type=CAPITATION - set status=APPROVED
if contract_request.type=REIMBURSEMENT - set status=PENDING_NHS_SIGN
Mapping
field | value |
---|---|
nhs_signer_id | $.user_id |
nhs_legal_entity_id | $.client_id |
updated_by | $.user_id |
updated_at | now() |
status | APPROVED, PENDING_NHS_SIGN |
data | $.data |
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 declaration to media storage
Add to event manager
After status was changed (status = APPROVED, PENDING_NHS_SIGN, DECLINED, TERMINATED or SIGNED) - add new status to event_manager
field | value |
---|---|
event_type | StatusChangeEvent |
entity_type | Contract_request |
entity_id | $.id |
properties.status.new_value | $.status |
event_time | $.update_at |
changed_by | $.user_id |
inserted_at | now() |
updated_at | now() |
Response structure examples
Description of the REST API response structure, example
Example:
Expand | ||
---|---|---|
| ||
|
...
Expand | ||
---|---|---|
| ||
|
HTTP status codes
Response code | HTTP Status code | Message | Internal name | Description | ||||||
---|---|---|---|---|---|---|---|---|---|---|
1 | Базові | |||||||||
2 | 201 | Response |
| |||||||
3 | 401 | Error | ||||||||
4 | 401 | Token is expired | ||||||||
5 | 403 |
|
| |||||||
6 | 1000 | 404 | Composition not found | COMPOSITION_NOT_FOUND_404 | Не знайдено медичний висновок | |||||
7 | 404 | not_found |
| |||||||
8 | 409 | Incorrect status of contract request to modify it |
| |||||||
9 | 422 |
| Validation failed | Помилка підтвердження | ||||||
10 | Специфічні | 11422 | Contractor owner must be active within current legal entity in contract request | |||||||
11 | 422 | Contract request start date should be in future | ||||||||
12 | 422 | contractor_employee_divisions can not be empty | ||||||||
13 | 422 | Division must be active and within current legal_entity | ||||||||
14 | 422 | Employee must be an active DOCTOR | ||||||||
15 | 422 | Field $ could not be empty | ||||||||
16 | 422 | Incorrect next_status | ||||||||
17 | 422 | Invalid EDRPOU in DS | ||||||||
18 | 422 | Legal entity is not activ | ||||||||
19 | 422 | Signed content does not match the previously created content | ||||||||
20 | 422 | The division is not belong to contractor_divisions | ||||||||
21 | Специфічні | |||||||||
22 | 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
Page Properties Report | ||||
---|---|---|---|---|
|
...