Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

...

  • name
  • form
  • ingredients (array)

Authorize

  1. Verify the validity of access token
  2. Check user scope (scope = 'medication:write') in order to perform this action
    1. In case error - generate 401 response

...

  1. For Check exist `Substance` by $.ingredients[].id.

    1. if invalid - return 422 error (message: "Substance in ingredients is not found!")

Validate status

...

Purpose validation: Id's in ingredients must be active  

  1. Invoke GetSubstanceByID($.ingredients[].id). Check exist any substance.is_active=FALSE.

    1. 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)  

  1. Calc count() where is_active_substance=TRUE in ingredients. Check count()=1.

    1. if invalid - return 422 error (message: "One of ingredients must be is active substance!")

Create new Medication

  1. Create new record in Medications 
  2. Fill data 

Destination

Source

id
name$.name
typeINNM
is_active TRUE
form$.form
ingredients$.ingredients
containerNULL
package_qtyNULL
package_min_qtyNULL
code_atcNULL
manufacturerNULL
certificate NULL
expired_certificate_atNULL
inserted_at:timestamp
inserted_byuser_id
updated_at:timestamp
updated_byuser_id

Prepare & return response data structure

...