Table of Contents |
---|
Purpose
...
Page Properties | |||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||||||||||
|
Expand | |||||
---|---|---|---|---|---|
|
...
Validate request
Check that request using schema
Return 422 with the list of validation errors in case validation fails.
Check that registerType = 'FULL_MEDICATIONS_REGISTRY'
Return 422 with the list of validation errors in case validation fails.
Check csv_data input according to file structure
Return 422 with the list of validation errors in case validation fails
Check csv_data input file size - csv file with max 30000 lines is allowed.
Return 422
The number of tasks for the job with a sequential execution strategy is limited to 30,000
in case validation fails
File example:
View file | ||
---|---|---|
|
*Note. Fields innms.sctid
, innms.name
, innms.name_original
, innm_dosage_ingredients.is_primary
, innm_dosage_ingredients.dosage.numerator_value
, innm_dosage_ingredients.dosage.numerator_unit
, innm_dosage_ingredients.dosage.denumerator_value
, innm_dosage_ingredients.dosage.denumerator_unit
, brand.code_atc
can exist as an array. Values should be separated as | (respectively).
...
Validate input according to schema
Create job with type
create_medication_registry
For each line of input file create separate task of job
Each task must validate existing and create new entities of medications registry:
Extract and search medications with
type = INNM_DOSAGE
,is_active = TRUE
,innm_dosage.name
,innm_dosage.form
andinnm_dosage.ingredients.dosage
,innm_dosage.ingredients.is_primary
:in case more than one medication with
type = INNM_DOSAGE
,is_active = TRUE
,innm_dosage.name
,innm_dosage.form
is found - returnFAILED
task status with error ('More than one INNM_DOSAGE with such name and form exist in medications table
')in case more than one ingredient is found - return
FAILED
task status with error ('More than one INNM_DOSAGE ingredient with such fields exist in ingredients table
')in case single medication with type = INNM_DOSAGE is found then check ingredients, in case ingredients of INNM_DOSAGE in DB are not equal to ingredients in uploaded register - return
FAILED
task status with error ('INNM_DOSAGE has different INNMS in ingredients table
')in case medication with
type = INNM_DOSAGE
is not found - insert it according to Create full medication registry | medications (type = INNM_DOSAGE), its ingredients according to Create full medication registry | ingredients (for INNM_DOSAGE), brand according to Create full medication registry | medications (type = BRAND), its ingredient according to Create full medication registry | ingredients (for BRAND) and program medication with brand according to Create full medication registry | program_medicationscheck existence of INNMs by
innms.name_original
in case innm is not found - insert it according to Create full medication registry | innms
in case innm is found - skip innm creation.
in case more than one innm is found - return
FAILED
task status with error ('More than one INNM with such name_original exist in innms table
')
in case medication with
type = INNM_DOSAGE
is found - proceed to brand.
Extract and search connected medications with
type = BRAND
,is_active = TRUE
,brand.name
,brand.form
,brand.package_qty
,brand.package_min_qty
,brand.certificate
,brand.container
,brand.manufacturer.name
,brand.manufacturer.country
,brand.certificate_expired_at
andbrand.ingredients.dosage
,brand.ingredients.is_primary,
brand.drlz_sku_id:in case more than one medication with such params is found - return
FAILED
task status with error ('More than one BRAND with such fields exist in medications table
')in case single medication with type = BRAND is found then check ingredients, in case ingredient of BRAND in DB is not equal to ingredient of a brand in uploaded register - return
FAILED
task status with error ('Invalid BRAND ingredients in ingredients table
')in case medication with
type = BRAND
is not found OR is absent in registry - insert brand according to Create full medication registry | medications (type = BRAND), its ingredient according to Create full medication registry | ingredients (for BRAND) and program medication with brand according to Create full medication registry | program_medicationsin case medication with
type = BRAND
is found - proceed to program medication.
Extract and search connected program medication by:
In caseregistry_number = NULL
then search bymedication_id
(withtype = BRAND
) andprogram_medications.medical_program_id
andprogram_medication.registry_number IS NULL
;
In caseregistry_number
hasid
then search bymedication_id
(withtype = BRAND
) andprogram_medications.medical_program_id
andprogram_medication.registry_number
;in case more than one program medication with such params is found - return
FAILED
task status with error ('More than one PROGRAM_MEDICATION with such fields exist in program_medications table
')in case program medication is not found - insert program medication with brand OR with innm_dosage according to Create full medication registry | program_medication
in case program medication is found - return
FAILED
task status with error ('Such medication already exist
')
Return job identifier with result.
...
Attribute | Source and Logic | Type and Constraints | O/M | ||
---|---|---|---|---|---|
id | uuid_generate_v4(), auto | uuid | M | ||
dosage | numerator_value | innm_dosage_ingredients.dosage.numerator_value, from request | jsonb | float8 | M |
numerator_unit | innm_dosage_ingredients.dosage.numerator_unit, from request | varchar(255) Dictionary MEDICATION_UNIT | M | ||
denumerator_value | innm_dosage_ingredients.dosage.denumerator_value, from request | float8 | M | ||
denumerator_unit | innm_dosage_ingredients.dosage.denumerator_unit, from request | varchar(255) Dictionary MEDICATION_UNIT | M | ||
is_primary | innm_dosage_ingredients.is_primary, from request | bool At least one of the ingredients must be is_primary = true | M | ||
innm_child_id | uuid_generate_v4(), auto | uuid innm_id | M | ||
parent_id | uuid_generate_v4(), auto | uuid medication_id (type = INNM_DOSAGE) | M | ||
inserted_at | now(), auto | timestamp | M | ||
updated_at | now(), auto | timestamp | M |
medications (type = BRAND) (may be absent)
Attribute | Source and Logic | Type and Constraints | O/M | ||
---|---|---|---|---|---|
id | uuid_generate_v4(), auto | uuid | M | ||
name | brand.name | varchar(255) | M | ||
type | auto (BRAND) | varchar(255) | M | ||
manufacturer | name | brand.manufacturer.name | jsonb | varchar(255) | M |
country | brand.manufacturer.country | varchar(255) Dictionary COUNTRY | M | ||
code_atc | brand.code_atc | jsonb | varchar(255) | M | |
is_active | true, auto | bool | M | ||
form | brand.form | varchar(255) Dictionary MEDICATION_FORM | M | ||
container | numerator_value | brand.container.numerator_value | jsonb | float8 | M |
numerator_unit | brand.container.numerator_unit | varchar(255) Dictionary MEDICATION_UNIT | M | ||
denumerator_value | brand.container.denumerator_value | float8 | M | ||
denumerator_unit | brand.container.denumerator_unit | varchar(255) Dictionary MEDICATION_UNIT | M | ||
package_qty | brand.package_qty | float | O | ||
package_min_qty | brand.package_min_qty | float | O | ||
certificate | brand.certificate | varchar(255) | O | ||
certificate_expired_at | brand.certificate_expired_at | date | O | ||
inserted_by | user_id, from token | uuid | M | ||
updated_by | user_id, from token | uuid | M | ||
inserted_at | now(), auto | timestamp | M | ||
updated_at | now(), auto | timestamp | M | ||
form_pharm | brand.form_pharm | varchar(255) | O | ||
max_request_dosage | brand.max_request_dosage | int | O |
...
Attribute | Source and Logic | Type and Constraints | O/M | ||
---|---|---|---|---|---|
id | uuid_generate_v4(), auto | uuid | M | ||
is_primary | brand_ingredients.is_primary, from request | bool Only one ingredient should be is_primary = true | M | ||
dosage | numerator_value | brand_ingredients.dosage.numerator_value, from request | jsonb | float8 | M |
numerator_unit | brand_ingredients.dosage.numerator_unit, from request | varchar(255) Dictionary MEDICATION_UNIT | M | ||
denumerator_value | brand_ingredients.dosage.denumerator_value, from request | float8 | M | ||
denumerator_unit | brand_ingredients.dosage.denumerator_unit, from request | varchar(255) Dictionary MEDICATION_UNIT | M | ||
medication_child_id | uuid_generate_v4(), auto | uuid medication (type = INNM_DOSAGE) | M | ||
parent_id | uuid_generate_v4(), auto | uuidmedication_id (type = BRAND) | M | ||
inserted_at | now(), auto | timestamp | M | ||
updated_at | now(), auto | timestamp | M |
...
Attribute | Source and Logic | Type and Constraints | O/M | |
---|---|---|---|---|
id | uuid_generate_v4(), auto | uuid | M | |
reimbursement | type | program_medications.reimbursement.type | varchar(64) Dictionary REIMBURSEMENT_TYPE | M |
reimbursement_amount | program_medications.reimbursement.reimbursement_amount | float | M | |
percentage_discount | program_medications.reimbursement.percentage_discount | float | M | |
is_active | true, auto | bool | M | |
medication_request_allowed | true, auto | bool | M | |
care_plan_activity_allowed | true, auto | bool | M | |
inserted_by | user_id, from token | uuid | M | |
updated_by | user_id, from token | uuid | M | |
medication_id | medication_id (type = BRAND OR INNM_DOSAGE), auto | uuid | M | |
medical_program_id | program_medications.medical_program_id | uuid | M | |
inserted_at | now(), auto | timestamp | M | |
updated_at | now(), auto | timestamp | M | |
wholesale_price | program_medications.wholesale_price | float8 | O | |
consumer_price | program_medications.consumer_price | float8 | O | |
reimbursement_daily_dosage | program_medications.reimbursement_daily_dosage | float8 | O | |
estimated_payment_amount | program_medications.estimated_payment_amount | float8 | O | |
start_date | program_medications.start_date | date | O | |
end_date | program_medications.end_date | date | O | |
registry_number | program_medications.registry_number | varchar(255) | O | |
max_daily_dosage | program_medication.max_daily_dosage | float8 | O |
HTTP status codes
Page Properties | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||
|