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

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

Version 1 Current »

Purpose

This WS is designed to allow employee with appropriate scopes to create device definition in system.

Key points

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

  2. Only authenticated and authorized employee with appropriate scope can create device definitions.

  3. Device definition validations are also used in [NEW] (GraphQl) Upload Device definitions registry WS.

Specification

 index.graphql
  "Creates a single `DeviceDefinition`."
  createDeviceDefinition(input: CreateDeviceDefinitionInput!): CreateDeviceDefinitionPayload
 deviceDefinitions.graphql
"""
Input for `createDeviceDefinition` mutation.

User must have scopes **device_definition:write**
"""
input CreateDeviceDefinitionInput {
  "Device identifier in external system."
  externalId: String
  "Device names."
  deviceNames: [CreateDeviceDefinitionNameInput]!
  "A classification or risk class of the device model. The value should be present in the `device_classification_type` dictionary."
  classificationType: String!
  "Description of the device."
  description: String
  "Name of device manufacturer"
  manufacturerName: String!
  "Country of manufacture. The value should be present in the `COUNTRY` dictionary."
  manufacturerCountry: String!
  "The catalog or model number for the device for example as defined by the manufacturer."
  modelNumber: String!
  "The part number or catalog number of the device."
  partNumber: String
  "A code that defines the specific type of packaging. The value should be present in the `device_definition_packaging_type` dictionary."
  packagingType: String!
  "The number of items contained in the package."
  packagingCount: Int!
  "Unit of measurement. The value should be present in the `DEVICE_UNIT` dictionary."
  packagingUnit: String!
  "Device notes and comments."
  note: String
  "Array of device properties."
  properties: [CreateDeviceDefinitionPropertyInput]
  "Reference to parent device definition."
  parentId: UUID
}

"""
Input for `deviceNames` of `createDeviceDefinition` mutation.
"""
input CreateDeviceDefinitionNameInput {
  "Device name type. The value should be present in the `device_name_type` dictionary."
  type: String!
  "Device name."
  name: String!
}

"""
Input for `properties` of `createDeviceDefinition` mutation.
"""
input CreateDeviceDefinitionPropertyInput {
  "Device property type. The value should be present in the `device_properties` dictionary."
  type: String!
  "Device property value in integer format."
  valueInteger: Int
  "Device property value in string format."
  valueString: String
  "Device property value in boolean format."
  valueBoolean: Boolean
  "Device property value in decimal format."
  valueDecimal: Float
}

"""
Return type for `createDeviceDefinition` mutation.
"""
type CreateDeviceDefinitionPayload {
  "Created `DeviceDefinition`."
  deviceDefinition: DeviceDefinition
}

"""
An instance of a medical-related component of a medical device. 

User must have a scope **device_definition:read**
"""
type DeviceDefinition implements Node {
  "The ID of an object."
  id: ID!
  "Primary key identifier from the database."
  databaseId: UUID!
  "Device identifier in external system."
  externalId: String
  "Device names."
  deviceNames: [DeviceName]!
  "A classification or risk class of the device model. The value should be present in the `device_classification_type` dictionary."
  classificationType: String!
  "Description of the device."
  description: String
  "Name of device manufacturer"
  manufacturerName: String!
  "Country of manufacture. The value should be present in the `COUNTRY` dictionary."
  manufacturerCountry: String!
  "The catalog or model number for the device for example as defined by the manufacturer."
  modelNumber: String!
  "The part number or catalog number of the device."
  partNumber: String
  "A code that defines the specific type of packaging. The value should be present in the `device_definition_packaging_type` dictionary."
  packagingType: String!
  "The number of items contained in the package."
  packagingCount: Int!
  "Unit of measurement. The value should be present in the `DEVICE_UNIT` dictionary."
  packagingUnit: String!
  "Device notes and comments."
  note: String
  "Array of device properties."
  properties: [DeviceDefinitionProperty]
  "Reference to parent device definition."
  parentId: UUID
  "is_active status."
  isActive: Boolean!
  "Date and time when record was inserted"
  insertedAt: DateTime!
  "Date and time when record was updated"
  updatedAt: DateTime!
}

"""
A component part of DeviceDefinition.
"""
type DeviceName implements DeviceDefinition {
  "Device name type. The value should be present in the `device_name_type` dictionary."
  type: String!
  "Device name."
  name: String!
}

"""
A component part of DeviceDefinition.
"""
type DeviceDefinitionProperty implements DeviceDefinition {
  "Device property type. The value should be present in the `device_properties` dictionary."
  type: String!
  "Device property value in integer format."
  valueInteger: Int
  "Device property value in string format."
  valueString: String
  "Device property value in boolean format."
  valueBoolean: Boolean
  "Device property value in decimal format."
  valueDecimal: Float
}

Authorize

  • Verify the validity of access token

    • 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 = 'device_definition:write')

    • Return (403, 'Your scope does not allow to access this resource. Missing allowances: device_definition:write') in case of invalid scope(s)

Validate legal entity

  • Extract client_id from token.

  • Check legal entity status (status = ACTIVE)

    • in case of error - return 409 ('client_id refers to legal entity that is not active.')

  • Check client type (type = NHS)

    • in case of error - return 403 ('You don't have permission to access this resource')

Validate request

  • Check that required fields according to specification are submitted

    • in case of error - return 422 ('In field <<field_name>>: Expected type <<field_type>>, found null.') where field_name - name of missing field, field_type - type of missing field

  • Check that no additional fields that do not correspond to schema are submitted

    • in case of error - return 422 ('In field <<field_name>>: Unknown field.') where field_name - name of additional field that does not correspond to schema

  • Check that each field in request corresponds to its type in specification

    • in case of error - return 422 ('In field <<field_name>>: Expected type <<field_type>>, found <<actual_value>>.') where field_name - name of error field, field_type - expected type of field, actual_value - value that was submitted to field

Validate device definition

  • Check that following field values exist in dictionaries:

    • $.classificationTypedevice_classification_type dictionary

    • $.manufacturerCountryCOUNTRY dictionary

    • $.packagingTypedevice_definition_packaging_type dictionary

    • $.packagingUnitDEVICE_UNIT dictionary

    • $.deviceNames.typedevice_name_type dictionary

    • $.properties.typedevice_properties dictionary

      • in case of error - return 422 ('value is not allowed in enum')

  • Check that there are no duplicated types within $.deviceNames ($.deviceNames.type must be unique within $.deviceNames)

    • in case of error - return 422 ('Values are not unique by 'type'.)

  • If $.properties is submitted, check that at least one of $.value[X] field is submitted in each object

    • in case of error - return 422 ('One and only one key is allowed from the list')

  • If $.properties is submitted, check that only one $.value[X] field is submitted in each object

    • in case of error - return 422 ('One and only one key is allowed from the list')

  • If $.parentId is submitted, check device definition exists and is active record in https://e-health-ua.atlassian.net/wiki/spaces/RMDN/pages/17670504863/UPD+Device+definition+data+model#Device-definition table in PRM DB

    • in case of error - return 422 ('Parent device definition is not found.')

  • If $.externalId is submitted, check that does not exist active device definition with the same external_id

    • in case of error - return 422 ('Active device definition with the same external_id already exists.')

  • Check that does not exist active device definition with the same combination of fields $.classificationType, $.manufacturerName, $.modelNumber, $.packagingCount, $.partNumber

    • in case of error - return 422 ('Active device definition with the same classification_type, manufacturer_name, model_number, packaging_count, part_number already exists.')

Service logic

  1. Save data to device_definitions and device_definition_names tables (PRM DB) according to [UPD] Device definition data model_EN

  2. Render a response according to specification.

  • No labels