Note |
---|
Сторінка знаходиться в процесі розробки. Інформація на ній може бути застарілою. |
Info |
---|
/wiki/spaces/EN/pages/17591304241 (remove the link block before publishing the document) |
Table of Contents |
---|
Properties of a REST API method document
Page Properties | ||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||||||||||||||||||
|
Purpose
This method is designed to create Medication dispense. The medication dispense is the result of a pharmacy system responding to a medication order.
Key points
Only authenticated and authorized users of legal entity can create Medication dispense.
Can be used both for creating and processing Medication dispense (depending on the requirements of the program).
In order to process dispense payment_id (optional) and payment_amount should be added.
Invoke Qualify Medication request by ID for receiving information about program participants.
Dispense of medication is possible only under Medication request and during the period specified in Medication request.
Several medications from different manufacturers with the same substance can be dispensed at a time.
The total of medication_qty should be less or equal to the medication quantity specified in the Medication request.
Logic
Get skip_medication_dispense_sign from medical program settings.
If skip_medication_dispense_sign = false or absent:
...
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.
...
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 |
Preconditions
Medication Request should be Сreated by MSP
Medication Request should be found and qualified by pharmacist
Configuration parameters
Description of the configuration parameters that are used when processing a request in the system
Dictionaries
Provides a list of links to dictionaries that are available in Confluence
Input parameters
Input parameter | Mandatory | Type | Description | Example | |
---|---|---|---|---|---|
1 | code | O | String | - | 314 |
Request structure
See on API-specification
Expand | ||
---|---|---|
| ||
|
Request data validation
Validate schema
Validate request according to JSON Schema
Check presence of extra parameters
In case of error - return 422 ('schema does not allow additional properties')
Check presence of required parameters
In case of error - return 422 ('required property %{property} was not present')
Check
note
length (optional, nullable) - it must be no longer than 1000 charactersIn case of error - return 422 ('expected value to have a maximum length of 1000 but was {actual length}')
Authorize
Verify the validity of access token
in case of error - return 401 (“Invalid access token”) in case of validation fails
Verify that token is not expired
in case of error - return 401 (“Invalid access token”)
Check user scopes in order to perform this action (scope = 'medication_dispense:write')
return 403 (“Your scope does not allow to access this resource. Missing allowances: medication_dispense:write”) in case of invalid scope(s)
If BLOCK_UNVERIFIED_PARTY_USERS is true, then check party's data match following condition: verification_status != NOT_VERIFIED or (verification_status = NOT_VERIFIED and updated_at <= current_date - UNVERIFIED_PARTY_PERIOD_DAYS_ALLOWED):
in case not match - return 403 ("Access denied. Party is not verified")
Validate Legal entity
Extract client_id from token
Check legal entity status is ACTIVE
In case of error - return 422 ('Legal entity is not active')
Check legal entity type in MEDICATION_DISPENSE_LEGAL_ENTITY_TYPES config parameter
in case of error - return 409 ('Invalid legal entity type')
Validate Division
Division must have active pharmacy license in order to dispense medications
Validate division is exist
in case of error - return 409 ("Division not found")
Validate division is active
in case of error - return 409 ("Division is not active")
Validate division belongs to user's legal entity
in case of error - return 409 ("Division does not belong to user's legal entity")
If chart parameter DISPENSE_DIVISION_DLS_VERIFY is on, then validate division is DLS verified
check that division.dls_verified = true
in case of error - return 409 ('Invalid division dls status')
If chart parameter MEDICAL_PROGRAM_PROVISION_VERIFY, then check division provide each submitted program. For each Medical Program Provision validate following:If the medical program has no settingskip_contract_provision_verifyor it is equal to false/null:it is exist and active:in case of error - return status=INVALID for a program, rejection_reason= "Division does not provide the medical program"
it relates to the actual reimbursement contract: contract.start_date <= current_date <= contract.end_date, is_active = true, status = VERIFIED.in case of error - return status=INVALID for a program, rejection_reason="Medical program provision is not related to any actual contract for the current date"
else ifskip_contract_provision_verify= true, then skip provision verification for the medical program
Get license_types_allowed parameter from settings of medical program from request $.medical_program_id:
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:legal_entity_id = client_id from access token
division_id = division_id from request
status = 'ACTIVE'
licensed_healthcare_service.status = 'ACTIVE'
healthcare_service.license_id is not null and licenses.type = value from license_types_allowed parameter
in case of error - return 409 ('Division must have active licenses to dispense medication request')
Validate Medication request
Check that medication_request_id is exist
in case of error - return 422 ('Medication request not found')
Check intent specified in Medication request equal to order
in case of error - return 409 error ('Medication request with intent PLAN cannot be dispensed')
Сheck that Medication request is_active = true and status == 'ACTIVE'
in case of error - return 409 error ('Medication request is not active')
Check that Medication request not blocked
(medication_requests.is_blocked = false or NULL)medication_requests.is_blocked= false or NULLmedication_requests.blocked_to <= now() (datetime) or NULL
in case of error - return 409 error ('Medication request is blocked')
Check that dispense date is in period specified in Medication request (dispense_valid_from >= current_date() and dispense_valid_to <= current_date())
in case of error - return 409 error ('Invalid dispense period')
Check if medication_request.based_on is present and not null AND medication_program is absent:
Verify Care plan:
It should be in active status
in case of error - return 409 (message: "Invalid care plan status")
Care plan's period.end (if exist) should be greater than current date or equal.
in case of error - return 409 (message: “Care plan expired“)
Verify care plan Activity:
It has scheduled, in_progress status
in case of error - return 409 (message: "Invalid activity status")
Qualify Medication request
Check that medication request is valid and available for dispense
Invoke Qualify method
Get medical_program_id from request, check that medical_program_id from request equals to medication_requests.medical_program_id
if true, use medication_requests.medical_program_id as program for qualify
if false, use medical_program_id from request as program for qualify
Check that program_medication_id is in Qualify response
Medication request is prohibited for dispense in case $.data[?(@.program_id=medication_requests.medical_program_id)].status = 'INVALID' or program_medication_id is absent in qualify response
In case of error - return 409 error ('Medication request can not be dispensed. Invoke qualify medication request API to get detailed info')
Medication request is allowed for dispense in case $.data[?(@.program_id=medication_requests.medical_program_id)].status = 'VALID' and program_medication_id is present in qualify response
Validate Medical program
Check that medical_program_id is exist
in case of error - return 422 ('Medical program not found')
Сheck that medical_program_id is_active = true and status == 'ACTIVE'
in case of error - return 422 error ('Medication request is not active')
Check if medical program has setting medical_program_change_on_dispense_allowed parameter from settings of medical program from medication request:
if it is false (absent), medical program in dispense must be the same as medical program in medication request (request.medical_program_id = medication_requests.medical_program_id)
in case of error - return 409 ('Medical program in dispense doesn't match the one in medication request')
Check if medical program has setting skip_contract_provision_verify = true, than skip contract validation
Else validate there is a contract in PRM.contracts that meets following requirements:
contracts.type==reimbursement
contracts.status==VERIFIED
Contract dates: start_date <= current_date & end_date >= current_date
contracts.contractor_legal_entity_id=token.client_id
$division_id in contract_divisionscontracts.medical_program_id==$.medical_program_id
сontracts.is_suspended == false
in case of error - return 409 ('Program cannot be used - no active contract exists')
Validate Code
Check that code in request is equal to code in medication_request
In case code exists in request - it should match with code in medication_request
in case of error - return 403 (message: “Incorrect code“)
Validate Medication dispenses
Check all connected medication dispenses:
there isn't medictaion dispenses with the 'NEW' status
in case of error - return 422 "Medication dispense in status NEW already exist."
Validate Dispense details
Check that medical_program_id is exist and active
Check that medication exists and is active
medications.is_active = true
medications.type is ‘BRAND' or ‘INNM_DOSAGE'
if medications.type = 'BRAND'
ingredients.medication_child_id = medication_request.medication_id and ingredients.is_primary = true
if medications.type = 'INNM_DOSAGE'
dispense_details.medication_id = medication_request.medication_id
check dispensed_at
if funding_source = "NHS" then dispensed_at = date.now()
in case of error - return 422 ('For Medical program with funding_source = "%{funding_source}" medication dispense dispensed_at must be equal to current date')
else if funding_source != "NHS" then dispensed_at <= date.now()
in case of error - return 422 ('For Medical program with funding_source = "%{funding_source}" medication dispense dispensed_at must be equal to or less than current date')
Validate Medication quantity
Get multi_medication_dispense_allowed parameter from medical program settings:
if it is true - check that requested medication quantity less or equal to available medication quantity in Medication Request (the way how to calculate available medication quantity is following:
available_qty = medication_request.medication_qty - used_qty,
where used_qty is the sum of medication_qty from medication_dispenses with medication_request_id = $.medication_request_id)medication_qty <= available_qty
in case of error - return 422 ('Dispensed medication quantity must be lower or equal to medication quantity in Medication Request. Available quantity is #{available_qty}')
if it is false (absent) - check that requested medication quantity equal to medication quantity in Medication Request
medication_qty = medication_request.medication_qty
in case of error - return 422 ('Dispensed medication quantity must be equal to medication quantity in Medication Request')
Validate Program medication
In case medications are dispensed to patient under specific medical program, program medication id must be provided provided by client or calculated by the system
...
Get last program_medication_id related to medical program and medication
in case of error - return 422 ('There are no active program medications for this program and medication')
Validate Medication multiplicity
This validation must be done only in case when medication dispensed to patient as brand. In case of extemporaneous medications this validation must be skipped
Check that requested medication quantity in dispense for all medications is multiplier of package_min_qty for this medications.id
Mod($medication_qty, medications.package_min_qty) = 0
in case of error (if at least one of medication don't pass verification) - return 422 error ('Requested medication brand quantity is not a multiplier of package minimal quantity')
Validate Medication discount amount
Define reimbursement_type (get from program_medications by program_medication_id).
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)
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 reimbursement_amount from program_medications):
There are two different formulas depending on medication type to be dispensedIf medication.type = ‘BRAND’:
discount_amount <= reimbursement_amount * (medication_qty/package_qty)
If medication.type = ‘INNM_DOSAGE’:
discount_amount <= reimbursement_amount * medication_qty
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 reimbursement_amount from program_medications):
There are two different formulas depending on medication type to be dispensedIf medication.type = ‘BRAND’:
discount_amount/ (reimbursement_amount * (medication_qty/package_qty)) >= 1 - deviation
If medication.type = ‘INNM_DOSAGE’:
discount_amount/ (reimbursement_amount * medication_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
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')
Processing
A list of processes related to receiving, changing or transmitting data according to the logic defined in the REST API
Response structure examples
See on API-specification
Expand | ||
---|---|---|
| ||
|
HTTP status codes
Response code | HTTP Status code | Message | Internal name | Description | |
---|---|---|---|---|---|
1 | Базові | ||||
2 | 401 | Invalid access token | Недійсний токен доступу | ||
3 | 403 | Your scope does not allow to access this resource. Missing allowances: medication_dispense:write | Для вашої ролі відсутній доступ до цього ресурсу. Необхідний доступ на створення запиту на відпуск рецепта | ||
4 | 403 | Access denied. Party is not verified | Доступ заборонено. Працівник не перевірений | ||
5 | 403 | Incorrect code | Некоректний код | ||
6 | 409 | Invalid legal entity type | Недопустимий тип юридичної особи | ||
7 | 409 | Division not found | Відділення юридичної особи не знайдено | ||
8 | 409 | Division is not active | Структурний підрозділ не активний | ||
9 | 409 | Division does not belong to user's legal entit | Структурний підрозділ не належить юридичній особі користувача | ||
10 | 409 | Invalid division dls status | Недійсний статус підрозділу у ліцензійному реєстрі ДержЛікСліжби | ||
11 | 409 | Division must have active licenses to dispense medication request | Підрозділ повинен мати активні ліцензії для погашення електронного рецепту | ||
12 | 409 | Medication request with intent PLAN cannot be dispensed | Рецепт з типом "План лікування" не може бути погашений | ||
13 | 409 | Medication request is not active | Рецепт не активний | ||
14 | 409 | Medication request is blocked | Рецепт заблоковано | ||
15 | 409 | Invalid dispense period | Недійсний період погашення рецепта | ||
16 | 409 | Invalid care plan status | Невірний статус плану лікування | ||
17 | 409 | Care plan expired | Закінчився термін дії плану лікування | ||
18 | 409 | Invalid activity status | Недопустимий статус призначення | ||
19 | 409 | Medication request can not be dispensed. Invoke qualify medication request API to get detailed info | Рецепт не може бути погашений. Перевірьте його відповідність програмі реімбурсації для отримання більшої інформації | ||
20 | 409 | Medical program in dispense doesn't match the one in medication request | Програма реімбурсації при погашенні рецепту не співпадає з програмою у виписаному рецепті | ||
21 | 409 | Program cannot be used - no active contract exists | Програма реімбурсації не може бути використана - немає активного договору з НСЗУ | ||
22 | Специфічні | ||||
23 | 422 | schema does not allow additional properties | схема не допускає додаткових властивостей | ||
24 | 422 | required property %{property} was not present | Обов'язкові поля %{property} не вказані | ||
25 | 422 | expected value to have a maximum length of 1000 but was {actual length} | Максимальна кількість символів: 1000 | ||
26 | 422 | Legal entity is not active | Юридична особа не активна | ||
27 | 422 | Medication request not found | Рецепт не знайдено | ||
28 | 422 | Medical program not found | Програма реімбурсації не знайдена | ||
29 | 422 | Medication request is not active | Рецепт не активний | ||
30 | 422 | Medication dispense in status NEW already exist | Заявка на погашення рецепта у статусі НОВИЙ вже існує | ||
31 | 422 | For Medical program with funding_source = "%{funding_source}" medication dispense dispensed_at must be equal to current date | Для медичної програми з джерелом фінансування = "%{funding_source}" dispensed_at погашення рецепта має бути рівною поточній даті | ||
32 | 422 | For Medical program with funding_source = "%{funding_source}" medication dispense dispensed_at must be equal to or less than current date | Для медичної програми з джерелом фінансування = "%{funding_source}" dispensed_at погашення рецепта має бути рівною або меншою поточної дати | ||
33 | 422 | Dispensed medication quantity must be lower or equal to medication quantity in Medication Request. Available quantity is #{available_qty} | Відпущена кількість лікарського засобу має бути меншою або дорівнювати кількості лікарського засобу, зазначеній в рецепті. Доступна кількість така: #{available_qty | ||
34 | 422 | Dispensed medication quantity must be equal to medication quantity in Medication Request | Вказана при погашенні кількість лікарського засобу повинна дорінювати кількості у рецепті | ||
35 | 422 | Invalid program medication id | Недійсний ідентифікатор учасника медичної програми | ||
36 | 422 | There are no active program medications for this program and medication | Для цієї програми та лікарського засобу немає активного учасника медичної програми | ||
37 | 422 | Requested medication brand quantity is not a multiplier of package minimal quantity | Запитувана кількість лікарського засобу даного торгового найменування не кратна мінімальній кількості лікарського засобу в первинній упаковці до продажу даного торгового найменування | ||
38 | 422 | Requested discount price must be equal to 0 | Запитуваний Розмір знижки має дорівнювати 0 | ||
39 | 422 | The ratio of requested discount price to allowed reimbursement amount must be greater or equal to <1 - deviation> | Співвідношення між запитуваною знижкою і дозволеною в реєстрі вартістю відшкодування повинна бути більше або дорівнювати <1 - DEVICE_DISPENSE_DEVIATION> | ||
40 | 422 | Expected a minimum of %{min} items but got %{actual | Очікується вказання мінімум %{min} обов'язкових параметрів, але отримано %{actual} | ||
41 | 422 | Not allowed to save empty 2d code | Заборонено зберігати порожній двовимірний код |
Post-processing processes
No
Technical modules where the method is used
Page Properties Report | ||||
---|---|---|---|---|
|
...