ЕСОЗ - публічна документація

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 20 Next »

Specification

Purpose

This WS is designed to create new innm dosage (post).

Input parameters 

  • name
  • form
  • ingredients (array)

Authorize

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

Validate request (JSON schema)

  1. Validate request using JSON schemas (new_medication_type_innm_dosage_schema.json):
    1. Return 422 with list of validation errors in case validation fails (422 EView)

Validate FK 

Purpose validation: Check on existing Inmm/Innm dosage in ingredients 

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

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

Validate status

Purpose validation: Id's in ingredients must be active  

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

    1. if exists - return 422 error (message: "Innm in ingredients must be active!")

Validate status ingredients.is_primary

Purpose validation:  in ingredients only one item must be is active innm (TRUE)  

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

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

Validate innm duplication

Purpose validation: in ingredients innms can't be duplicated. Innms id has to be unique

  1. Check uniqueness of $.ingredients[].id.

    1. if invalid - return 422 error (message: "Ingredients can't be duplicated")

Create new Medication

  1. Create new record in Medications
  2. Fill data 

Destination

Source

id
name$.name
typeINNM Dosage
is_primaryTRUE
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

Create new Ingredients

  1. Save `id` of new Medication into var `med_id` 
  2. Create new record in Ingredients from $.ingredients
  3. Delete all Ingredients where parent_id = 
  4. Fill data (where `Ing` = $.ingredients) 

Destination

Source

id
dosageIng.dosage
parent_idmed_id
innm_idIng.innm_id
medication_idNULL
is_primaryIng.is_primary
inserted_at:timestamp
inserted_byuser_id
updated_at:timestamp
updated_byuser_id
  • No labels