Versions Compared

Key

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

...

If medication dispense has medical program with setting skip_contract_provision_verify = true, than skip contract validation

Else validate there is a contract in PRM.contracts that meets following requirements:

...

  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 "Invalid division dls status"

  4. If chart parameter MEDICAL_PROGRAM_PROVISION_VERIFY, then check division provide each submitted program. For each Medical Program Provision validate following:

    1. If the medical program has no setting skip_contract_provision_verify or it is equal to false/null: 

      1. it is exist and active:

        1. in case of error - return status=INVALID for a program, rejection_reason= "Division does not provide the medical program"

      2. it relates to the actual reimbursement contract: contract.start_date <= current_date <= contract.end_date, is_active = true, status = VERIFIED.

        1. 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"

    2. else if skip_contract_provision_verify = true, then skip provision verification for the medical program

Qualify medication request

...

Validate medication quantity

  1. Get multi_medication_dispense_allowed parameter from medical program settings:

    1. if it is true - check that requested medication quantity less or equal to medication quantity in Medication Request

      1. sum(:medication_qty) <= medication_request.medication_qty

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

    2. if it is false (absent) - check that requested medication quantity equal to medication quantity in Medication Request

      1. medication_qty = medication_request.medication_qty 

        1. in case of error - return 422 "Dispensed medication quantity must be equal to medication quantity in Medication Request"

...

  1. Get reimbursement amount for this medication_id according to medical_program_id

    1. Determine calculation channel (FIXED, EXTERNAL)

    2. Calculate reimbursement amount for the requested quantity of medications:

      1. Get the reimbursement_amount from program_medications.reimbursement.reimbursement_amount (for the package)

      2. Based on it,  package_min_qty and requested medication_qty calculate the ratio and allowed reimbursement amount ((reimbursement_amount/package_qty)*medication_qty)

Service 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 absent in the request.

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

      2.2. Add record to medication_dispenses table:

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

       2.3. Add records to medication_dispense_details table:

Parameter

Source

Description

id

UUID

Autogenerated

medication_dispense_id

FK: medication_dispense

reimbursement_amount

Reimbursement

3. 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.2. Call Process Medication Dispense process, but without validation of digital sign and storage signed content to the bucket.

      3.3. Add records as described on steps 2.2-2.3, but with following differences: 

             medication_dispenses table

Parameter

Source

Description

payment_id

Request: payment_id

optional parameter

payment_amount

Request: payment_amount

required parameter

status

Const: PROCESSED

PROCESSED skip_medication_dispense_sign = true
See: 

Status Charts (reimbursement)