Table of Contents |
---|
...
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')
- Return (403, 'invalid scopes') in case of invalid scope(s)
...
- Get service request by ID
- Service request must be active
- $.status == "active"
- in case of error return 409 "Invalid service request status"
- $.status == "active"
Check for related episodes and encounters
Service request can be released only if there is no related episodes and encounters
Search for episode of care related to this service request.Medical Events DB: patient[<patient_id>].episodes[*].incoming_referrals = Request: service_request_idStatus in (active, closed)If there is at least one episode of care - return 409, "Service request cannot be released due to related episodes of care"
Search for encounters related to this service request.Medical Events DB: patient[<patient_id>].encounters[*].incoming_referrals = Request: service_request_idStatus in (finished)If there is at least one encounter - return 409, "Service request cannot be released due to related encounters"
Service logic
- Update service request attributes. Erase used_by
- Set Medical Events DB: service_requests[<id>].used_by to NULL
...