Versions Compared

Key

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

Table of Contents

...

specsnew_innm_dosage_schema_response.json
Apiary
JSON Schema request
JSON Schema response
Status
colourRed
title

Purpose

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

...

  • 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

...

  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!")

...

  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!")

...

  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