Specification
Purpose
This WS is design to create contract request from Legal Entity side by Owner or Admin. Before the request is created the documents must have been uploaded. Than request can be approved or declined by NHS side. After that MSP must approve the request from their side. In case the request was two-side approved it can be two-side signed.
Input parameters
Input is signed data in PKCS7 format. The data must be unpacked and validated using JSON schema.
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
Digital signature
Decode content that is encrypted in an electronic digital signature.
Use Digital signature WS. Method checks digital signature and returns result.
Validate DRFO
- Check that DRFO in Certificate details exists and not empty
- in case of error return 422 error ('Invalid DRFO in DS')
- Check that DRFO in Certificate details is equal to DRFO in Party
- 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
Verify role
Extract from token:
- Validate client_id (is_blocked=false)
- in case of error return 403 Error ('Client is blocked')
- Check contractor_legal_entity is active
- in case error return 403 - ('Client is not active')
Validate 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')
- Validate each division in array present exactly one time
- in case of error return 422 error view $divisions ('Division duplicates')
- Check divisions belongs to legal_entity and divisions.status='active'
- 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')
- Check employee present in divisions for one time: count(employee_id)=1 by contractor_employee_divisions.division_id
- in case of error return 422 error $divisions ('Employee in division duplicates)
- Employees from employee_divisions has employee_type='DOCTOR', status='APPROVED'
- Validate external_contractors
- Check external_contractors.divisions.id is present in contractor_divisions.id
- in case of error return 422 error $divisions ('The division is not belong to contractor_divisions')
- Check external_contractors.contract.expires_at>start_date
- in case of error return 422 error $contract.expires_at ('Expires date must be greater than contract start_date')
- Set external_contractors.legal_entity_id='client_id'
- Check external_contractors.divisions.id is present in contractor_divisions.id
- Validate external_contractor_flag:
- If external_contractors is not null then external_contractor_flag must be
true
- If external_contractors is null then external_contractor_flag must be set to
false
- in case of error return 422 error $external_contractor_flag ('Invalid external_contractor_flag').
If external_contractors wasn't sent in request then set external_contractor_flag to false.
- If external_contractors is not null then external_contractor_flag must be