toc
Table of Contents |
---|
Introduction
Specification
...
- Verify the validity of access token
- in case of error return 401 ('Access denied')
- Check user scope service_request:write in order to perform this action
- in case of error generate 403 response ('Invalid scopes')
Validate digital signature
Decode content that is encrypted in an electronic digital signature.
Use Digital signature WS. Method checks digital signature and returns result.
See service specification
1. Ensure that digital signature is valid
2. Validate that requester of service request is a current user
2.1. Get token metadata
- Extract user_id, client_id, client_type
...
Code Block | ||
---|---|---|
| ||
SELECT p.tax_id
FROM employees e, parties p
WHERE e.party_id = p.id
AND e.id = :requester; |
Validate request using JSON Schema
Return 422 with the list of validation errors in case validation fails
Validate service request
...
e.id = :requester; |
Validate request using JSON Schema
Return 422 with the list of validation errors in case validation fails
Validate service request
- Validate that service request ID is unique
- $.id must be unique
- in case of error return 409 - "Service request with such id already exists"
- $.id must be unique
- Requisition is a common identifier for the group of service requests and it must matches with one of the patient's episode of care number
- $.requisition must match with patient's episode of care number
- in case of error return 409 - "Incorrect requisition number"
- $.requisition must match with patient's episode of care number
- Service request category must refer to a valid dictionary
- $.category.coding[*].system == "ehealth/SNOMED/service_request_categories"
- $.requisition must match with patient's episode of care number
- in case of error return 409 - "Service request with such id already exists"
- Incorrect service request category"
- Procedure code must be a valid value from NAME? dictionary, that is active and request is allowed
- $.code.code exists in NAME? dictionary
- $.category.coding[*].system == "ehealth/SNOMED/service_request_categories"
- in case of error return 409 - "Incorrect requisition number"
- 422 "Value is not found"
- $.code.code is active == true and request_allowed == true
- in case of error return
- $.code.coding[*].system == "ehealth/SNOMED/procedure_codes"
- 422 "Value is not active or request is not allowed"
- If group code was chosen as a code (will be specified soon), service_request_category should be equal to Dictionary_name.code.category
- Select service from Dictionary_name where services.code==$.code.code and services.category=$.category
- in case of error return
- 422 "Service request category does not correspond to service code category"
- Select service from Dictionary_name where services.code==$.code.code and services.category=$.category
- Context must be an active encounter
- $.context.identifier.type.coding[*].system == "eHealth/resources"
- $.context.identifier.type.coding[*].code == "encounter"
- $.context.identifier.value refer to existing encounter (status == 'finished')
- Occurence is a valid date-time in the future
- $.occurrenceDateTime
- $.occurrence_date_time - ISO date must be greater current date-time
- $.occurrencePeriod.start
- $.occurrence_period.start - ISO date must be greater than current date-time
- $.occurrence_period.end - ISO date must be greater than current date-time and greater than $.occurrencePeriod.start
- $.occurrenceDateTime
- Authored On is a valid date-time in the past
- $.authored_on - ISO date must be less than current date-time
- Requester must be active employee within current legal entity
- $.requester.identifier.type.coding[*].system == "eHealth/resources"
- $.requester.identifier.type.coding[*].code == "employee"
- $.requester.identifier.value refer to active employee within current legal entity (employee.status == approved and employee.is_active == true and employee.legal_entity_id == token.client_id)
- Performer type must refer to a valid dictionary
- $.performer_type.coding[*].system == "ehealth/SNOMED/service_request_performer_roles"
- in case of error return 409 "Incorrect service request category"
- $.performer_type.coding[*].system == "ehealth/SNOMED/service_request_performer_roles"
- Supporting info must refer to a valid medical events object (Episode of Care) within specified patient.
- $.supporting_info.identifier.type.coding[*].system == "eHealth/resources"
- in case of error return 409 "Incorrect supporting info"
- $.supporting_info.identifier.type.coding[*].system == "eHealth/resources"
- Reason reference must refer to a valid medical events object (Observation, Condition) within specified patient.
- $.reason_reference.identifier.type.coding[*].system == "eHealth/resources"
- $.reason_reference.identifier.type.coding[*].code in ("condition", "observation")
- in case of error return 409 "Incorrect reason reference"
- Permitted Episode of care must refer to a valid medical events object (Episode of Care) within specified patient.
- $.permitted_episodes.identifier.type.coding[*].system == "eHealth/resources"
- $.permitted_episodes.identifier.type.coding[*].code == "episode_of_care"
- in case of error return 409 "Incorrect reason reference"
- Validate permited peisodes as references - Create Service Request V2583403592
- Validate that permitted episodes is not specified in case of category "laboratory"
- in case of error 422 "Permitted episodes are not allowed for laboratory category of service request"
- Validate expiration_date is in future
- in case of error return 422 "Expiration date can not be in past"
...
In this case validate that "9183a36b-4d45-4244-9339-63d81cd08d9c" is an existing episode_of_care
from patients collection and it is not entered_in_error.
Service logic
- Generate requisition number (see Human readable Service request requisition number)
- Save signed content to media storage
- Save data to corresponding collection in DB
- Save link to the signed content in service request storage
...