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

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Next »

Purpose

Specification

Apiary

Service logic

  1. Only authenticated and authorized user can use this service
  2. Employee role must be valid and consistent, i.e. all "foreign keys" must be valid
  3. It can be only one active employee_role for the single employee and healthcare service

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 = 'employee_role:write')
    1. Return 403 in case invalid scope(s)

Validate request

Validate request using JSON schema

Validate legal entity

Check that legal entity is active (status = ACTIVE, SUSPENDED)

  1. Extract client_id from token (token.client_id == legal_entity_id)
  2. Check legal entity status (status = ACTIVE, SUSPENDED)
    1. In case of error - return 409 (Legal entity must be ACTIVE or SUSPENDED)

Validate FK

  1. Validate healthcare_service_id healthcare service exists and is_active = true
    1. Return 422 in case validation fails
  2. Validate employee_id employee exists and is_active = true
    1. Return 422 in case validation fails

Validate constraint

It can be only one active employee_role for the single employee and healthcare service

  1. Check that there is no another active record (status = ACTIVE) with the same employee and healthcare service
    1. Return 409 (Duplicated employee role for this employee and healthcare service) in case such pair exists

Validate healthcare service

Check that healthcare service belongs to the same legal entity as the user and healthcare service is active

  1. Extract client_id from token (token.client_id == legal_entity_id)
  2. Validate legal entity on healthcare service
  3. Check healthcare service status (status = ACTIVE)

Validate employee and its specialization

Check that employee belongs to the same legal entity as the user, employee is active and has the same specializations as the healthcare service

  1. Extract client_id from token (token.client_id == legal_entity_id)
  2. Validate legal entity on employee service
  3. Check employee status (status = APPROVED)
  4. Validate specialization on employee (where specialities.speciality_officio = true) and healthcare service

Save object to DB

ParameterSourceDescription
idUUIDAutogenerated
start_dateTimestamp: now()Get current date-time
statusConst: ACTIVEBy default ACTIVE for new records
is_activeConst: TRUEAlways TRUE for new records
inserted_atTimestamp: now()Get current date-time
inserted_byToken: user_idExtract user from token
updated_atTimestamp: now()Get current date-time
updated_byToken: user_idExtract user from token
  • No labels