...
...
...
...
Table of Contents |
---|
Status
...
Purpose
This WS is designed to create new medication (post).
APIary
Input parameters
- name
- type
- manufacturer (object)
- code_atc
- form
- container info
- package_qty
- package_min_qty
- certificate
- expired_certificate_at
- ingredients (array)
- id
- dosage info
- is_active_substance
Authorize
- Verify the validity of access token
- Check user scope (scope = 'medication:write') in order to perform this action
- In case error - generate 401 response
Validate request (JSON schema)
- Validate request using JSON schemas:
- Return 422 with list of validation errors in case validation fails (422 EView)
...
Validate FK
Purpose validation: Check on existing Substance/Innm in ingredients
For $.type = INNM - Check exist `Substance` by $.ingredients[].id.
if invalid - return 422 error (message: "Substance in ingredients is not found!")
For $.type = MEDICATION - Check exist `Medications` by $.ingredients[].id.
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
For $.type = MEDICATION - Check exist any ($.ingredients[].dosage.denumerator_unit != $.container.numerator_unit).
if invalid - return 422 error (message: "Denumerator unit from Dosage ingredients must be equal Numerator unit from Container medication!")
Validate multiplicity
Purpose validation: For $.type = MEDICATION - Package_qty for container_dosage must have multiplicity package_min_qty. Result (Mod or % operator) must = 0 .
- For $.type = MEDICATION - Vaildate multiplicity (Mod == 0) $.package_qty Mod $.package_min_qty == 0
- if result NOT 0 - return 409 eror (message: "Only a multiplicity package quantity for the minimum package quantity medication!")
Create new Medication
- Create new record in Medications
- Fill data
...
...
...
Prepare & return response data structure
...
Table of Contents | ||||
---|---|---|---|---|
|
Purpose
This WS is designed to create new medication.
Specification
Page Properties | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Logic
This method is used to create Medications. Fields descriptions are listed in request Example view.
Request structure
See on Apiary
Example:
Expand | ||
---|---|---|
| ||
|
Authorize
Verify the validity of access token
Check user scope (scope = 'medication:write') in order to perform this action
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 Substance/Innm in ingredients
Check exist `Medications` by $.ingredients[].id.
if invalid - return 422 error (message: "INNM in ingredients is not found!")
Validate status & type ingredients
Purpose validation: Id's in ingredients must be active
Invoke GetInnmByID($.ingredients[].id). Check exist any innm.is_active=FALSE.
if exists - return 422 error (message: "INNM in ingredients must be active!")
Purpose validation: Ingredients for TYPE=BRAND must be TYPE=INNM_DOSAGE
Check exists Ingredients with type=BRAND.
if exists - return 422 error (message: "Only INNM_DOSAGE can be ingredients!")
Validate status ingredients.is_primary
Purpose validation: in ingredients only one item must be is primary (TRUE)
Calculate count() where is_primary=TRUE in ingredients. Check count()>=1.
if invalid - return 422 error (message: "One of ingredients must be is primary!")
Validate Equal Dosage & Container
Purpose validation: Denumerator unit from Ingredients.dosage must be equal Numerator unit from Container.
Check exist any ($.ingredients[].dosage.denumerator_unit != $.container.numerator_unit).
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 .
MEDICATION - Validate multiplicity (Mod == 0) $.package_qty Mod $.package_min_qty == 0
if result NOT 0 - return 409 error (message: "Only a multiplicity package quantity for the minimum package quantity medication!")
Validate atc code
Validate value according to regex ^[abcdghjlmnprsvABCDGHJLMNPRSV]{1}[0-9]{2}[a-zA-Z]{2}[0-9]{2}$
in case of error return ('Invalid code')
Check that all elements in array of atc_code are different
in case of error return 422 error (message `atc codes are duplicated`)
Validate request
Validate request using features.
Expand | |||
---|---|---|---|
|
Processing
Info |
---|
Saving innm dosage and medication occurs in one table - prm.medications. They are separated by the parameter type - innm_dosage and brand. Therefore, some fields may not be filled in when creating an innm dosage or medication. For example, max_daily_dosage is filled for innm dosage, but not filled for medication, etc. |
Create new record in Medications
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 |
daily_dosage | number |
Create new Ingredients
Create new record in Ingredients from $.ingredients
Fill data
Destination | Source |
---|---|
id | |
dosage | $.ingredients.dosage |
parent_id | medication_id |
innm_child_id | NULL |
medication_child_id | $.ingredients.innm_dosage_id |
is_primary | $.ingredients.is_primary |
inserted_at | :timestamp |
inserted_by | user_id |
updated_at | :timestamp |
updated_by | user_id |
Response structure
See on Apiary
Example:
Expand | ||
---|---|---|
| ||
|
Expand | ||
---|---|---|
| ||
|
HTTP status codes
Page Properties | |||||||||
---|---|---|---|---|---|---|---|---|---|
|