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

RC_2_PSYHO_IL.Deactivate Division

Purpose

Specification

Apiary

Service logic

  1. Only authenticated and authorized user can use this service
  2. Only ACTIVE division can be deactivated
  3. Legal entity can deactivate only its own divisions

Authentication

  1. Verify the validity of access token
    1. Return 401 in case validation fails
  2. Check scopes in order to perform this action (scope = 'division:deactivate')
    1. Return 403 in case invalid scope(s)

Validate division

  1. Check that division with such ID exists in the system (is_active = true)
    1. In case of error - return 404
  2. Check that division belongs to the same legal entity as the user
    1. In case of error - return 403

Validate healthcare service

Check that there are no active healthcare services related to this division

  1. Search for healthcare services with this division in status ACTIVE
    1. If search result contains any records - return 409 error (Division cannot be deactivated - active healthcare services exists)

Validate equipment

Check that there are no active records in equipments table related to this division

  1. Search for equipments with this division in ACTIVE status
    1. If search result contains any records - return 409 error (Division cannot be deactivated - active equipments exists)

Validate transition

Only ACTIVE division can be deactivated

Available transitions

  1. ACTIVE → INACTIVE

In other cases - return 409 error ('{current_status} division cannot be DEACTIVATED')

Save object to DB

ParameterSourceDescription
statusINACTIVE
updated_atTimestamp: now()Get current date-time
updated_byToken: user_id

Deactivate Medical Program Provision

For PHARMACY legal entity type only. For related divisions deactivate linked active medical program provision entities (according to link).

Deactivate related active medical program provision entities:

  • set is_active = false

  • set deactivate_reason = AUTO_DIVISION_DEACTIVATION 

  • set updated_at, updated by

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