ЕСОЗ - публічна документація
RC_CSI-1542_IL.Deactivate Division
Purpose
Specification
Service logic
Only authenticated and authorized user can use this service
Only ACTIVE division can be deactivated
Legal entity can deactivate only its own divisions
Authentication
Verify the validity of access token
Return 401 in case validation fails
Check scopes in order to perform this action (scope = 'division:deactivate')
Return 403 in case invalid scope(s)
Validate division
Check that division with such ID exists in the system (is_active = true)
In case of error - return 404
Check that division belongs to the same legal entity as the user
In case of error - return 403
Validate healthcare service
Check that there are no active healthcare services related to this division
Search for healthcare services with this division in status ACTIVE
If search result contains any records - return 409 error (Division cannot be deactivated - active healthcare services exists)
Validate employees
Check that there are no active employees related to this division
Search for employees with this division in status ACTIVE
If search result contains any records - return 409 error (Division cannot be deactivated - active employees exists)
Validate equipment
Check that there are no active records in equipments table related to this division
Search for equipments with this division in ACTIVE status
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
ACTIVE → INACTIVE
In other cases - return 409 error ('{current_status} division cannot be DEACTIVATED')
Save object to DB
Parameter | Source | Description |
---|---|---|
status | INACTIVE |
|
updated_at | Timestamp: now() | Get current date-time |
updated_by | Token: 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
ЕСОЗ - публічна документація