Versions Compared

Key

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

Table of Contents

Image Added

Requirements

  1. Відміна використання направлення

Specification

  1. Release Service Request

Validation

Authorization

  • Verify the validity of access token
    • Return (401, 'unauthorized') in case of validation fails
  • Verify that token is not expired
    • in case of error - return (401, 'unauthorized')
  • Check user scopes in order to perform this action (scope = 'service_request:use')
    1. Return (403, 'invalid scopes') in case of invalid scope(s)

Validate transition

Only active and used service request can be released

  1. Get service request by ID
  2. Service request must be active
    1. $.status == "active"
      1. in case of error return 409 "Invalid service request status"

Check for related episodes and encounters

Service request can be released only if there is no related episodes and encounters

  1. Search for episode of care related to this service request.
    1. Medical Events DB: patient[<patient_id>].episodes[*].incoming_referrals = Request: service_request_id
    2. Status in (active, closed) 
      1. If there is at least one episode of care - return 409, "Service request cannot be released due to related episodes of care"
  2. Search for encounters related to this service request.
    1. Medical Events DB: patient[<patient_id>].encounters[*].incoming_referrals = Request: service_request_id
    2. Status in (finished) 
      1. If there is at least one encounter - return 409, "Service request cannot be released due to related encounters"

Service logic

  1. Update service request attributes. Erase used_by_legal_entity
    1. Set Medical Events DB: service_requests[<id>].used_by_legal_entity to NULL

Notes

Валидация: обязательно проверка, что на реферрал не ссылается какой-нибудь эпизод с энкаунтером энкаунтером  - это означает, что пациент уже приходил на прием к другому врачу. Исключением может быть энтеред ин эррор или клоузд но с каким-то ризоном особенным