Table of Contents |
---|
...
Page Properties | |||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||||||||||
|
Logic
Fill in the following fields:
status = IN_PROGRESS
status_reason = null
subject. Set hashed patient_id from URL
performer_legal_entity. Set client_id from token
quantity.unit. Set description according to quantity code and system
inserted_at. Set current date and time
updated_at. Set current date and time
inserted_by. Set current user from token
updated_by. Set current user from token
Save data to device_dispenses collection in MongoDB according to /wiki/spaces/CSI/pages/17467572335
Send
StatusChangeEvent
to Event Manager
...
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 ('Only device request with intent = 'order' can be dispensed')
Сheck that Device request is in status 'ACTIVE'
in case of error - return 409 422 error ('Device request is not active')
Check that dispense_valid_to is greater or equal to current date
in case of error - return 409 ('Device request is expired for dispense')
...
Check that program in dispense is the same as program in device request (request.program.identifier.value = device_requests.program.identifier.value)
in case of error - return 409 422 ('"Program in dispense doesn't match the one in device from request 'params")
Qualify Device request
This validation must be done only if medical_program exists in request and medical_program is the same as in device request
...
Check that there is no other
IN_PROGRESS
device dispenses based on the same device requestFind all device dispenses related to the same device request ($.based_on)
Check that there are no records in status
in-progress
whereinserted_at
+ configdevice_dispense_ttl
>= current date-time()in case of error - return 422 "Other active device dispense dispenses already exist."
Validate Dispense details
...