Table of Contents |
---|
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
...
json schema
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"
...
- 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"
Validate data
- Validate contract request id.
- Check contract_requests.id = $.id
- in case error return 404 ("Contract request with id=$id doesn't exist")
- Check contract_requests.id = $.id
- Validate contract_request.status=NEW
- in case error return 422 - "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_base
- nhs_contract_price
- ??nhs_payment_method
- issue_city
- Validate contractor_legal_entity_id
- Legal_entities.id = $.contractor_legal_entity_id and Legal_entities.status='ACTIVE',
- in case error return 422 ("Legal entity in contract request should be active")
- Legal_entities.id = $.contractor_legal_entity_id and Legal_entities.status='ACTIVE',
- Validate contractor_owner_id
- Employee status='APPROVED' and employees.legal_entity_id=contractor_legal_entity_id and employee_type='OWNER'
- in case error return 422, $contractor_owner_id (Contractor owner must be active within current legal entity in contract request)
- Employee status='APPROVED' and employees.legal_entity_id=contractor_legal_entity_id and employee_type='OWNER'
- Validate contractor_employee_divisions
- Employees from employee_divisions has employee_type='DOCTOR', status='APPROVED', division is not null
- in case of error return 422 error view $employee ('Employee must be active DOCTOR with linked division')
- 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')
- Check employee belongs to division
- in case of error return 422 error view $employee ('Employee must be within current division')
- Employees from employee_divisions has employee_type='DOCTOR', status='APPROVED', division is not null
- Validate start_date
- start_date > now()
- in case error return 422 $start_date ("Contract request start date should be in future")
- start_date > now()
...
After status is changed to APPROVED - generate printout form
Invoke MAN to render printuot form.
Request mapping:
Parameter | Source |
---|---|
id | CONTRACT_REQUEST |
...
MANResponse.$.data |
Response
mapping
field | value |
---|---|
nhs_signer_id | $.user_id |
nhs_legal_entity_id | $.client_id |
cupdated_by | $.user_id |
updated_at | now() |
status | APPROVED |
data | $.data |
Add to event manager
After status was changed (status = APPROVED, DECLINED, TERMINATED or SIGNED) - add new status to event_manager
field | value |
---|---|
event_type | StatusChangeEvent |
entity_type | Contract_request |
entity_id | $.id |
properties.status. | $.status |
event_time | $.update_at |
changed_by | $.user_id |
inserted_at | now() |
uodated_at | now() |
...