Table of Contents |
---|
Specification
...
Using this endpoint a reimbursement contract could be created as well as a capitation contract. The difference between those two types of contract is described here- Contract: Reimbursement version Data model
Input parameters
Input is signed data in PKCS7 format. The data must be unpacked and validated using JSON schema (capitation contract) or JSON schema (reimbursement contract)
In order to change signed contract contract_number should be send. In this case start_date and end_date are taken from existing contract and should not be present in payload.
In case this contract request is changes for another one, the previous contract request id (583401836) should be send in payload.
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 DS
We need to check DS based on legal entity legal form. DS can belong to individual entrepreneur or to legal entity. As previous version of DS can contain tax_id in EDRPOU field, not in DRFO validation must be done as described below:
...
- Validate client_id (is_blocked=false)
- in case of error return 403 Error ('Client is blocked')
- Check contractor_legal_entity is active or suspended
- in case error return 403 - ('Client is not active')
Validate request
- Validate contract_type: legal entities with types in capitation_contract_le_types can create only capitation contracts when reimbursement_contract_le_types can create only reimbursement contracts
- in case of error 409 - "Contract type "{contract_type}" is not allowed for legal_entity with type "{legal_entity_type}" "
- Validate previous_request_id
- select id from contract_request where id=$.previous_request_id
- in case no data found return 422 ("previous_request does not exist")
- Check previous_request status not in ('SIGNED')
- in case error return 422 ('In case contract exists new contract request should be created')
- Check that contractor_legal_entity_id of previous request is equal to contractor_legal_entity_id of current request
- in case of error return 422 ('Previous request doesn't belong to legal entity')
- select id from contract_request where id=$.previous_request_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')
- 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'
For capitation contract: Validate contractor_employee_divisionsEmployees 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.idin 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_idin case of error return 422 error $divisions ('Employee in division duplicates)
- For capitation contract: 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'
- division_id from the external_contractors block must be a part of the legal entity that enters into the capitation contract. In the external_contractors.legal_entity_id must be specify the legal entity that is the counterparty of this division_id.
- Check external_contractors.divisions.id is present in contractor_divisions.id
- For capitation contract: 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
- Validate start_date
- the year in start_date must be equal to current or next year (current+1).
- in case of error return 422 error $start_date ('Start date must be within this or next year')
- the year in start_date must be equal to current or next year (current+1).
- Validate end_date (Note. These validations are applied for cases when the contract_number isn't passed in the request. If the contract_number is passed, validations from 10.g are applied)
- the the year in $end_date must can be equal to year in $start_date
in case of error return 422 error $end_date ('The year of start date and end date must be equal')next year after 'start_date' if the total period of the contract doesn't exceed 1 year. - the $end_date must be greater or equal than the $start_date
- in case of error return 422 ('The end_date should be greater or equal than the start_date')
- the different between $end_date and $start_date should be no more than one year old (365 or 366 days)
- in case of error return 422 ('The difference between end_date and start_date is more than one year')
- the the year in $end_date must can be equal to year in $start_date
- Validate contractor_owner_id
- Check employees.employee_id=contractor_owner_id and client_id=employee.legal_entity_id and employee_type in('OWNER', 'ADMIN') and status='APPROVED' and is_active=true
- In case of error return 422 Error ('Contractor owner must be an active OWNER or ADMIN and within current legal entity in contract request')
- If in request was sent contract_number:
- check 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.
- check there is a contract with such contract_number
- in case of error return 422 error ('Contract with such contract number does not exist')
- check if contract is not in status 'TERMINATED'
- in case of error return 409 error ('Can not update terminated contract')
- employee_divisions, start_date, end_date can't be updated. If there is an active contract with such contract_number copy start_date, end_date and contractor_legal_entity_id from existing contract. It's not allowed in response.
- in case of error return 422 error
- check submitted contract_type is the same as in existing contract with number =contract_number
- in case of error 409 ('Submitted contract_type does not correspond to previously created content`)
- in case it is reimbursement contract, check medical_program_id is the same
- in case of error 409 ('Submitted medical_program_id does not correspond to previously created content`)
- for capitation and reimbursement contract requests:
- if $contract_number and $end_date is passed in request:
- the $end_date must be greater or equal then the $start_date
- in case of error return 422 ('The year of end_date should be one year greater or equal to start_date')
- the $end_date should be less than $end_date from the previous contract and less than or equal to three month
- in case of error return 422 ('The end_date should be greater than of the previous contract and less than or equal to three months')
- the $end_date must be greater or equal then the $start_date
- if $contract_number w/o $end_date is passed in request:
- $end_date is taken from the previous contract.
- if $contract_number and $end_date is passed in request:
- check contract request number structure XXXX-1234-5678-C , where:
- Validate id_from is from dictionary CONTRACT_TYPE
- in case of error return 422 error ('Invalid contract type')
- Validate there is no other active (VERIFIED)
contract
created by this legal_entity_id in this period (contract_request.start_date <= contract.end_date and contract_request.end_date => contract.start_date)
by same contract_type and program_id( in case of reimbursement contract)- in case of error return 422 error ('There is an active contract. Contract number must be sent in request')
- For reimbursement contracts: Validate program with submitted id exists
- in case of error return 422 error ('Reimbursement program with such id does not exist ')
- For reimbursement contracts: Validate program with submitted id is an active program
- in case of error return 409 error ('Reimbursement program is not active')
- For reimbursement contracts: Validate program with submitted id has 'medication' type
- in case of error return 409 error ('Program with such id is not a reimbursement program')
- Validate contractor_payment_details:
- if payer_account not like
^UA[0-9]{22}$
or^UA[0-9]{27}$
-> MFO must be required
- if payer_account not like
Determine parent contract (optional)
...
Insert record to IL.contract_request in status 'NEW'
set - contractor_legal_entity_id=$client_id
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 : INITIAL_CONTRACT_REQUEST timestamp :TIMESTAMP - Upload signed contract request to media storage
...