ЕСОЗ - публічна документація
Cancel Episode (CR-207)
Overview
This web service is designed to cancel episode in case it was entered in error
Specification
Validation
Validate token
Verify the validity of access token
Return 401 in case validation fails
Verify token is not expired
in case of error return 401
Verify that user’s employees from care_manager belongs to one of the user_id from token.
in case of error - return 422 ('User is not allowed to perform this action')
Validate scopes
Check user scopes in order to perform this action (scope = 'episode:write')
Return 403 in case invalid scope(s)
Validate legal entity
Validate episode belongs to the legal entity where the current user works
ME.episode.managing_organization==token.client_id
in case of error return 422 "Managing_organization does not correspond to user`s legal_entity"
Validate request
Validate episode is not already canceled
ME.patients{patient_id}.episodes{episode_id}.status!="entered_in_error"
in case of error "Episode in <status> can not be canceled"
Validate that "canceleation_reason" is a valid value from the corresponding dictionary
$.cancellation_reason.coding[*].system == "eHealth/cancellation_reasons"
Validate that all encounters created on episode are already canceled
ME.patients{patient_id}.episodes{episode_id}.encounters{*}.status != `entered_in_error`
in case of error - "Episode can not be canceled while it has not canceled encounters"
Request processing
Set the status of the episode in "entered_in_error"
Set $.cancellation_reason to ME.patients.episodes.status_reason
Set explanatory_letter
Create a record in ME.episode.status_history
ЕСОЗ - публічна документація