Versions Compared

Key

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

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

Table of Contents

Specification

Apiary

create-medication

JSON Schema request

new_medication_schema.json

JSON Schema response

Status
colourRed
titlespecs


Purpose

This WS is designed to create new medication (post).


Input parameters 

  • name

  • manufacturer (object)

  • code_atc

  • form

  • container info

  • package_qty

  • package_min_qty

  • certificate

  • expired_certificate_at

  • ingredients (array)

Authorize

  1. Verify the validity of access token

  2. Check user

    scope 

    scope (scope = 'medication: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_medication_schema.json):

    1. Return 422 with list of validation errors in case validation fails (422 EView)

Validate FK 

Purpose validation: Check on existing Substance/Innm in ingredients 

  1. Check exist `Medications` by $.ingredients[].id.

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

Validate status  & type ingredients

Purpose validation: Id's in ingredients must 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!")

Purpose validation: Ingredients for TYPE=MEDICATION must MEDICATION must be TYPE=INNM  

  1. Check exists Ingredients with type=MEDICATION.

    1. if exists - return 422 error (message: "Only INNMs can be ingredients!")

Validate status ingredients.is_active_substance

Purpose validation:  in ingredients only one item must 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!")

Validate Equal Dosage & Container

Purpose validation: Denumerator unit unit from Ingredients.dosage  must be equal Numerator unit from Container. See examples: Medications model  

  1. Check exist any  ($.ingredients[].dosage.denumerator_unit != $.container.numerator_unit).

    1. if invalid - return 422 error (message: "Denumerator unit from Dosage ingredients must be equal Numerator unit from Container medication!")

...

Purpose validation:  Package_qty for container_dosage must have multiplicity package_min_qty.  Result (Mod or % operator) must = 0 .

  1. MEDICATION -

     Vaildate

     Vaildate multiplicity (Mod == 0) $.package_qty Mod $.package_min_qty == 0

    1. if result NOT 0 - return 409 eror (message: "Only a multiplicity

  2. package quantity for the
    1. package quantity for the minimum package quantity medication!")

Validate atc code

  1. Check that all elements in array of atc_code are different 

    1. in case of error return 422 error (message `atc codes are duplicated`)

Create new Medication

  1. Create new record in Medications 

  2. Fill data 

Destination

Source

id


name

$.name

TYPE

MEDICATION

is_active

TRUE

form

$.form

ingredients

$.ingredients

container

$.container

package_qty

$.package_qty

package_min_qty

$.package_min_qty

code_atc

$.code_atc

manufacturer

$.manufacturer

certificate

$.certificate

expired_certificate_at

$.expired_certificate_at

inserted_at

:timestamp

inserted_by

user_id

updated_at

:timestamp

updated_by

user_id