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

RCC_(CSI-2959)_Create approval


Validation of the request

Validate resources or block of resources

  1. Approvals are processed in the async way

Validate resources

Search for the resource in DB is done by the pair patient_id + resources_id due to solution architecture when all resources must be discovered via patient identifier

In case no records found using this combination - system will respond with 404 error

  1. if episode_of_care is presented in request as the code of resource

    1. Check episode_of_care in the request exists and is in active or closed status in DB

      1. in case of error return - 422 (Episode is canceled)

    2. Check if resource from granted_to = 'employee':

      1. in case of error return - 422 ("$.resource. value is not allowed in enum")

  2. if diagnostic_report is presented in request as the code of resource

    1. Check diagnostic_report block in the request exists and is in final status in DB

      1. in case of error return - 422 (Diagnostic report in \"entered_in_error\" status can not be referenced or Diagnostic report with such id is not found)

    2. Check if resource from granted_to = 'employee':

      1. in case of error return - 422 ("$.resource. value is not allowed in enum")

  3. if care_plan is presented in request as the code of resource

    1. Check care_plan in the request exists in DB

      1. in case of error return - 422 (Care plan with such id is not found)

    2. Check there no other objects in request

      1. in case of error return - 422 (Approval for care plan can not contain other entities)

    3. Check if resource from granted_to = 'employee':

      1. in case of error return - 422 ("$.resource. value is not allowed in enum")

    4. If access_level = 'write':

      1. Check if care_plans.managing_organization = granted_to.employees.legal_entity_id:

        1. in case of error return - 422 ('User is not allowed to write care plan from another legal_entity')

  4. if encounter  is presented in request as the code of resource

    1. Check encounter in the request exists in DB and is not in “entered_in_error” status in DB

      1. (Encounter in \"entered_in_error\" status can not be referenced or Encounter with such id is not found)

    2. Check if resource from granted_to = 'employee':

      1. in case of error return - 422 ("$.resource. value is not allowed in enum")

    3. Validate episode related to the encounter:

      • exists

        • in case of error - return 422 ('Encounter refers to episode that does not exist')

      • is “active” or “closed”

        • in case of error - return 422 ('Encounter refers to episode that is not active or closed')

      • it’s managing organization matches with author’s legal entity (client_id)

        • in case of error - return 422 ('Encounter is from another legal entity')

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