Versions Compared

Key

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

Table of Contents

...

  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

...

  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 and (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

...