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

RС_[NEW] (GraphQl) Deactivate Device definition_EN

Purpose

This WS is designed to allow employee with appropriate scopes to deactivate device definition in eHealth.

Key points

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

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

Specification

"Deactivates a single `DeviceDefinition` using its globally unique ID." deactivateDeviceDefinition(input: DeactivateDeviceDefinitionInput!): DeactivateDeviceDefinitionPayload
""" Input for `deactivateDeviceDefinition` mutation. User must have scopes **device_definition:write** """ input DeactivateDeviceDefinitionInput { "The ID of an object" id: ID! } """ Return type for `deactivateDeviceDefinition` mutation. """ type DeactivateDeviceDefinitionPayload { "Deactivated `DeviceDefinition`." deviceDefinition: DeviceDefinition } """ A component part of medication. 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 ('required property <field_name> was not present') where field_name - name of missing field

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

    • in case of error - return 422 ('Unknown field')

  • Check that device definition by $.id exists in device_definitions table in PRM DB

    • in case of error - return 404 ('Device definition is not found')

  • Check that device definition is active (is_active = true)

    • in case of error - return 409 ('Device definition should be active')

  • Check that no active program devices exist in program_devices table in PRM DB with device_definition_id = $.id

    • in case of error - return 422 ('Device definition has active Program devices')

Service logic

  1. Update record in device_definitions table in PRM DB, set values:

    1. is_active = false

    2. updated_at = now()

    3. updated_by = user_id from token

  2. Render a response according to specification.

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