...
Only authenticated and authorized users with appropriate scope can invoke Create Device Dispense
Device Dispense is created in async way. Successful result of the job should return a link on the created Device Dispense (look at /wiki/spaces/CSI/pages/17467506869 ).
Device Dispense can be created only under active Device Request within valid dispense period
Several devices of different manufacturers with the same code can be dispensed at a time
Multiple dispenses to the same Device Request is not allowed
It is allowed to create Device Dispense for not active or not verified persons (for the same reasons as in the medication reimbursement process)
Specification
...
Extract client_id from token
Check legal entity exists and its status is ACTIVE
In case of error - return 409 ('client_id refers to legal entity that is not active')
Validate Patient
Get Patient identifier from the URL
Check it exists in persons table (MPI)
Return 404 ('not found') in case of error
Validate person status is active
in case of error - return 409 ('Patient is not active')
in case NOT_VERIFIED - return error 409 ("Patient is not verified")
Validate dispense
Validate performer
...
Validate value in the field $.location, Reference on employee division resource, required.
Check that division exists
in case of error - return 409 ("Division not found")
Check that division is active
in case of error - return 409 ("Division is not active")
Validate division belongs to user's legal entity (client_id from token)
in case of error - return 409 ("Division does not belong to user's legal entity")
If chart parameter DEVICE_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"
...
Check that device request exists
in case of error - return 422 ('Device request not found')
Check that intent specified in Device request is
order
in case of error - return 409 error ('Device Only device request with intent PLAN cannot = 'order' can be dispensed')
Сheck that Device request is in status 'ACTIVE'
in case of error - return 409 error ('Device request is not active')
...