Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

...

  1. Verify the validity of access token
    1. in case of error return 401 ('Access denied')
  2. Check user scope service_request:write in order to perform this action
    1. 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

...

Validate Legal Entity Type

Invoke Get Legal Entity By Id

Validate Response $.data.Validate legal_entities.type in me_allowed_transactions_le_types and $.datalegal_entities.status =='active' and $.datalegal_entities.nhs_verified ==true

Validate service request

  1. Validate that service request ID is unique
    1. $.id must be unique
      1. in case of error return 409 - "Service request with such id already exists"
  2. 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
    1. $.requisition must match with patient's episode of care number
      1. in case of error return 409 - "Incorrect requisition number"
  3. Service request category must refer to a valid dictionary
    1. $.category.coding[*].system  == "ehealth/SNOMED/service_request_categories" 
      1. in case of error return 409 "Incorrect service request category"
  4. Validate  code as a Reference(service_group/service)
  5. Validate that service or group submitted as a code has request_allowed==true
  6. Validate category, in case service was submitted as a code
    1. if service.code.identifier.type.coding[].code=="service" than service.code.identifier should reference service from PRM.services where category is empty or equal to service.category
  7. Context must be an active encounter
    1. $.context.identifier.type.coding[*].system == "eHealth/resources"
    2. $.context.identifier.type.coding[*].code == "encounter"
    3. $.context.identifier.value refer to existing encounter (status == 'finished')
  8. Occurence is a valid date-time in the future
    1. $.occurrenceDateTime 
      1. $.occurrence_date_time - ISO date must be greater current date-time
    2. $.occurrencePeriod.start
      1. $.occurrence_period.start - ISO date must be greater than current date-time
      2. $.occurrence_period.end - ISO date must be greater than current date-time and greater than $.occurrencePeriod.start
  9. Authored On is a valid date-time in the past
    1. $.authored_on - ISO date must be less than current date-time
  10. Requester must be active employee within current legal entity
    1. $.requester.identifier.type.coding[*].system == "eHealth/resources"
    2. $.requester.identifier.type.coding[*].code == "employee"
    3. $.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)
  11. Performer type must refer to a valid dictionary
    1. $.performer_type.coding[*].system  == "ehealth/SNOMED/service_request_performer_roles" 
      1. in case of error return 409 "Incorrect service request category"
  12. Supporting info must refer to a valid medical events object (Episode of Care) within specified patient. 
    1. $.supporting_info.identifier.type.coding[*].system == "eHealth/resources"
      1. in case of error return 409 "Incorrect supporting info"
  13. Reason reference must refer to a valid medical events object (Observation, Condition) within specified patient. 
    1. $.reason_reference.identifier.type.coding[*].system == "eHealth/resources"
    2. $.reason_reference.identifier.type.coding[*].code in ("condition", "observation")
      1. in case of error return 409 "Incorrect reason reference"
  14. Permitted Episode of care must refer to a valid medical events object (Episode of Care) within specified patient. 
    1. $.permitted_episodes.identifier.type.coding[*].system == "eHealth/resources"
    2. $.permitted_episodes.identifier.type.coding[*].code == "episode_of_care"
      1. in case of error return 409 "Incorrect reason reference"
  15. Validate permited peisodes as references - 583403592
  16. Validate that permitted episodes is not specified in case of category "laboratory"
    1. in case of error 422 "Permitted episodes are not allowed for laboratory category of service request"
  17. Validate expiration_date is in future
    1. 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

  1. Generate requisition number (see Human readable Service request requisition number)
  2. Save signed content to media storage
  3. Save data to corresponding collection in DB
  4. Save link to the signed content in service request storage

...