...

  • Validate sell_price

    • Check it is present if medical program is present and has funding_source = "NHS"

      • in case of error - return 422 ('Required property sell_price was not present')

  • Validate sell_amount

    • Check it is present if $.sell_price has been set

      • in case of error - return 422 ('Required property sell_amount was not present')

    • Check that $.sell_amount = $.sell_price * $.dispense_details.quantity.value + DEVICE_DISPENSE_TOLERANCE

      • in case of error - return 422 ('Sell amount doesn’t comply with quantity and sell price')

    Validate discount_amount

    • Check it is present if medical program is present and has funding_source = "NHS"

      • in case of error - return 422 ('Required property discount_amount was not present')

    • Check it is absent if medical program is absent

      • in case of error - return 422 ('Property discount_amount shouldn’t be submitted if medical program is absent')

    • Calculate allowed reimbursement amount:

      • If reimbursement_type of program_device is PERCENTAGE:

        • If reimbursement_percentage_discount of program_device is zero, then check $.discount_amount is equal to zero too

          • in case of error - return 422 ('Requested discount amount must be equal to 0')

        • Calculate allowed_reimbursement_amount = $.sell_price * program_device.reimbursement_percentage_discount/100

      • If reimbursement_type of program_device is FIXED:

        • Get allowed_reimbursement_amount = program_device.reimbursement_amount

    • Check $.discount_amount <= allowed_reimbursement_amount * ($.dispense_details.quantity.value/device_definition.packaging_count) + DEVICE_DISPENSE_TOLERANCE

      • in case of error - return 422 ('Requested discount amount must be less or equal to allowed reimbursement amount')

    • Check the ratio of discount amount to reimbursement amount as $.discount_amount/ (allowed_reimbursement_amount * ($.dispense_details.quantity.value/device_definition.packaging_count)) >= 1 - DEVICE_DISPENSE_DEVIATION

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

...