ЕСОЗ - публічна документація

RC_Update program medication registry (CSI-2140)

Purpose

The service is designed to uploading updates to the program 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

  1. This is a GraphQL method that is used in Administration panel only.

  2. Only authenticated and authorized NHS employee with appropriate scope can update program medication registry.

  3. Update program medication registry file should be in .csv format.

Specification

"Updates a single `MedicationRegistry`." updateMedicationRegistry( input: UpdateMedicationRegistryInput! ): UpdateMedicationRegistryPayload
""" Input for `updateMedicationRegistry` mutation. User must have a scope **medication_registry:write** """ input UpdateMedicationRegistryInput { "Type of register originating medication registry data. The value should be present in the `REGISTER_TYPE` dictionary." registerType: String! "Update medication registry reason description." reasonDescription: String! "String with input file in csv format with medication register." csvData: String! } """ Return type for `updateMedicationRegistry` mutation. """ type UpdateMedicationRegistryPayload { "Created `MedicationRegistryJob`." medicationRegistryJob: MedicationRegistryJob } """ An object for MedicationRegistryJob. """ type MedicationRegistryJob implements Node { "The ID of an object" id: ID! "Primary key identifier from the database" databaseId: UUID! "Job name." name: String "Medication registry Job status." status: JobStatus! "Job execution strategy." strategy: JobStrategy! "Date and time when the job starts." startedAt: DateTime! "Date and time when the job ends." endedAt: DateTime "Tasks within this job." tasks( "A condition to be used in determining which values should be returned by the collection." filter: TaskFilter "The method to use when ordering collection items." orderBy: TaskOrderBy "Read all values in the set after (below) this cursor." after: String "Read all values in the set before (above) this cursor." before: String "Only read the first _n_ values of the set." first: Int "Only read the last _n_ values of the set." last: Int ): MedicationRegistryTaskConnection! "Type of register originating medication registry data. The value should be present in the `REGISTER_TYPE` dictionary." registerType: String! "Medication registry job reason description." reasonDescription: String! } """ A connection to a list of `MedicationRegistryTask` values. """ type MedicationRegistryTaskConnection { "Information to aid in pagination." pageInfo: PageInfo! "A list of nodes." nodes: [MedicationRegistryTask] "A list of edges." edges: [MedicationRegistryTaskEdge] } """ Reads and enables pagination through a set of `MedicationRegistryTask`. """ type MedicationRegistryTaskEdge { "The item at the end of the edge." node: MedicationRegistryTask! "A cursor for use in pagination." cursor: String! } """ A child of a `MedicationRegistryJob`, contains the result of task execution. """ type MedicationRegistryTask implements Node { "The ID of an object" id: ID! "Primary key identifier from the database" databaseId: UUID! "Task name." name: String "Task status, is set automatically." status: TaskStatus! "Task meta data." meta: MedicationRegistryTaskMeta "Date and time when task was executed." endedAt: DateTime "Task error." error: TaskError "Technical information when task was inserted into the DB." insertedAt: DateTime! "Technical information when task was updated in the DB." updatedAt: DateTime! } """ Metadata of a `MedicationRegistryTask`. """ type MedicationRegistryTaskMeta { "Primary key identifier of an entity from the database." databaseId: UUID "Line number of csv file from input." csvDataLine: Int }

Authorization

  • 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

  1. Check request using schema

    1. Return 422 with the list of validation errors in case validation fails

  2. Check that registerType = 'UPDATE_PROGRAM_MEDICATION_REGISTRY'

    1. Return 422 Invalid register_type in case validation fails

  3. Check csv_data input according to file structure

    1. Return 422 with the list of validation errors in case validation fails

  4. Check csv_data input file size - csv file with max 30000 lines is allowed.

    1. Return 422 The number of tasks for the job with a sequential execution strategy is limited to 30,000 in case validation fails

File examples:

Service logic

  1. Validate input according to schema

  2. Create job with type update_medication_registry

  3. For each line of input file create separate task of job

  4. Each task must validate existing and update entities of program medications registry:

    1. Extract and search program medications by program_medications.id from file

      1. in case program medication is not found - return FAILED task status with error ('Program medication <program_medication.id> does not exist')

      2. in case program medication is found - update the record with the rest of the values:

Attribute

Source and Logic

Type and Constraints

O/M

Attribute

Source and Logic

Type and Constraints

O/M

id

program_medications.id

uuid

M

medication_request_allowed

program_medications.medication_request_allowed

bool

M

care_plan_activity_allowed

program_medications.care_plan_activity_allowed

bool

M

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

reimbursement.reimbursement_amount

program_medication.reimbursement.reimbursement_amount

float8 in jsonb

M

reimbursement.percentage_discount

program_medication.reimbursement.percentage_discount

float8 in jsonb

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

float

O

package_qty_divisible

program_medication.package_qty_divisible

bool

M

  1. Return job identifier with result.

ЕСОЗ - публічна документація