Table of Contents |
---|
...
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"
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
- Get user_id → user_parties.party_id → parties.last_name and compare to surname from DS
...
- 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")
- Check contract request with contract_request.id = $.id exists
- 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
- Legal_entities.id = $.contractor_legal_entity_id and Legal_entities.status='ACTIVE' and is_active=true,
- 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')
- Employee is_active=true and status='APPROVED' and employees.legal_entity_id=contractor_legal_entity_id
- 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')
- Check divisions belongs to legal_entity and divisions.status='active'
- 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')
- Check contractor_employee_divisions 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()
- Reimbursement only: Validate medical_program_id is an ID of an ACTIVE medical program
...
Response
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.
ParameterSourceaction 'GET' bucket 'CONTRACT_REQUEST' resource_id : CONTRACT_REQUEST_ID resource_name : CONTRACT_REQUEST_APPROVED timestamp :TIMESTAMP - Upload signed declaration to media storage
Add 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() |
updated_at | now() |
...