Versions Compared

Key

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

...

Page Properties
idAPI_Specification

Link

https://ehealthmedicaleventsapi.docs.apiary.io/#reference/device-requests/create-device-request/create-device-request

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

Resource

/api/patients/{{patient_id}}/device_requests

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

Scope

device_request:write

Scope для доступу

Components

Devices

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

Microservices

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

Protocol type

REST

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

Request type

POST

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

Sync/Async

Async

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

Public/Private/Internal

Public

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

Logic

  1. Save signed content to media storage, in bucket pointed in MEDIA_STORAGE_DEVICE_REQUEST_BUCKET chart parameter

  2. Fill in the following fields:

    1. requisition. Generate requisition number as described at Human readable Medication request number , but based on the Device Request identifier and put it in the field.

    2. signed_content_links. Add string item in the array with a link on saved content in media storage

    3. status = ACTIVE

    4. status_reason = null

    5. subject. Set hashed patient_id from URL

    6. requester_legal_entity. Set client_id from token

    7. quantity.unit. Set description according to quantity code and system

    8. dispense_valid_to. Set (current_date + dispense_period_day) if medical program was set and it has dispense_period_day setting. Otherwise, set the value using device_dispense_period global parameter.

    9. verification_code. Generate random 4-digit code

    10. context_episode_id. Set episode from the $.encounter

    11. inserted_at. Set current date and time

    12. updated_at. Set current date and time

    13. inserted_by. Set current user from token

    14. updated_by. Set current user from token

  3. Send verification code:

    1. Determine patient's default authentication method as described at Determination of a default authentication method and return person's active auth_methods :

      1. if OTP defined, then generate text according to TEMPLATE_SMS_FOR_CREATE_DEVICE_REQUEST and send SMS with verification_code

  4. Save data to device_requests collection in MongoDB according to /wiki/spaces/CSI/pages/17467375685

  5. Send StatusChangeEvent to Event Manager

...

  1. Validate $.status is active

    1. in case of error - return 422 ("value is not allowed in enum")

Processing

...

Response structure

See on Apiary

...

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

Post-processing processes

...

HTTP status codes

Page Properties
idAPI_HTTP status codes

HTTP status code

Message

What caused the error

 202

 

 

...