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

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Purpose

The service is designed to upload deactivation 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.

Specification

Link

jabba service

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

Resource

jabba 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

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

 Specification for deactivateMedicationRegistryMutation
  "Deactivates a single `MedicationRegistry`."
  deactivateMedicationRegistry(
    input: DeactivateMedicationRegistryInput!
  ): DeactivateMedicationRegistryPayload  

"""
Input for `deactivateMedicationRegistry` mutation.

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

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

Logic

  1. Validate input according to schema

  2. Validate existing and deactivate entities of program medications registry:

    1. Extract program medications by program_medications.id from file and (deactivate the record) set:

      1. medication_request_allowed = false

      2. care_plan_activity_allowed = false

      3. is_active = false

      4. end_date = current_date ()

      5. updated_at = now()

      6. updated_by = user_id, from token

  3. Return job identifier with result.

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)

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 = ‘DEACTIVATE_PROGRAM_MEDICATION_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 that the identifiers from the request exist and active

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

File example:

HTTP status codes

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

 

404

validation error

422

validation error

  • No labels