Table of Contents |
---|
...
- name
- form
- ingredients (array)
- id
- dosage info
- is_aprimary
Authorize
- Verify the validity of access token
- Check user scope (scope = 'innm_dosage:write') in order to perform this action
- In case error - generate 401 response
...
Invoke GetInnmByID($.ingredients[].id). Check exist any innm.is_active=FALSE.
if exists - return 422 error (message: "Innm in ingredients must be active!")
...
Calc count() where is_primary=TRUE in ingredients. Check count()=1.
if invalid - return 422 error (message: "One of ingredients must be primary!")
...
- Create new record in Medications
- Fill data
Destination | Source |
---|---|
id | |
name | $.name |
type | INNM Dosage |
is_primary | 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 |
Create new Ingredients
- Save `id` of new Medication into var `med_id`
- Create new record in Ingredients from $.ingredients
- Delete all Ingredients where parent_id =
- Fill data (where `Ing` = $.ingredients)
Destination | Source |
---|---|
id | |
dosage | Ing.dosage |
parent_id | med_id |
innm_id | Ing.innm_id |
medication_id | NULL |
is_primary | Ing.is_primary |
inserted_at | :timestamp |
inserted_by | user_id |
updated_at | :timestamp |
updated_by | user_id |