Table of Contents |
---|
...
Page Properties | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Logic
Get skip_medication_dispense_sign from medical program settings.
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 |
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 |
...
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 (dls_verified=true)
in case of error - return 409 "Division is not verified in DLS".
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 Medical Program
Get medical_program_change_on_dispense_allowed parameter from settings of medical program from medication request:
...
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 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").
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 - deviationIn 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 |
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 |
...