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

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 17 Next »

Status

  • Specification SPECS
  • Apiary SPECS

Purpose

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

APIary 

create-medication

Input parameters 

  • name
  • type
  • 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 = 'medication:write') in order to perform this action
    1. In case error - generate 401 response

Validate request (JSON schema)

Validate request using JSON schemas:

Type (Dictionary: MEDICATION_TYPESchema link
INNMnew_medication_type_innm_schema.json
MEDICATIONnew_medication_type_medication_schema.json

Validate FK 

Purpose validation: Check on existing Substance/Innm in ingredients 

  1. For $.type = INNM - Check exist `Substance` by $.ingredients[].id.

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

  2. For $.type = MEDICATION - Check exist `Medications` by $.ingredients[].id.

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

Validate Equal Dosage & Container

Purpose validation: For $.type = MEDICATION - Denumerator 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!")

Validate multiplicity

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

  1. Vaildate multiplicity (Mod == 0) $.package_qty Mod $.package_min_qty == 0
    1. if result NOT 0 - return 409 eror (message: "Only a multiplicity package quantity for the minimum package quantity !")

Create new Medication

  1. Create new record in Medications 
  2. Fill data 
Destination
Source
id
name$.name
is_active TRUE
start_at $.start_at
route $.route
container_dosage $.container_dosage
package_qty$.package_qty
package_min_qty$.package_min_qty
code_ATX $.code_ATX
manufacturer_name_country$.manufacturer_name_country
certificate $.certificate
expired_certificate_date $.expired_certificate_date
inserted_at:timestamp
inserted_byuser_id
updated_at:timestamp
updated_byuser_id
  1. Save temp variable from medication.id
  2. Create new records in Ingredients (array)

Destination
Source
id
medication_id medication.id
innm_id $.ingredients[].innm_id
is_active_substance $.ingredients[].is_active_substance
dosage $.ingredients[].dosage
inserted_at:timestamp
inserted_byuser_id
updated_at:timestamp
updated_byuser_id

Return data structure

  1. Fill response data structure (Similar input parametrs)
  2. Additional  
    • id
    • container_dosage.description
    • ingredients.dosage.description
    • ingredients.innm info
  • No labels