Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Only authenticated and authorized users with appropriate scope can invoke Create Device Dispense

  2. Device Dispense is created in async way. Successful result of the job should return a link on the created Device Dispense (look at Get Device dispense details /wiki/spaces/CSI/pages/17467506869 ).

  3. Device Dispense can be created only under active Device Request within valid dispense period

  4. Several devices of different manufacturers with the same code can be dispensed at a time

  5. Multiple dispenses to the same Device Request is not allowed

...

  • Check that division exists

    • in case of error - return 409 ("Division not found")

  • Check that division is active

    • in case of error - return 409 ("Division is not active")

  • Validate division belongs to user's legal entity (client_id from token)

    • in case of error - return 409 ("Division does not belong to user's legal entity")

  • If chart parameter DISPENSE_DIVISION_DLS_VERIFY is on, then validate division is DLS verified (dls_verified=true)

    • in case of error - return 409 "Division is not verified in DLS"

Validate

...

Device request

...

  • in case of error - return 409 error ('Invalid dispense period')

Validate Device request

Validate value in the field $.based_on ($.based_on.identifier.value), Reference on device request, required.

...

  • Check that Device request is valid and available for dispense under this medical program

    • Invoke Qualify Device request /wiki/spaces/CSI/pages/17467834459

    • Check that program_id is in Qualify response

      • Device request is prohibited for dispense in case $.data[?(@.program_id=device_request.program.identifier.value)].status = 'INVALID' or program_id is absent in qualify response

        • In case of error - return 409 error ('Device request can not be dispensed. Invoke qualify dispense request API to get detailed info')

      • Device request is allowed for dispense in case $.data[?(@.program_id=device_request.program.identifier.value)].status = 'VALID' and program_id is present in qualify response

...

  • Check that there is no other IN_PROGRESS device dispenses based on the same device request

    • Find all device dispenses related to the same device request ($.based_on)

    • Check that there are no records in status in-progress where wheninserted_handed_overat + config device_dispense_ttl >= current date-time()

      • in case of error - return 422 "Other active device dispense already exist."

...

  • Fill in the following fields:

    • status = IN_PROGRESS

    • status_reason = null

    • subject. Set hashed patient_id from URL

    • performer_legal_entity. Set client_id from token

    • quantity.unit. Set description according to quantity code and system

    • inserted_at. Set current date and time

    • updated_at. Set current date and time

    • inserted_by. Set current user from token

    • updated_by. Set current user from token

  • Save data to device_dispenses collection in MongoDB according to Device dispense data model /wiki/spaces/CSI/pages/17467572335

  • Send StatusChangeEvent to Event Manager