ЕСОЗ - публічна документація
Private. Approve Contract Request by NHS
- 1 Purpose
- 2 Specification
- 3 Preconditions
- 4 Logic
- 5 Input parameters
- 6 Request structure
- 7 Authorize
- 8 Headers
- 9 Request data validation
- 9.1 Validate token
- 9.2 Validate user
- 9.3 Validate scopes
- 9.4 Digital signature
- 9.5 Validate EDRPOU
- 9.6 Validate DRFO
- 9.7 Validate request
- 9.8 Check uploaded documents
- 10 Dictionaries
- 11 Processing
- 12 Response structure
- 13 HTTP status codes
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
Specification
Link | Посилання на Apiary або Swagger | |
Resource | /api/contract_requests/{{id}}/actions/approve | Посилання на ресурс, наприклад: /api/persons/create |
Scope | contract_request:update | Scope для доступу |
Components | Contracts | Зазначається перелік бізнес компонентів, які використовують цей метод, наприклад: ePrescription |
Microservices | API paragraph not found | Перелік мікросервісів, які використовує метод API, наприклад: Auth, ABAC |
Protocol type | REST | Тип протоколу, який використовується запитом, наприклад: SOAP | REST |
Request type | PATCH | Тип запиту API, наприклад: GET, POST, PATCH… |
Sync/Async | API paragraph not found | Метод є синхронним чи асинхронним? |
Public/Private/Internal | Private | Потрібно зазначити тип методу за ступенем доступності |
Preconditions
Before this the contract request should Updated by NHS employee
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
Input parameters
Input parameter | Values | Type | Description | Example |
---|---|---|---|---|
id |
| String | Required | b075f148-7f93-4fc2-b2ec-2d81b19a9b7b |
Request structure
Example:
Authorize
Request to process the request using a token in the headers
Headers
Наприклад:
Content-Type:application/json
Authorization:Bearer c2778f3064753ea70de870a53795f5c9
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
extract client_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
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
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
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
Example:
HTTP status codes
HTTP status code | Message | What caused the error |
---|---|---|
201 | Response |
|
401 |
|
|
403 |
|
|
404 | not_found |
|
409 | Incorrect status of contract request to modify it |
|
422 |
| Validation failed |
ЕСОЗ - публічна документація