ЕСОЗ - публічна документація

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »


Introduction

Specification

Apiary

Validations


Authorization

  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

2.2. Determine the party_id associated with this user_id

SELECT pu.party_id
FROM party_users pu
WHERE pu.user_id = :user_id;

2.3. Determine employees related to this party_id in current MSP

SELECT e.id
FROM employees e
WHERE e.party_id = :party_id
AND e.legal_entity_id = :client_id;

2.4 Ensure that $.requester.identifier.value matches with user employees

3. Validate that DS belongs to the requester of encounter

3.1. Determine the party_id associated with requester ($.requester.identifier.value)

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

  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. Procedure code must be a valid value from NAME? dictionary, that is active and  request is allowed
    1. $.code.code exists in NAME? dictionary
      1. in case of error return 422 "Value is not found"
    2. $.code.code is active == true and request_allowed == true
      1. in case of error return 422 "Value is not active or request is not allowed"
  5. If group code was chosen as a code (will be specified soon), service_request_category should be equal to Dictionary_name.code.category
    1.  Select service from Dictionary_name where services.code==$.code.code and services.category=$.category
      1. in case of error return 422 "Service request category does not correspond to service code category"
  6. 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')
  7. 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
  8. Authored On is a valid date-time in the past
    1. $.authored_on - ISO date must be less than current date-time
  9. 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)
  10. 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"
  11. 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"
  12. 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"
  13. 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"
  14. Validate permited peisodes as references - DEPRECATED - Create Service Request V2#Referencevalidation
  15. 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"
  16. Validate expiration_date is in future
    1. in case of error return 422 "Expiration date can not be in past"

Reference validation

  1. Validate that $..identifier.value is an existing value from $..identifier.type.coding[0].code collection in DB and it belongs to the patient
    1. in case of errror return 422 "There is no {$..identifier.type.coding[0].code} with such id"
  2. Validate that this entity is not in status entered_in error
    1. 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

  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


Notes

  1. Валидация данных из supporting info на вхождение в эпизоды, которые выбраны для организации доступов
  2. Валидация данных из reasonReference на вхождение:
    1. в эпизод, к которому относится энкаунтер, на основании которого создан реферрал
    2. в эпизоды, которые выбраны для организации доступов
  3. Валидация соответствия пациента в рецепте пациенту в энкаунтере, на основании которого создается рецепт


  • No labels