ЕСОЗ - публічна документація

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 12 Next »

Purpose

Allows to cancel approval by it's identifier in patient context.

Specification

Link

https://medicaleventsmisapi.docs.apiary.io/#reference/approvals/cancel-approval/cancel-approval

Resource

api/patients/{{patiend_id}}/approvals/{{id}}/actions/cancel

Scope

approval:cancel

Components

Approvals

Microservices

API paragraph not found

Protocol type

REST

Request type

PATCH

Sync/Async

Async

Public/Private/Internal

Public

Logic

Allows to cancel approval by it's identifier in patient context. It is allowed only for the doctor who has an active declaration with a patient from url (can cancel all approvals) or approval is granted to user (can cancel own approval).

Input parameters

Input parameter

Values

Type

Description

Example

patiend_id

String

identifier of the patient

aff00bf6-68bf-4b49-b66d-f031d48922b3

id

String

identifier of the approval

aff00bf6-68bf-4b49-b66d-f031d48922b3

Headers

  • Content-Type:application/json

  • Authorization:Bearer c2778f3064753ea70de870a53795f5c9

Authorization

  • Verify the validity of access token

    • Return (401, 'Invalid access token') in case of validation fails

  • Verify that token is not expired

    • in case of error - return (401, 'Invalid access token')

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

    • Return (403, 'Your scope does not allow to access this resource. Missing allowances: approval:cancel') in case of invalid scope(s)

Validate Patient

  • Get Patient identifier from the URL

  • Check it exists in DB

    • Return 404 ('Person is not found') in case of error

Validate Approval

  • Get Approval identifier from the URL

  • Check it exists in DB

    • Return 404 ('not found') in case of error

  • Check approval status is active in DB

    • Return 409 ('Approval can be cancelled only if it has new or active status') in case of error

Validate User

  • Extract user_id from token.

  • Check user has an active declaration with a patient from URL (can cancel all approvals) or approval is granted to user (can cancel own approval):

    • Return 403 ('No active declaration with patient found or declaration is not from the same MSP') in case the employee doesn't have an active declaration with the patient

Response structure

See on Apiary

Example:

 Response example
{
  "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"
  }
}

 Response example
{
  "data": {
    "id": "d5a5d991-0bf7-476f-b3cf-bec73f044b2e",
    "granted_resources": [
      {
        "identifier": {
          "type": {
            "coding": [
              {
                "system": "eHealth/resources",
                "code": "episode_of_care"
              }
            ]
          },
          "value": "d5a5d991-0bf7-476f-b3cf-bec73f044b2e"
        },
        "display_value": "null"
      }
    ],
    "granted_to": {
      "identifier": {
        "type": {
          "coding": [
            {
              "system": "eHealth/resources",
              "code": "employee"
            }
          ]
        },
        "value": "9183a36b-4d45-4244-9339-63d81cd08d9c"
      },
      "display_value": "null"
    },
    "expires_at": 1498749591,
    "reason": {
      "identifier": {
        "type": {
          "coding": [
            {
              "system": "eHealth/resources",
              "code": "service_request"
            }
          ]
        },
        "value": "9183a36b-4d45-4244-9339-63d81cd08d9c"
      },
      "display_value": "null"
    },
    "status": "new",
    "access_level": "read",
    "authentication_method_current": {
      "type": "OTP",
      "number": "+38093*****85"
    }
  },
  "meta": {
    "code": 201,
    "url": "http://example.com/resource",
    "type": "object",
    "request_id": "req-adasdoijasdojsda"
  }
}

Service logic

Service allow to cancel of the patient approval:

  • Get approval by patient_id and approval id from approvals collection (MongoDB)

  • Update approvals status (update also updated_at, updated_by)

  • If patient's authentication method is OTP or third_person.OTP, send SMS to that patient with info about cancelling.

  • Render a response according to specification.

Add status to event manager

After status was changed (status = CANCELLED) - add new status to event_manager

field

value

event_type

StatusChangeEvent

entity_type

Approval

entity_id

$.id

properties.status.new_value

$.status

event_time

$.update_at

changed_by

$.changed_by

HTTP status codes

HTTP status code

Message

What caused the error

 201

 use payload from response

 sync

 202

 use Get job details to get processing result. Response payload will be returned in the job details

 async: default method

  • No labels