Versions Compared

Key

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

...

Page Properties

Link

https://ehealthmisapi1.docs.apiary.io/#reference/public.-reimbursement/medication-dispense/create-medication-dispense

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

Resource

/api/medication_dispenses

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

Scope

medication_dispense:write

Scope для доступу

Components

ePrescription

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

Microservices

API paragraph not found

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

Protocol type

REST

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

Request type

POST

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

Sync/Async

Sync

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

Logic

  1. Get skip_medication_dispense_sign from medical program settings.

  2. If skip_medication_dispense_sign = false or absent:

          2.1. Check payment_id, payment_amount is present in the request.

in case if absent - return 422 with path: $.<field_name>  and message "schema does not allow additional properties"

          2.2. Add record to medication_dispenses table:

...

          2.4. Add records to medication_2d_codes table (for each 2d code object in array):

...

Parameter

...

Source

...

Parameter

Source

Description

id

UUID

Autogenerated

medication_dispense_id

FK: medication_dispense

 

medication_2d_code

Request: medication_2d_codes

 

inserted_at

Timestamp: now()

Get current date-time

  1. If skip_medication_dispense_sign =

true:

             3.1. Check if payment_amount in the request.

  • in case is absent - return 422 with path: $.payment_amount and message "required property payment_amount was not present"

             3.1. Call Process Medication Dispense by Pharmacy User process, but without validation of the previously created (NEW) medication dispense, digital sign and storage signed content to the bucket.

...

             medication_dispenses table

...

Parameter

...

Source

...

Parameter

Source

Description

payment_id

Request: payment_id

optional parameter

payment_amount

Request: payment_amount

optional parameter

status

Const: PROCESSED

PROCESSED skip_medication_dispense_sign = true
See: Medication dispense status model

...

  1. Validate division is active

    1. in case of error - return 409 ("Division is not active").

  2. Validate division belongs to user's legal entity

    1. in case of error - return 409 ("Division does not belong to user's legal entity").

  3. If chart parameter DISPENSE_DIVISION_DLS_VERIFY is on, then validate division is DLS verified (dls_verified=true)

    1. in case of error - return 409 "Division is not verified in DLS".

  4. Get license_types_allowed parameter from settings of medical program from request $.medical_program_id:

    1. if it is exists and not empty, get list of all license types from parameter.
      Check that division has active healthcare services with following parameters:

      1. legal_entity_id = client_id from access token

      2. division_id = division_id from request

      3. status = 'ACTIVE'

      4. licensed_healthcare_service.status = 'ACTIVE'

      5. healthcare_service.license_id is not null and licenses.type = value from license_types_allowed parameter

        1. in case of error - return 409 ('Division must have active licenses to dispense medication request').

Validate Medical Program

Get medical_program_change_on_dispense_allowed parameter from settings of medical program from medication request:

...

  1. Define reimbursement_type (get from program_medications by program_medication_id).

  2. Validate percentage discount price.
    Check if reimbursement_type == percentage and percentage_reimbursement_amount = 0
    (the way how to calculate percentage_reimbursement_amount is following:
    percentage_reimbursement_amount = sell_price (from request) * percentage_discount (from program_medications) /100)

    • In case if discount_amount != 0 - return 422 ("Requested discount price must be equal to 0")

    • Else (if discount_amount = 0)  - finish validation (do not validate 3, 4).

  3. Validate allowed reimbursement amount.
    Check that requested discount price is less or equal to allowed reimbursement amount for the requested medication quantity
    (the way how to calculate allowed reimbursement amount is below.
    for type == percentage use percentage_reimbursement_amount, for fixed = use reimbusement_amount from program_medications):
           discount_amount <= reimbursement_amount * (medication_qty/package_qty)

    • In case of error - return 422 ("Requested discount price must be less or equal to allowed reimbursement amount").

  4. Validate the ratio of discount price to reimbursement amount.
    Check that the ratio of requested discount price to allowed reimbursement amount is more or equal to allowed rule (including deviation) for the requested medication quantity
    (the way how to calculate allowed reimbursement amount is below.
    for type = percentage use percentage_reimbursement_amount, for fixed - use reimbusement_amount from program_medications):
           discount_amount/ (reimbursement_amount * (medication_qty/package_qty)) >= 1 - deviation

    • In case of error - return 422 ("The ratio of requested discount price to allowed reimbursement amount must be greater or equal to <1 - deviation>").

Validate 2d codes

Important: This validation must be done only if medication_2d_codes field exists in request.

  • Check that medication_2d_codes array contains at least one element (array is not empty)

    • in case of error - return 422 ('Expected a minimum of %{min} items but got %{actual}').

  • For all objects in array check that string 'medication_2d_code' is not null or empty

    • in case of error - return 422 ('Not allowed to save empty 2d code').

Get reimbursement amount

There are two types of calculation of reimbursement amount:

...

          2.2. Add record to medication_dispenses table:

...

Parameter

...

Source

...

Parameter

Source

Description

id

UUID

Autogenerated

payment_id

NULL

NULL for new records

payment_amount

NULL

NULL for new records.

status

Const: NEW

NEW skip_medication_dispense_sign = false

See: Status Charts (Reimbursement)

is_active

Const: TRUE

Alwayls TRUE for new records

inserted_at

Timestamp: now()

Get current date-time

inserted_by

Token: user_id

Extract user from token

updated_at

Timestamp: now()

Get current date-time

updated_by

Token: user_id

Extract user from token

...