Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
minLevel1
maxLevel7

Purpose

The service is designed to upload a 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 an entity from the registry.

...

Specification

Page Properties

Link

API paragraph not foundJabba service

Посилання на Apiary або Swagger

Resource

API paragraph not foundJabba service

Посилання на ресурс, наприклад: /api/persons/create

Scope

medication_registry:write

Scope для доступу

Components

ePrescription

Зазначається перелік бізнес компонентів, які використовують цей метод, наприклад: ePrescription

Microservices

API paragraph not found

Перелік мікросервісів, які використовує метод API, наприклад: Auth, ABAC

Protocol type

API paragraph not found

Тип протоколу, який використовується запитом, наприклад: SOAP | REST

Request type

API paragraph not found

Тип запиту API, наприклад: GET, POST, PATCH…

Sync/Async

API paragraph not found

Метод є синхронним чи асинхронним?

Public/Private/Internal

Internal

Потрібно зазначити тип методу за ступенем доступності

Expand
titleSpecification for Create full medication registry
Code Block
languagegraphql
  "Creates a single `MedicationRegistry`."
  createMedicationRegistry(
    input: CreateMedicationRegistryInput!
  ): CreateMedicationRegistryPayload
Code Block
languagegraphql
"""
Input for `createMedicationRegistry` mutation.

User must have a scope **medication_registry:write**
"""
input CreateMedicationRegistryInput {
  "Type of register originating medication registry data. The value should be present in the `REGISTER_TYPE` dictionary."
  registerType: String!
  "Create medication registry reason description."
  reasonDescription: String!
  "Input file in csv format with medication register."
  csvData: Upload!    
}

"""
Return type for `createMedicationRegistry` mutation.
"""
type CreateMedicationRegistryPayload {
  "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  
}

...

  1. Validate input according to schema

  2. Create job with type create_medication_registry

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

  4. Each task must validate existing and create new entities of medications registry:

    1. Extract medications with type = INNM_DOSAGE, is_active = TRUE, innm_dosage.name, innm_dosage.form and innm_dosage.ingredients.dosage, innm_dosage.ingredients.is_primary):

      1. in case found extract connected medications with type = BRAND, is_active = TRUE, brand.name, brand.form, brand.package_qty, brand.package_min_qty, brand.certificate, brand.container and brand.ingredients.dosage, brand.ingredients.is_primary, brand.manufacturer.name, brand.manufacturer.country, brand.certificate_expired_at:

        1. in case found extract connected program medication by medication_id and program_medications.medical_program_id and insert program medication with brand according to https://e-health-ua.atlassian.net/wiki/spaces/EH/pages/17205985289/Create+full+medication+registry#program_medications in case program medication not found

      2. in case innm_dosage not found insert it according to https://e-health-ua.atlassian.net/wiki/spaces/EH/pages/17205985289/Create+full+medication+registry#medications-(type-%3D-INNM_DOSAGE) and its ingredients https://e-health-ua.atlassian.net/wiki/spaces/EH/pages/17205985289/Create+full+medication+registry#ingredients-(for-INNM_DOSAGE)

        1. check existence of INNMs by innms.name_original

          1. in case innm not found - insert it according to https://e-health-ua.atlassian.net/wiki/spaces/EH/pages/17205985289/Create+full+medication+registry#innms

          2. in case innm is found - skip innm creation.

          3. 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')

      3. in case brand not found insert brand according to https://e-health-ua.atlassian.net/wiki/spaces/EH/pages/17205985289/Create+full+medication+registry#medications-(type-%3D-BRAND) and its ingredient https://e-health-ua.atlassian.net/wiki/spaces/EH/pages/17205985289/Create+full+medication+registry#ingredients-(for-BRAND) .

        1. insert program medication with brand according to https://e-health-ua.atlassian.net/wiki/spaces/EH/pages/17205985289/Create+full+medication+registry#program_medications

      4. in case brand and program medication found - return FAILED task status with error ('Such medication already exist')

  5. Return job identifier with result.

...

  • 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)

Headers

Наприклад:

  • Content-Type:application/json

  • Authorization:Bearer c2778f3064753ea70de870a53795f5c9

  • api-key:uXhEczJ56adsfh3Ri9SUkc4en

Request data validation

Validate request

  1. Check that request using schema

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

  2. Check that registerType = 'FULL_MEDICATIONS_REGISTRY'

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

  3. Check that reasonDescription filled

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

  4. Check input file according to file structure

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

  5. Check 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 example:

View file
namemedication_registries.csv

...

Page Properties

HTTP status code

Message

What caused the error

401

 Invalid access token

 

 

 403

 Your scope does not allow to access this resource. Missing allowances: medication_registry:write

  

422 

Validation error