Table of Contents |
---|
...
Page Properties | |||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||||||||||
|
Logic
Save signed content to media storage, in bucket pointed in MEDIA_STORAGE_DEVICE_REQUEST_BUCKET chart parameter
Fill in the following fields:
requisition. Generate requisition number as described at Human readable Medication request number, but based on the Device Request identifier and put it in the field.
signed_content_links. Add string item in the array with a link on saved content in media storage
status = ACTIVE
status_reason = null
subject. Set hashed patient_id from URL
requester_legal_entity. Set client_id from token
quantity.unit. Set description according to quantity code and system
dispense_valid_to. dispense_valid_to. Set (current_date + dispense_period_day) if medical program was set and it has dispense_period_day setting. Otherwise, if medical program was set and it has NO dispense_period_day setting, set the value using device_dispense_period global parameter. Else, if medical program was NOT set dispense_valid_to = null.
Save dispense_valid_to as
datetime
but truncate time to beginning of date (2013-08-02T00:00:00Z
)
verification_code. Generate random 4-digit code if medical program was set
context_episode_id. Set episode from the $.encounter
context_care_plan_id.Get Activity from $.based_on, set activity.care_plan as context_care_plan_idbased_on. Set based_on from the $.based_on
priority. Set priority from the $.priority
parameter. Set parameter from the $.parameter
performer. Set performer from the $.performer
supporting_info. Set supporting_info from the $.supporting_info
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
Send notification to patient:
Determine patient's default authentication method as described at Determination of a default authentication method and return person's active auth_methods
Get program from request and (if provided) get program setting
request_notification_disabled
:if program provided and
request_notification_disabled
== true:do not send SMS notification to patient
if program provided and
request_notification_disabled
== false and OTP defined on patient:generate text according to CREATE_DEVICE_REQUEST_SMS_TEMPLATE and send SMS with verification_code
if program not provided and OTP defined on patient:
check config parameter
DEVICE_REQUESTS_SMS_ENABLED
is set to truegenerate text according to CREATE_DEVICE_REQUEST_SMS_TEMPLATE_WITHOUT_CODE and send SMS without verification_code
Save data to device_requests collection in MongoDB according to https://e-health-ua.atlassian.net/wiki/spaces/EH/pages/17782014841
If device request is based on activity - recalculate and set remaining_quantity for the activity
select all device requests based on current activity and calculate previously reserved quantity as sum of DR.quantity.value.
calculate reserved at the moment quantity as sum of previously reserved quantity and quantity from current DR
calculate remaining quantity by subtracting reserved at the moment quantity from activity's quantity
Update activity set remaining quantity (activity.detail.remaining_quantity)
Send
StatusChangeEvent
to Event Manage
...
Skip the following validation in case madical_program is not specified in the request
Note |
---|
|
Validate quantity
Info |
---|
If medical program is not specified in request then quantity is optional here |
...
Execute validation as described here…
Validate Medical program
...