Versions Compared

Key

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

Purpose

This WS allows to update details of a participant of medication program with device type.

Key points

  1. This is a graphQl method used in Administration panel only.

  2. Only authenticated and authorized NHS employee with appropriate scope can update Program device.

  3. This method is used to update program device details as well as deactivate program device record (by submitting is_active = false in request).

Specification

Expand
titleindex.graphql
Code Block
languagegraphql
  "Updates a single `ProgramDevice` using its globally unique ID and a patch."
  updateProgramDevice(input: UpdateProgramDeviceInput!): UpdateProgramDevicePayload
Expand
titleprogramDevices.graphl
Code Block
languagegraphql
"""
Input for `updateProgramDevice` mutation.

User must have a scope **program_device:write**
"""
input UpdateProgramDeviceInput {
  "The ID of an object."
  id: ID!
  "Whether `ProgramDevice` is active or not?"
  isActive: Boolean
  "Is it allowed to prescribe this device definition?"
  deviceRequestAllowed: Boolean
  "Is it allowed to create care plan activity for this device definition?"
  carePlanActivityAllowed: Boolean
  "Date of configuration end."
  endDate: Date
}

"""
Return type for `updateProgramDevice` mutation.
"""
type UpdateProgramDevicePayload {
  "Updated `ProgramDevice`."
  programDevice: ProgramDevice
}

"""
Program Device linkes device definition and medical program.

In order to obtain details user must have a scope **program_device:read**
"""
type ProgramDevice implements Node {
  "The ID of an object."
  id: ID!
  "Primary key identifier from the database."
  databaseId: UUID!
  "Medical program."
  medicalProgram: MedicalProgram!
  "Device definition."
  deviceDefinition: DeviceDefinition!
  "Reimbursement information."
  reimbursement: Reimbursement!
  "Wholesale selling price per package."
  wholesalePrice: Float
  "Retail price per package."
  consumerPrice: Float
  "The daily count of the device definition to be compensated."
  reimbursementDailyCount: Int
  "The amount of surcharge for packaging."
  estimatedPaymentAmount: Float
  "Date of configuration start."
  startDate: Date!
  "Date of configuration end."
  endDate: Date
  "Number (version) of reimbursement configuration."
  registryNumber: String
  "Whether `ProgramDevice` is active or not?"
  isActive: Boolean!
  "Is it allowed to prescribe this device definition?"
  deviceRequestAllowed: Boolean!
  "Date and time when record was inserted"
  insertedAt: DateTime!
  "Date and time when record was updated"
  updatedAt: DateTime!
  "The maximum allowable daily quantity of the device."
  maxDailyCount: Int
  "Is it allowed to create care plan activity for this device definition?"
  carePlanActivityAllowed: Boolean!
}

Authorization

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

    • Return (403, 'Your scope does not allow to access this resource. Missing allowances: program_device: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 program device by $.id exists in program_devices table in PRM DB

    • in case of error - return 404 ('Program device not found')

  • If $.isActive = false (program device is deactivated), check that device_request_allowed = true and care_plan_activity_allowed = true for program device

    • in case of error - return 422 ('To deactivate device definition within the program firstly disable medication_request_allowed and care_plan_activity_allowed')

  • If $.deviceRequestAllowed = true, check that program device is active (is_active = true)

    • in case of error - return 422 ('To allow device request firstly enable program device')

  • If $.carePlanActivityAllowed = true, check that program device is active (is_active = true)

    • in case of error - return 422 ('To allow care plan activity firstly enable program device')

  • If $.endDate is submitted, check that its value is greater than start_date of program device

    • in case of error - return 422 ('Program device end date should be greater than start date')

Validate program device

  • Check that device_definition_id of program device is still active in program_devices table in PRM DB (is_active = true)

    • in case of error - return 409 ('Device definition is not active')

  • Check that medical_program_id of program device is still active in medical_programs table in PRM DB (is_active = true)

    • in case of error - return 409 ('Medical program is not active')

Service logic

  1. Update params submitted on input in the program device entity. Also, set values:

    1. updated_by = user_id from token

    2. updated_at = now()

  2. Render a response according to specification.

...