...
Check there is at least one appropriate Device Definition for a program:
Find program_devices related to the program, that:
is active
has validity period (start_date and end_date) within current date
has max_daily_count is null or max_daily_count >= quantity.value/(occurence_period.end - occurence_period.start) of the Device Request
in case not found - return reject_reason = “No appropriate participants found for this medical program“
For found program_devices check there at least one appropriate Device Definition, that:
is active
has the same code as in the Device Request
has packaging_unit that matches to quantity.code of the Device Request
in case of error - return reject_reason = “Not found any active Device Definition with the same units of measure as pointed in the quantity of the Device Request”
has a remainder of the division ($.device_request.quantity.value/device_definition.packaging_count) that is equal to 0
in case of error - return reject_reason = “The quantity in the Device Request must be divisible to packaging_count of at least one related Device Definition”
...