Versions Compared

Key

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

...

Table of Contents

Overview

This web service is designed to cancel episode in case it was entered in error

Specification

Apiary

Validation

Table of Contents
minLevel1
maxLevel3

Purpose

This web service is designed to cancel episode in case it was entered in error

Specification

Page Properties

Link

https://medicaleventsmisapi.docs.apiary.io/#reference/medical-events/episode-of-care/cancel-episode

Resource

/api/patients/{{patient_id}}/episodes/{{episode_id}}/actions/cancel

Scope

episode:write

Components

Episode of Care

Microservices

API paragraph not found

Protocol type

REST

Request type

PATCH

Sync/Async

Async

Public/Private/Internal

Public

Logic

This web service is designed to cancel episode in case it was entered in error

Input parameters

Input parameter

Values

Type

Description

Example

patient_id

String

Patient identifier

70a9e15b-b71b-4caf-8f2e-ff247e8a5677

episode_id

String

Episode identifier

a10aeafb-0df2-4091-bc83-f07e92a100ae

Request structure

See on Apiary

Example:

Expand
titleRequest example
Code Block
{
  "explanatory_letter": "Епізод був відмінений у зв'язку з помилкою при виборі пацієнта",
  "status_reason": {
    "coding": [
      {
        "system": "eHealth/cancellation_reasons",
        "code": "misspelling"
      }
    ],
    "text": ""
  }
}

Authorize

Request to process the request using a token in the headers

  • Verify the validity of access token

    • Return 401 in case validation fails

  • Verify token is not expired

    • in case of error return 401 

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

    • Return 403 in case invalid scope(s)

Headers

Наприклад:

  • Content-Type:application/json

  • Authorization:Bearer {{access_token}}

  • API-key:{{secret}}

Request data validation

Validate token

  • check value of ALLOWof ALLOW_OTHER_LE_EMPLOYEES_TO_MANAGE_EPISODE variable 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
      • '

    )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

  1. Validate episode is not already canceled

    1. ME.patients{patient_id}.episodes{episode_id}.status!="entered_in_error"

      1. in case of error "Episode in <status> can not be canceled"  

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

    1. $.cancellation_reason.coding[*].system == "eHealth/cancellation_reasons"

  3. Validate that all encounters created on episode are already canceled

    1.   ME.patients{patient_id}.episodes{episode_id}.encounters{*}.status != `entered_in_error`

      1. in case of error - "Episode can not be canceled while it has not canceled encounters"

...

Processing

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

  2. Set $.cancellation_reason to ME.patients.episodes.status_reason

  3. Set explanatory_letter

  4. Create a record in ME.episode.status_history

Response structure

See on Apiary

Example:

Expand
titleResponse example
Code Block
{
  "data": {
    "status": "pending",
    "eta": "2018-08-02T10:45:16.000Z",
    "links": [
      {
        "entity": "job",
        "href": "/Jobs/NBXk9EyErUZv1RhXgyvgg"
      }
    ]
  },
  "meta": {
    "code": 202,
    "url": "http://example.com/resource",
    "type": "object",
    "request_id": "req-adasdoijasdojsda"
  }
}

Expand
titleResponse example
Code Block
{
  "meta": {
    "code": 404,
    "url": "http://example.com/resource",
    "type": "object",
    "request_id": "req-adasdoijasdojsda"
  },
  "error": {
    "type": "NOT_FOUND",
    "message": "Patient not found"
  }
}

Post-processing processes

API paragraph not found

HTTP status codes

HTTP status code

Message

What caused the error

202

 

 

401

 

Access token validation failed

403

 

Invalid scope

404

 Patient not found

 

422

 

Validation failed