...
Перевірка та взяття в обробку направлення за програмою медичним закладом
Specification
Validations
Authorization
Verify the validity of access token
Return (401, 'unauthorized') in case of validation fails
Verify that token is not expired
in case of error - return (401, 'unauthorized')
Check user scopes in order to perform this action (scope = 'service_request:write')
Return (403, 'invalid scopes') in case of invalid scope(s)
...
Validate request
legal entity(client_id)
Check legal_entity.type in me_allowed_transactions_le_types config parameter and legal_entity.status = ACTIVE
in case of error return 409 "Action is not allowed for the legal entity"
service request
validate SR.program_processing_status in (new,In Queue,In Progress)
in case error return 409, “service request has wrong status“
contract
check legal_entity (from token) has active contract with type = '________'(TBD)
in case error return 409, “Legal entity does not have a proper contract“
validate dates start_date <= now <=end_date
in case error return 409, “contract is not active“
validate contract.status = 'VERIFIED' and is_active=true
in case error return 409, “contract is not active“
validate contract.is_suspended = false
in case error return 409, “Contract is suspended and should be updated“validate SR.status = Active
in case error return 409, “service request has wrong status“
If SR.based_on is present:
Verify submitted Activity:
It has scheduled, in_progress status
in case of error return 409, "Invalid activity status")
if quantity was set, then validate remaining_quantity greater then zero:
in case of error return 409, "The number of available services according to the care plan activity has been exhausted"
Verify Care plan:
It should be in active status
in case of error return 409, "Care plan is not active"
Care plan's period end (if exist) should be greater than current date or equal.
in case of error return 409, “Care plan expired“
program
For each program validate it is an existing service program with type=service
in case not found or is_active==false write result in Data collection according to apiary
in case type!= service write result in Data collection according to apiary - "Invalid program type"
For each program validate that service(or service_group) is an active member of the program
Select is_active from PRM.program_services where service_id(or group_id) == $.signed_content.code.identifier.value and program_id=$.program.identifier.value
if not found or is_active==false write result in Data collection according to apiary - "Service is not included in the program"
Prepare & return response data structure
Fill response WS data structure
Validate response using JSON schemas
Return 422 with list of validation errors in case validation fails (422 EView)For each program in array prepare response
If it is any or some errors from validations return “NOT VALID“ with error msg