Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents

Overview

...

Apiary

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 check value of ALLOW_OTHER_LE_EMPLOYEES_TO_MANAGE_EPISODE variable in charts configuration

    • if its value is equal to false, 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')

    • otherwise, verify that user’s employees from care_manager belongs to the same Legal Entity as author of the episode

      • in case of error - return 422 ('User is not allowed to perfom this action')

Validate scopes

  • Check user scopes in order to perform this action (scope = 'episode:write')

    1. Return 403 in case invalid scope(s)

...

  1. 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

  1. Validate episode.status!= "entered_in_error" or "closed"

    1. in case of error "Episode in {episode_status} can not be closed"

  2. Validate that "closing_reason" is a valid value from the corresponding dictionary 

    1. $.closing_reason.coding[*].system == "eHealth/episode_cancellation_reasons"

  3. Validate period as Period (consider period.start_date from the episode)

...

  1. Set the status of the episode in "closed"

  2. Set closing_reason in status_reason

  3. Set closing_summary

  4. Set period.end

  5. Create a record in episode.status_history

  6. Async! Close related service requests

    1. Fetch all service requests from $.referral_requests

    2. Send message to Kafka

    3. Process each message and update service request status to Completed (see Deprecated - Kafka Consumer: Mark Service Request As Completed)