...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
Table of Contents |
---|
Purpose
This web service is designed to change contract request by nhs employee. NHS employee ADMIN SIGNER should enrich contract request with information about itself, sum and place of the contract request and . NHS signer could change status of contract request.
...
only contract request in status = IN_RPOCESS, all other statuses can't be changed
Specification
Page Properties | |||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||||||||||
|
Preconditions
Before this the contract request should be created from MSP/PHARAMCY side and NHS employee should be appointed
Logic
NHS employee with scopes 'contract_
...
request:update' can change contract request
Contract request only in status '
...
IN_PROCESS' could be changed
...
NHS employee can change only several field of the contract request but not all of them
Specification
- apiary
- json_schema
Request
In case of reimbursement contract, nhs_contract_price shouldn`t be filled.
Input parameters
Input parameter | Values | Type | Description | Example |
---|---|---|---|---|
id | String | Contract request identifier. Required | d290f1ee-6c54-4b01-90e6-d701748f0851 |
Request structure
Example:
Expand | ||
---|---|---|
| ||
|
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 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_
requestsrequest:update')
Return 403 in case invalid scope(s) "Your scope does not allow to access this resource. Missing allowances: contract_
requestsrequest:update"
Validate contract request status
Check contract_request.status=
...
IN_PROCESS
in case error return 422 - "Incorrect status of contract_request to modify it"
Validate data
Validate contract request id exists in DB
in case error return 404 ("Contract request with id=$id doesn't exist")
Validate
...
- Only next field could be changed by nhs employee
- issue_city
- Set issue_city = nhs_le.addresses.settlement_name, where address_type=REGISTRATION
- nhs_base
- price
- status (enum)
- Approved
- Declined
- status_reason
- issue_city
Response
Generate human readable contract request number
If status is changed to APPROVED - generate human readable contract request number
- Use algorithm to generate contract request number
- contract request number structure XXXX-1234-5678-9012-345-C , where:
- XXXX - series: numbers + only some letters (A, E, H, K, M, P, T, X)
- 1234-5678-9012-345 - randomly generated numbers and letters A, E, H, K, M, P, T, X.
- C - checksum: Should be calculated using the Damn algorithm or Verhoeff algorithm
Validate uniqueness of human readable contract request number
- generate contract_request_number
- Search contract request number in contract_requests.contract_number
- if exists = go to 'generate contract request number'
- else save contract_request_number to contract_request
Generate Printout form
If status is changed to APPROVED - generate printout form
Invoke MAN to render printuot form.
Request mapping:
...
...
...
Code Block | ||
---|---|---|
| ||
curl --request POST \
--header 'Accept: text/html' \
--header 'Content-Type: application/json' \
{:host}/templates/{:contract_printout_id}/actions/render |
Set IL.contract_request.printout_content:
...
MANResponse.$.data
Add to event manager
if status was changed (status = APPROVED, DECLINED or SIGNED) - add new status to event_manager
...
request according to json schema
in case error return 422 ("validation failed")
Validate OPS.contract_request.contract_type == $.contract_type
in case of error return 409 ("Contract_type does not correspond to previously created content")
validate nhs_contract_price
in case contract_type =` REIMBURSEMENT` nhs_contract_price shouldn`t be submitted
in case of error return 409 - "nhs_contract_price is unavailable for reimbursement contract requests`
nhs_contract_price should be >= 0
in case error return 422 ("Contract price could not be negative")
Validate $nhs_signer_id: fetch prm.employees.id=$nhs_signer_id
check client_id=prm.employees.legal_entity_id
in case of error return 422 Error (Employee doesn't belong to legal_entity)
check status='APPROVED' and is_active=true
in case of error return 422 Error (Employee must be active)
Processing
Fill the fields of contract_request in DB with information from request and from employee token:
field | value |
---|---|
contract_requests.nhs_signer_id | $nhs_signer_id |
contract_requests.nhs_legal_entity_id | $client_id |
contract_requests.nhs_signer_base | $.nhs_signer_base |
contract_requests.issue_city | $.issue_city |
contract_requests.nhs_contract_price | $.nhs_contract_price |
contract_requests.nhs_payment_method | $.nhs_payment_method |
contract_requests.updated_by | $.user_id |
contract_requests.updated_at | now() |
Response structure
Expand | ||
---|---|---|
|
field | value |
---|---|
contract_requests.nhs_signer_id | $nhs_signer_id |
contract_requests.nhs_legal_entity_id | $client_id |
contract_requests.nhs_signer_base | $.nhs_signer_base |
contract_requests.issue_city | $.issue_city |
contract_requests.nhs_contract_price | $.nhs_contract_price |
contract_requests.nhs_payment_method | $.nhs_payment_method |
contract_requests.updated_by | $.user_id |
contract_requests.updated_at | now() |
contract_request_update_response.json_schema
Example:
Expand | ||
---|---|---|
| ||
|
HTTP status codes
Page Properties | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||||
|