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

RС_[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.

Specification

Apiary

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.

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

Authorization

  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)

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 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%')

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

  4. 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" 

Processing

  1. Get person's authentication_method of MPI

  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. Call SMS timeout procedure to check if resending is allowed using:
    - DEVICE_REQUEST_MAX_ATTEMPTS_COUNT as MAX_ATTEMPTS_COUNT
    - DEVICE_REQUEST_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 has no program specified

      1. check config parameter DEVICE_REQUESTS_SMS_ENABLED is set in true

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

  5. Send SMS to a person

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