Table of Contents |
---|
Status
- Specification
Status colour Red title specs - Apiary
Status colour Red title specs
...
This WS is designed to create new medication (post).
APIary
Input parameters
- name
- start_at
- route
- container_dosage infotype
- manufacturer (object)
- code_atc
- form
- container info
- package_qty
- package_min_qtycode_ATX
- manufacturer_name_country info
- certificate
- expired_certificate_dateat
- ingredients info(array)
- innm_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 using JSON schema (link !!! TBD)
...
schemas:
Type (Dictionary: MEDICATION_TYPE | Schema link |
---|---|
INNM | new_medication_type_innm_schema.json |
MEDICATION | new_medication_type_medication_schema.json |
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 Innm `Medications` by $.ingredients[].innm_id.
if invalid - return 422 error (message: "Innm INNM in ingredients is not found!")
Validate Equal Dosage & Container
...
Purpose validation: Denum For $.type = MEDICATION - Denumerator unit from Dosage must Ingredients.dosage must be equal Denum Numerator unit from Container dosage. See examples: Medications model
Check exist any Denum unit from Dosage any ($.ingredients[].dosage.denumerator_unit ) with Denum unit Container dosage ( != $.container_dosage.denumeratornumerator_unit).
if invalid - return 422 error (message: "Denum Denumerator unit from Dosage ingredients must be equal Denum Numerator unit from Container dosage medication!")
Validate multiplicity
...
- if result NOT 0 - return 409 eror (message: "Only a multiplicity package quantity for the minimum package quantity !")
Create new Medication
- Create new record in Medications
- 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_by | user_id |
updated_at | :timestamp |
updated_by | user_id |
- Save temp variable from medication.id
- 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_by | user_id |
updated_at | :timestamp |
updated_by | user_id |
Return data structure
- Fill response data structure (Similar input parametrs)
- Additional
- id
- container_dosage.description
- ingredients.dosage.description
- ingredients.innm info