ЕСОЗ - публічна документація
[DRAFT] Public. Approve Contract Request by MSP [API-005-002-002-0050]
Сторінка знаходиться в процесі розробки. Інформація на ній може бути застарілою.
https://e-health-ua.atlassian.net/wiki/spaces/EN/pages/17591304241 (remove the link block before publishing the document)
- 1 Properties of a REST API method document
- 2 Purpose
- 3 Logic
- 4 Configuration parameters
- 5 Dictionaries
- 6 Input parameters
- 7 Request structure
- 8 Headers
- 9 Request data validation
- 9.1 Authorize
- 9.2 Validate token
- 9.3 Validate user
- 9.4 Validate scopes
- 9.5 Validate data
- 10 Processing
- 10.1 Save response data to DB
- 10.2 Mapping
- 10.3 Add to event manager
- 11 Response structure examples
- 12 HTTP status codes
- 13 Post-processing processes
- 14 Technical modules where the method is used
Properties of a REST API method document
Document type | Метод REST API |
---|---|
Document title | [Document status] REST API [Назва методу] [ID методу] |
Guideline ID | GUI-0011 |
Author | @ |
Document version | 1 |
Document status | DRAFT |
Date of creation | ХХ.ХХ.ХХХХ (дата фінальної версії документа – RC або PROD) |
Date of update | ХХ.ХХ.ХХХХ (дата зміни версії) |
Method API ID | API-005-002-002-0050 |
Microservices (namespace) | IL |
Component | Contracts |
Component ID | COM-005-002 |
Link на API-специфікацію | |
Resource | {{host}}/api/contract_requests/{{contract_type}}/{{id}}/actions/approve_msp |
Scope | contract_request:approve |
Protocol type | REST |
Request type | PATCH |
Sync/Async | Sync |
Public/Private | Public |
Purpose
This WS is designed to change status of contract request to PENDING_NHS_SIGN by legal entity side. After the contract was approved by NHS side (status=APPROVED) MSP employee can change status of contract request and approve it from his side.
Logic
This WS is designed to approve contract request by MSP side after it was approved by NHS side. Contract request only in status APPROVED can be approved by MSP/PHARMACY and as a result status changes to 'PENDING_NHS_SIGN'. Only after that NHS employee can sign the contract request.
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
Input parameter | Mandatory | Type | Description | Example | |
---|---|---|---|---|---|
1 | id |
| String |
|
|
2 |
|
|
|
|
|
Request structure
See on API-specification
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
Request to process the request using a token in the headers
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
extract client_id from token
Check if user is active
in case error return 403 - (user is not active)
check contractor_legal_entity is active
in case error return 403 - (Client is not active)
Validate $client_id=contractor_legal_entity_id.
in case of error return 403 - Client is not allowed to modify contract_request
Validate scopes
Check user scopes in order to perform this action (scope = 'contract_requests:approve')
Return 403 in case invalid scope(s) "Your scope does not allow to access this resource. Missing allowances: contract_requests:approve"
Validate data
Validate contract request id.
Check contract_requests.id = $.id
in case error return 404 ("Contract request with id=$id doesn't exist")
Validate contract_request.status=APPROVED
in case error return 409 - "Incorrect status of contract request to modify it"
Validate contractor_legal_entity_id
Legal_entities.id = $.contractor_legal_entity_id and Legal_entities.status='ACTIVE' and legal_entities.nhs_verified = true
in case error return 422 ("Legal entity in contract request should be active")
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')
For capitation only: Validate contractor_employee_divisions
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")
For reimbursement only: Validate medical_program_id is ACTIVE
Processing
Save response data to DB
set status='PENDING_NHS_SIGN'
Mapping
field | value |
---|
field | value |
---|---|
updated_by | $.user_id |
updated_at | now() |
status | PENDING_NHS_SIGN |
Add to event manager
After status was changed (status = APPROVED, DECLINED, PENDING_NHS_SIGN, TERMINATED or SIGNED) - add new status to event_manager
field | value |
---|---|
|
|
| Contract_request |
| $.id |
| $.status |
| $.update_at |
| $. |
inserted_at | now() |
updated_at | now() |
Response structure examples
See on API-specification
HTTP status codes
Response code | HTTP Status code | Message | Internal name | Description | |
---|---|---|---|---|---|
1 | Базові | ||||
2 |
| 200 |
|
|
|
3 |
| 401 | Token is expired |
|
|
4 |
| 403 | Client is not active |
|
|
5 |
| 403 | Client is not allowed to modify contract_request |
|
|
6 |
| 403 | user is not active |
|
|
7 |
| 403 | Your scope does not allow to access this resource. Missing allowances: contract_requests:approve |
|
|
8 |
| 404 | Contract request with id=$id doesn't exist |
|
|
9 |
| 409 | Incorrect status of contract request to modify it |
|
|
10 |
| 422 | Contractor owner must be active within current legal entity in contract request |
|
|
11 |
| 422 | Contract request start date should be in future |
|
|
12 |
| 422 | Division must be active and within current legal_entity |
|
|
13 |
| 422 | Employee must be an active DOCTOR |
|
|
14 |
| 422 | Legal entity in contract request should be active |
|
|
15 |
| 422 | The division is not belong to contractor_divisions |
|
|
16 | Специфічні | ||||
17 |
|
|
|
|
|
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
ЕСОЗ - публічна документація