Purpose

This method is designed to process previously created Medication dispense.

...

Page Properties

Link

https://ehealthmisapi1.docs.apiary.io/#reference/public.-reimbursement/medication-dispense/process-medication-dispense-by-pharmacy-user

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

Resource

/api/pharmacy/medication_dispenses/{{id}}/actions/process

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

Scope

medication_dispense:process

Scope для доступу

Components

ePrescription

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

Microservices

API paragraph not found

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

Protocol type

REST

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

Request type

PATCH

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

Sync/Async

Sync

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

Logic

  1. Save signed content to media storage.

  2. Update Medication dispense data in OPS DB:

    1. set status  =  ‘PROCESSED’

    2. updated_by = user_id

    3. updated_at = now()

  3. Update related Medication request data in OPS DB:

    1. set status  =  ‘COMPLETED’

    2. updated_by = user_id

    3. updated_at = now()

  4. Write changes to event manager (Medication dispense and Medication request).

  5. Change Care plan activity (If related medication request has reference on Care plan, then corresponding care plan activity should be changed in async way after Medication dispense processed. Update activity events invokes using ops.medication_dispense_process table):

    1. Set activity status to in_progress if previous activity status was scheduled.

    2. Check the MD identifier in outcome_reference attribute of the activity:

      1. if not found:

        1. Add reference on the medication dispense resource to the outcome_reference attribute .

        2. If quantity in the activity was set then calculate and set remaining quantity:

          1. select all MD in status PROCESSED related to MR which based on care plan and current activity;

          2. calculate dispensed quantity in the current activity as sum of medication_qty in the filtered MD list;

          3. calculate remaining quantity by subtracting dispensed quantity from activity quantity;

          4. update remaining_quantity value in the activity with calculated value.

      2. If found, then skip updating activity (it means that activity has been already updated by event from current MD processing).

...

  • Validate request is signed

    • in case of error - return 400 (“document must be signed by 1 signer but contains 0 signatures”).

  • Validate that DS is valid and not expired.

  • Validate that DS belongs to the user

    • Check that DRFO from DS and party.tax_id matches

      • in case of error - return 422 (“Does not match the signer drfo“).

    • Check that Last Name from DS and party.last_name matches

      • in case of error - return 422 (“Does not match the signer last name“).

Validate Medication dispense

...

  1. Check that signed content is equal to online generated dispense with ids in DB:

    1. Do not compare:

      • payment_amount field;

      • payment_id field;

      • medication_request/legal_entity object;

      • medication_request/division object;

      • medication_request/employee object;

      • medication_request/person/id field;

      • medication_request/rejected_at field;

      • medication_request/rejected_by field;

        • in case error return 422 ("Signed content does not match to previously created dispense").

...

Validate related Medication request

  1. Medication request should be active in order to process medication dispense

    1. is_active = true

    2. status = 'ACTIVE'

      1. In case error - return 409 ("Medication request is not active").

  2. Medication request should not be blocked in order to process medication dispense

    1. is_blocked <> true

      1. In case error - return 409 ("Medication request is blocked").

Check if related medication request has reference on the Care plan - based_on attribute filled. If it has, validate following:

...