Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Reverted from v. 2

...

  • Check device (device definition) to be dispensed ($.dispense_details.device)

    • Check code ($.dispense_details.device.identifier.type.coding.code) = device_definition

      • in case of error - return 422 ('Only device definition is allowed for dispense')

    • Get device definition by id ($.dispense_details.device.identifier.value)

      • device_definition.is_active = true

        • in case of error - return 422 ('Device definition not found')

    • Check that this device definition is compliant with prescribed device

      • If device_request.code is of type Reference

        • Check that device_definition_id in dispense is equal to device_definition_id in request

      • If device_request.code is of type CodeableConcept

        • Check that device_definition.classification_type is equal to prescribed device definition code in device request (device_request.code)

      • in case of error - return 422 ('Dispensed device doesn’t match with prescribed device')

    • Check that packaging_unit matches with quantity.code of the Device Request

      • in case of error - return 422 (Dispensed packaging unit doesn’t match with prescribed packaging unit)

    • Check the remainder of the division ($.device_request.quantity.value/device_definition.packaging_count) is equal to 0

      • in case of error - return reject_reason = “The quantity must be divisible to packaging_count of prescribed Device Definition”

Validate program device

  • Check program device

    • Is applicable only if program was passed to request and program device passed to request

      • Check code ($.dispense_details.program_device.identifier.type.coding.code) = program_device

        • in case of error - return 422 ('Invalid code. Expected 'program_device'')

      • Check that program device is active

      • Check that program device has validity period (start_date and end_date) within current date

        • in case of error - return 422 ('Program device is not active')

      • Check that max daily count is not exceeded - max_daily_count is null or max_daily_count >= quantity.value/(occurence_period.end - occurence_period.start) of the Device Request

        • in case of error - return 422 ('max daily count exceeded')

      • Check that program device relates to the device definition in $.dispense_details.device

        • in case of error - return 422 ('Program device doesn’t match with device')

      • Check that program device relates to the program in $.program

        • in case of error - return 422 ('Program device doesn’t match with program')

    • if program was passed to request and no program device specified

      • find program device related to dispensed device definition and selected program

        • find active records

        • find program devices where validity period (start_date and end_date) within current date

          • if no records found - return 422 ('No active program devices under this program')

        • Check that max daily count is not exceeded - max_daily_count is null or max_daily_count >= quantity.value/(occurence_period.end - occurence_period.start) of the Device Request

          • in case of error - return 422 ('max daily count exceeded')

...