Table of Contents |
---|
Status
- Specification
Status colour Red title specs - Apiary
Status colour Red title specs
...
- 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)
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 `Medications` by $.ingredients[].id.
if invalid - return 422 error (message: "INNM in ingredients is not found!")
...
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
Destination | Source | |||
---|---|---|---|---|
id | ||||
name | $.name | |||
is_active | TRUE | |||
start_at form | $.start_at form | |||
route ingredients | $.routeingredients | |||
container_dosage | $.container_dosage | |||
package_qty | $.package_qty | |||
package_min_qty | $.package_min_qty | |||
code_ATX atc | $.code_ATX atc | |||
manufacturer_name_country | $.manufacturer_name_country | |||
certificate | $.certificate | |||
expired_certificate_date at | $.expired_certificate_date | inserted_at | ||
:timestamp | inserted_by | user_id | updated_at | :timestamp |
updated_by | user_id |
...
...
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 |
...
Prepare & return response data structure
- Fill response WS data structure (Similar input parametrs)Additional
- id
- container_dosage.description
- ingredients.dosage.description ingredients.innm infostructure
- Validate response using JSON schemas (!!! TBD)
- Return 422 with list of validation errors in case validation fails (422 EView)