Status
- Specification

- Apiary

- JSON schema request

- JSON schema response

Purpose
This WS is designed to update substance (post).
APIary
update-substance
Input parameters
- id
- name
- name_original
- sctid
is_active
Authorize
- Verify the validity of access token
- Check user scope (scope = 'substance:write') in order to perform this action
- In case error - generate 401 response
Validate request (JSON schema)
Validate request using JSON schema (link !!! TBD)
Check existing substance
- Check exist substance by if $.id in payload
- if found - return 409 error (message: "Substance does not exist!")
Validate statuses linked medication
Purpose validation: Status innm must be equal to statuses linked medication.
- Get `is_active` medications (linked with substance) in the opposite $.is_active in payload
IF EXISTS(
SELECT * FROM medications M
WHERE M.type == INNM
AND M.ingridients.id = $.id
AND M.is_active != $.is_active
) |
- if found - return 409 error (message: "Status innm must be equal to statuses linked medications!")
Update substance data
- Update substance data according to payload parameters.
Return data structure: