Table of Contents |
---|
Introduction
Specification
Validations
Authorization
- 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
...
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"
- in case of error return 409 "Incorrect service request category"
- $.category.coding[*].system == "ehealth/SNOMED/service_request_categories"
- Procedure code must refer to a valid dictionary
- $.code.coding[*].system == "ehealth/SNOMED/procedure_codes"
- in case of error return 409 "Incorrect procedure code"
- $.code.coding[*].system == "ehealth/SNOMED/procedure_codes"
- Patient must be active
- $.patient.identifier.type.coding[*].system == "eHealth/resources"
- $.patient.identifier.type.coding[*].code == "patient"
- $.patient.identifier.value refer to active MPI (is_active == true and status == 'active')
- 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 acre 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"
Reference validation
- Validate that $..identifier.value is an existing value from $..identifier.type.coding[0].code collection in DB and it belongs to the patient
- in case of errror return 422 "There is no {$..identifier.type.coding[0].code} with such id"
- Validate that this entity is not in status entered_in error
- in case of errror return 422 "Could not reference entity in status entered_in_error"
Example:
1 2 3 4 5 6 7 8 9 10 11 12 | "identifier" : { "type" : { "coding" : [ { "system" : "eHealth/resources" , "code" : "episode_of_care" } ] }, "value" : "9183a36b-4d45-4244-9339-63d81cd08d9c" } } |
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
...