Table of Contents |
---|
...
- name
- form
- ingredients (array)
- id
- dosage info
- is_active_substance
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
...
For Check exist `Substance` by $.ingredients[].id.
if invalid - return 422 error (message: "Substance in ingredients is not found!")
Validate status
...
Purpose validation: Id's in ingredients must be active
Invoke GetSubstanceByID($.ingredients[].id). Check exist any substance.is_active=FALSE.
if exists - return 422 error (message: "Substance in ingredients must be active!")
Validate status ingredients.is_active_substance
Purpose validation: in ingredients only one item must be is active substance (TRUE)
Calc count() where is_active_substance=TRUE in ingredients. Check count()=1.
if invalid - return 422 error (message: "One of ingredients must be is active substance!")
Create new Medication
- Create new record in Medications
- Fill data
Destination | Source |
---|---|
id | |
name | $.name |
type | INNM |
is_active | TRUE |
form | $.form |
ingredients | $.ingredients |
container | NULL |
package_qty | NULL |
package_min_qty | NULL |
code_atc | NULL |
manufacturer | NULL |
certificate | NULL |
expired_certificate_at | NULL |
inserted_at | :timestamp |
inserted_by | user_id |
updated_at | :timestamp |
updated_by | user_id |
Prepare & return response data structure
...