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

RC_[UPD] Resend SMS on Device request

Purpose

This WS is designed to resend sms with OTP-code to the person’s verified phone on device request in case OTP wasn’t delivered in first time.

Key points

  1. Only authenticated and authorized user with appropriate scope can resend SMS on Device request.

  2. SMS with OTP-code can be resend only to person with verification_type = OTP OR THIRD_PERSON authentication metod with active confidant person relationship.

  3. SMS with OTP-code can be resend only for Device request in active status

 

Specification

Link

https://ehealthmedicaleventsapi.docs.apiary.io/#reference/device-requests/resend-sms-on-device-request/resend-sms-on-device-request

Посилання на Apiary або Swagger

Resource

/api/patients/{{patient_id}}/device_requests/{{device_request_id}}/actions/resend

Посилання на ресурс, наприклад: /api/persons/create

Scope

device_request:resend

Scope для доступу

Components

Devices

Зазначається перелік бізнес компонентів, які використовують цей метод, наприклад: ePrescription

Microservices

 

Перелік мікросервісів, які використовує метод API, наприклад: Auth, ABAC

Protocol type

REST

Тип протоколу, який використовується запитом, наприклад: SOAP | REST

Request type

GET

Тип запиту API, наприклад: GET, POST, PATCH…

Sync/Async

Sync

Метод є синхронним чи асинхронним?

Public/Private/Internal

Public

Потрібно зазначити тип методу за ступенем доступності

 

Logic

API paragraph not found

 

Input parameters

Input parameter

Values

Type

Description

Example

Input parameter

Values

Type

Description

Example

patient_id

 

String

Unique patient identifier

7075e0e2-6b57-47fd-aff7-324806efa7e5

device_request_id

 

String

Unique device request identifier

aff00bf6-68bf-4b49-b66d-f031d48922b3

 

Request structure

API paragraph not found

 

Authorize

  1. Verify the validity of access token

    1. in case of error - return 401 (“Invalid access token”) in case of validation fails

  2. Verify that token is not expired

    1. in case of error - return 401 (“Invalid access token”)

  3. Check user scopes in order to perform this action (scope = 'device_request:resend')

    1. return 403 (“Your scope does not allow to access this resource. Missing allowances: device_request:resend”) in case of invalid scope(s)

 

Headers

  • Content-Type:application/json

  • Authorization:Bearer d368a4b0-4a0e-457a-b267-32359fa6288f

 

Request data validation

Validations

  1. Check if device request with device_request_id from request is exist

    1. in case of error - return 404 (“Not found”) in case of validation fails

  2. Validate person

    1. Check if person with patient_id from request is exist

      1. in case of error - return 404 (“Not found”) in case of validation fails

    2. Check if person with patient_id from request is not preperson

      1. in case of validation fails skip all steps below

  3. Validate legal entity

    1. Check that legal_entity_type is included in chart variables ME_ALLOWED_TRANSACTIONS_LE_TYPES config parameter

      1. in case of error return 409 "Action is not allowed for the legal entity"

    2. Check that legal_entity has status = active

      1. in case of error return 409 "Action is not allowed for the legal entity" 

  4. Validate device_request

    1. Check that status = ‘active'

      1. in case of error - return 409 error ('You can not resend SMS for device request in status %status%')

 

Processing

  1. Get person's authentication_method of MPI according to logic:

  2. If authentication_method == OTP or THIRD_PERSON (with OTP) 

    1. if device_request has a program specified

      1. Generate text SMS with template CREATE_DEVICE_REQUEST_SMS_TEMPLATE.

      2. enrich template with data from Device Request: request_number, verification_code

    2. if device_request has no program specified

      1. Generate text SMS with template СREATE_DEVICE_REQUEST_SMS_TEMPLATE_WITHOUT_CODE.

      2. enrich template with data from Device Request: request_number

    3. If inform_with exists in device request and is not empty, check:

      1. Authentication method exists in person_authentication_methods table in MPI DB (with is_active=true), is active (ended_at > now() or null)

      2. Get value of THIRD_PERSON_CONFIDANT_PERSON_RELATIONSHIP_CHECK config parameter, if it is set to true - for authentication method with type = THIRD_PERSON check that person from value is an approved confidant for a person from device request – exists active and approved confidant person relationship between person from request and confidant_person_id from authentication method value (using following logic: Check confidant person relationship with person_id = person from request and confidant_person_id = value from auth method - expected :ok, :approved response)

        1. in case any validation failed - return 409 ('Authentication method doesn't exist or is inactive')

        2. else - get authentication_method from inform_with

    4. If inform_with does not exist in device request or is empty - get default authentication_method of person from MPI using logic Determination of a default authentication method and return person's active auth_methods

  3. Call SMS timeout procedure to check if resending is allowed using:
    - DR_MAX_ATTEMPTS_COUNT as MAX_ATTEMPTS_COUNT
    - DR_SEND_TIMEOUT as SEND_TIMEOUT
    - "device_request" as entity_name
    - device_request_id as entity_id

    in case of error - return 429 ("Sending SMS timeout. Try later. Next attempt will be available at <attempts.oldest.value + SEND_TIMEOUT>")

  4. Check if sms notifications are enabled:

    1. if device_request has a program specified

      1. in case of an error check that the specified program has setting request_notification_disabled set in false or the setting is absent

        1. return an error 409 "Action is not allowed for the specified medical program"

      2. if device_request is for assistive device (device_request.code OR at least one classification type of device_request.code_reference is in dictionary configuration “assistive_devices”)

        1. generate SMS text with template CREATE_ASSISTIVE_DEVICE_REQUEST_SMS_TEMPLATE_WITH_CODE

        2. Else generate SMS text with template CREATE_DEVICE_REQUEST_SMS_TEMPLATE

    2. if device_request has no program specified

      1. if device_request is for assistive device (device_request.code OR at least one classification type of device_request.code_reference is in dictionary configuration “assistive_devices”)

        1. check that ASSISTIVE_DEVICE_REQUESTS_SMS_ENABLED is set in true

          1. else return an error 409 “Action is disabled by the configuration”

        2. generate SMS text with template CREATE_ASSISTIVE_DEVICE_REQUEST_SMS_TEMPLATE_WITHOUT_CODE

      2. else check config parameter DEVICE_REQUESTS_SMS_ENABLED is set in true

        1. else return an error 409 “Action is disabled by the configuration”

        2. generate text SMS with template CREATE_DEVICE_REQUEST_SMS_TEMPLATE_WITHOUT_CODE

  5. Send SMS to a person

 

Response structure

See on Apiary

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" } }

 

Post-processing processes

API paragraph not found

 

HTTP status codes

HTTP status code

Message

What caused the error

HTTP status code

Message

What caused the error

 202

 

 

 

 

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