Purpose
This WS is designed to update contract by NHS by creating new contract request. Contract request is created with contract number, and parent contract is added to request. NHS Admin can change fields that are on nhs side.
Specification
GraphQL
Authorize
- Verify the validity of access token
- in case of error return 401 ('Access denied')
- Check user scope contract_request:create in order to perform this action
- in case of error generate 401 response ('Invalid scopes')
- Verify the validity of access token
Verify role
Extract from token:
- Validate client_id (is_blocked=false)
- in case of error return 403 Error ('Client is blocked')
- Check legal_entity is active
- in case error return 403 - ('Client is not active')
- Check legal_entity.type = 'NHS'
- in case error return 403 forbidden
Validate
- contract request number structure XXXX-1234-5678-C , where:
- XXXX - series: numbers + only some letters (A, E, H, K, M, P, T, X)
- 1234-5678 - randomly generated numbers and letters A, E, H, K, M, P, T, X.
- contract_number is in request
- in case error return 409, "Contract number should be in payload"
- check there is a contract with such contract_number
- in case of error return 422 error ('Contract with such contract number does not exist')
- contrat status = VARIFIED
- in case of error return 409 error ('Can not update terminated contract')
- Contract.is_suspended = false
- in case error 409, "suspended contract should be updated by contractor_owner"
- Check only next fields are different from contract
- nhs_signer_id
- nhs_signer_base
- nhs_contract_price (for capitation contracts only)
- nhs_payment_method
- issue_city
- Miscellaneous
- in case error return 422, "Not allowed to change field $.field"
Search pending contract requests
1. Find there is no contract request
- for same contractor_legal_entity_id
- within same period [start_date, end_date]
- status in ('NEW', 'IN_PROCESS','APPROVED', 'NHS_SIGNED', 'PENGIND_NHS_SIGN')
- id_form
- medical_program_id (for reimbursement contracts)
In case there is such contract request change its' status to 'TERMINATE'
Save contract request
- status=APPROVED
- parent_contract_id=contract_id
- nhs_signed_date=null
- update fields from request, other fields should be taken from contract.