Table of Contents |
---|
Purpose
The service is designed to uploading new medication registry. The process uses the jabba service. Upon execution of the request, a job is created, on the basis of which tasks are created. Each task is one request to create entity from registry.
Key points
NHS admin user download file with fields according to its structure.
File should be in .csv format.
Full medication registry input data for GraphQL mutatiuon should be in .csv format and with escaped symbols (i.e. quotes, new lines - " as \"; new line replaced as \r\n ). Please note that UI of NHS Admin panel converts csv file to appropriate GraphQL input.
Specification
Page Properties | |||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||||||||||
|
Expand | |||||
---|---|---|---|---|---|
|
...
Verify the validity of access token
in case of error - return 401 (“Invalid access token”) in case of validation fails
Verify that token is not expired
in case of error - return 401 (“Invalid access token”)
Check user scopes in order to perform this action (scope = 'medication_registry:write')
return 403 (“Your scope does not allow to access this resource. Missing allowances: medication_registry:write”) in case of invalid scope(s)
Validate request
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 | ||
---|---|---|
|
View file | ||
---|---|---|
|
...
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 - 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
medication_id
(withtype = BRAND
) andprogram_medications.medical_program_id
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 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.
...