Overview
This web service is designed to close an episode.
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
Validate scopes
- Check user scopes in order to perform this action (scope = 'episode:write')
- Return 403 in case invalid scope(s)
Validate
declarationIn order to perform this action, primary doctor must have active declaration with the patient
Validate declaration using Methodlegal 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 403 "User is not allowed to perform actions with an episode that belongs to another legal entity"
- ME.episode.managing_organization==token.client_id
Validate request
- Validate episode.status!= "entered_in_error" or "closed"
- in case of error "Episode in {episode_status} can not be closed"
- Validate that "closing_reason" is a valid value from the corresponding dictionary
- $.closing_reason.coding[*].system == "eHealth/episode_cancellation_reasons"
- Validate period as Period (consider period.start_date from the episode)
Request processing
- Set the status of the episode in "closed"
- Set closing_reason in status_reason
- Set closing_summary
- Set period.end
- Create a record in episode.status_history