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

RС_[NEW] (GraphQl) Create Program device_EN

Purpose

This WS allows to create 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 create Program device.

Specification

"Creates a single `ProgramDevice`." createProgramDevice(input: CreateProgramDeeviceInput!): CreateProgramDevicePayload
""" Input for `createProgramDevice` mutation. """ input CreateProgramDeviceInput { "Device definition identifier." deviceDefinitionId: ID! "Medical program identifier." medicalProgramId: ID! "Reimbursement information." reimbursement: CreateReimbursementInput! "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 "The maximum allowable daily quantity of the device." maxDailyCount: Int "Is it allowed to prescribe this device definition?" deviceRequestAllowed: Boolean! "Is it allowed to create care plan activity for this device definition?" carePlanActivityAllowed: Boolean! } """ Input for `Reimbursement` of `createProgramDevice` mutation. User must have a scope **program_device:write** """ input CreateReimbursementInput { "Reimbursement type." type: ReimbursementType! "Reimbursement amount." reimbursementAmount: Float "Percentage of reimbursement." percentageDiscount: Float } """ Return type for `createProgramDevice` mutation. """ type CreateProgramDevicePayload { "Created `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

  • Validate device definition submitted in $.deviceDefinitionId

    • Check that device definition by id exists in device_definitions table (PRM DB) and is active (is_active = true)

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

  • Validate medical program submitted in $.medicalProgramId

    • Check that medical program by id exists in medical_programs table (PRM DB) and is active (is_active = true)

      • in case of error - return 422 ('Medical program not found')

    • Check that medical program has type DEVICE

      • in case of error - return 422 ('Medical program type should be DEVICE')

  • Validate reimbursement details submitted in $.reimbursement

    • If $.reimbursement.type = FIXED, than $.reimbursement.reimbursementAmount field is required

    • If $.reimbursement.type = PERCENTAGE, than $.reimbursement.percentageDiscount field is required

      • in case of error - return 422 ('can't be blank')

    • If $.reimbursement.percentageDiscount submitted, check that its value is in range from 0 to 100

      • in case of error - return 422 ('expected the value to be <= 100')

  • Validate program device start date submitted in $.startDate

    • If $.endDate is submitted, check that program device start date is lesser than end date

      • in case of error - return 422 ('must be earlier than the end date')

Service logic

  1. Create program device entity in program_devices table in PRM DB with values from input. Also, set values:

    1. id = autogenerate uuid

    2. is_active = true

    3. inserted_at = now()

    4. updated_at = now()

    5. inserted_by = user_id from token

    6. updated_by = user_id from token

  2. Render a response according to specification.

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