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

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

Purpose*

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

Specification*

Link

API paragraph not found

Resource

/innm_dosages

Scope

innm_dosage:write

Components

Drugs and Program medications

Microservices

API paragraph not found

Protocol type

REST

Request type

POST

Sync/Async

Sync

Public/Private/Internal

Internal. NHS Admin

Logic*

This method is used to create INNM Dosage. Fields descriptions are listed in request Example view.

Request structure*

See on Apiary

Example:

 Request example
{
  "name": "Амідарон",
  "form": "PILL",
  "ingredients": [
    {
      "id": "1349a693-4db1-4a3f-9ac6-8c2f9e541982",
      "dosage": {
        "numerator_unit": "MG",
        "numerator_value": 200,
        "denumerator_unit": "PILL",
        "denumerator_value": 1
      },
      "is_primary": true
    }
  ]
}

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

Request to process the request using a token in the headers

Headers*

Наприклад:

  • Content-Type:application/json

  • Authorization:Bearer c2778f3064753ea70de870a53795f5c9

Request data validation*

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

Validate request

  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)

Processing*

Create new Medication

  1. Create new record in Medications

  2. Fill data 

Destination

Source

id

name

$.name

type

INNM Dosage

is_primary

TRUE

form

$.form

ingredients

$.ingredients

container

NULL

package_qty

NULL

package_min_qty

NULL

code_atc

NULL

manufacturer

NULL

certificate

NULL

expired_certificate_at

NULL

inserted_at

:timestamp

inserted_by

user_id

updated_at

:timestamp

updated_by

user_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

dosage

Ing.dosage

parent_id

med_id

innm_id

Ing.innm_id

medication_id

NULL

is_primary

Ing.is_primary

inserted_at

:timestamp

inserted_by

user_id

updated_at

:timestamp

updated_by

user_id

Response structure*

See on Apiary

Example:

 Response example
{
  "meta": {
    "code": 201,
    "url": "https://example.com/resource",
    "type": "object",
    "request_id": "req-adasdoijasdojsda"
  },
  "data": {
    "id": "09b2bffb-699a-43c0-bc9a-5066d9b9b5a8",
    "name": "Амідарон",
    "form": "PILL",
    "ingredients": [
      {
        "id": "1349a693-4db1-4a3f-9ac6-8c2f9e541982",
        "name": "Амідарон",
        "dosage": {
          "numerator_unit": "MG",
          "numerator_value": 200,
          "denumerator_unit": "PILL",
          "denumerator_value": 1
        },
        "is_primary": true
      }
    ],
    "is_active": true,
    "inserted_at": "2017-04-20T19:14:13Z",
    "inserted_by": "e1453f4c-1077-4e85-8c98-c13ffca0063e",
    "updated_at": "2017-04-20T19:14:13Z",
    "updated_by": "2922a240-63db-404e-b730-09222bfeb2dd"
  }
}

 Response example
{
  "meta": {
    "code": "422",
    "url": "https://example.com/resource",
    "type": "object",
    "request_id": "req-adasdoijasdojsda"
  },
  "error": {
    "type": "unverified",
    "message": "Property \"is_active\" has not been defined and the schema does not allow additional properties!"
  }
}

Post-processing processes*

API paragraph not found

HTTP status codes*

HTTP status code

Message

What caused the error

 201

 

 

 422

 

 

  • No labels