Table of Contents |
---|
Page Properties | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Purpose
This WS is designed to deactivate medication by ID (post).
APIary
Input parameters
- id
Authorize
- Verify the validity of access token
- Check user scope (scope = 'medication:write') in order to perform this action
- In case error - generate 401 response
Validate PK Medication
Purpose validation: Check on existing Medication record
Check exist Medication by $.id.
if invalid - return 404 error (message: "Medication is not found!")
Validate status
Purpose validation: Medication should be active (is_active == TRUE)
- Validate `is_active` == TRUE
- if invalid - return 409 eror (message: "Medication should be active !")
Validate status linked Medications
Purpose validation: For INNM - all linked (child) Medications should be inactive (is_active == FALSE)
- Get linked medications, check exist active medications
- if invalid - return 409 eror (message: "All linked medication should be inactive !")
Code Block | ||
---|---|---|
| ||
IF EXIST (
SELECT * FROM medications M
WHERE M.type = MEDICATIONS
AND (M.ingridients.id = $.id AND M.ingridients.is_active_substance)
) |
Update medication
Update medication record by $.id set values:
Destination | Source |
---|---|
is_active | FALSE |
inserted_at | :timestamp |
inserted_by | user_id |
updated_at | :timestamp |
updated_by | user_id |
Prepare & return response data structure
- Fill response WS data structure
- Validate response using JSON schemas (!!! TBD)
- Return 422 with list of validation errors in case validation fails (422 EView)