Overview
This web service is designed to create an episode of care.
Specification
Validation
Validate token
- Verify the validity of access token
- Return 401 in case validation fails
- Verify token is not expired
- in case of error return 401
Validate scopes
- Check user scopes in order to perform this action (scope = 'episode:create')
- Return 403 in case invalid scope(s)
Validate declaration
In order to perform this action, primary doctor must have active declaration with the patient
- Validate declaration using Method
Request validation
- Validate patient status
- Medical_data status for this patient must be in "active" status
- in case of error return 409 - "Patient is not active"
- Medical_data status for this patient must be in "active" status
- Validate episode id is uniqie
- $.id is unique
in case of error return 422 - "Episode with such id already exists"
{:error, [{
%{
description:
"pisode with such id already exists"
,
params: [],
rule: :invalid
},
"$.id"
}]}
- $.id is unique
- Validate request according to JSON Schema LINK
- in case of error return 422
Validate type = "Primary care"- resolved by JSON schemaValidate status= "active"- resolved by JSON schema- Validate managing_organization
- Only one item is allowed in coding array
- in case of error return 409 "Only one item is allowed in "coding" array "
- $.managing_organization.identifier.type.coding.[0].code = "legal_entity"
- in case of error return 409 "Only legal_entity could be subitted as a managing_organozation"
- $.managing_organization.identifier.value = token.client_id
- in case of error return 409 "User can create an episode only for the legal entity for which he works"
- $.managing_organization.identifier.type.coding.[0].system = "eHealth/resources"
- in case of error return 409 "Only value "eHealth/resources" allowed as a system for managing_organization"
- Only one item is allowed in coding array
- Validate period
- $.period.start <= current_date
- in case of error return 409 - "Start date of episode must be in past"
- $.period.end is absent
- in case of error return 409 - "End date of episode could not be submitted on creation"
- $.period.start <= current_date
- Validate care_manager
- $.care_manager.identifier.type.coding.[0].code = "employee"
- in case of error return 409 "Only employee could be subitted as a care_manager"
- $.care_manager.identifier.type.coding.[0].system = "eHealth/resources"
- in case of error return 409 "Only value "eHealth/resources" allowed as a system for care_manager"
- $.care_manager.identifier.value must meet the following requirements:
- id exsists in PRM.employee and is active DOCTOR and relates to the same legal entity
- PRM.employee.type = "DOCTOR"
- PRM.employee.status= "active"
- PRM.employee.legal_entity = token.client_id
- id exsists in PRM.employee and is active DOCTOR and relates to the same legal entity
- $.care_manager.identifier.type.coding.[0].code = "employee"