Versions Compared

Key

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

Table of Contents

...

The key to find current active employee in contract and deactivate it  -  $contract_id + $employee_id +$division_id and end_date=null. For such row set end_date=now()::date.

Request example to add/update employee:

Code Block
titleUpdate employee
{
 "employee_id": "09106b70-18b0-4726-b0ed-6bda1369fd52",
 "staff_units": 1,
 "declaration_limit": 45000,
 "division_id": "6eb6123a-b3ce-4d27-ad3a-f6e3fb3ef1a1"
}


Request example to deactivate employee:

Code Block
titleUpdate employee
{
 "employee_id": "09106b70-18b0-4726-b0ed-6bda1369fd52",
 "division_id": "6eb6123a-b3ce-4d27-ad3a-f6e3fb3ef1a1",
 "is_active": false
}


Authorize

    1. Verify the validity of access token
      1. in case of error return 401 ('Access denied')
    2. Check user scope contract:write in order to perform this action
      1. in case of error generate 401 response ('Invalid scopes')

Check employee

Update contract_employees can be done by employee with necessary scopes in equal legal_entity_id as was perviously input in contract.

...

Decode content that is encrypted in an electronic digital signature.
Use Digital signature WS. Method checks digital signature and returns result.

Validate DRFO

  1. Check that DRFO in Certificate details exists and not empty
    1. in case of error return 422 error ('Invalid DRFO in DS')
  2. Check that DRFO in Certificate details is equal to DRFO in Party
    1. Get party.tax_id using user_id from token (user.id→ party_users.party_id → parties.id.tax_id)
    2. Compare DRFO in Certificate with party.tax_id
      1. Convert DRFO and TAX_ID to uppercase
      2. Compare DRFO and TAX_ID as Cyrillic letters
      3. Convert DRFO to Cyrillic and compare as Cyrillic letters
    3. In case validation fails - generate 422 error

Validate request

  1. Check contract_id exists. In case of error return 404 Error ('Contract with this ID doesn't exist')
  2. Check contract with  $contract_id has status 'VERIFIED'. In case of error return 422 Error ('Not active contract can't be updated')
  3. Validate contractor_employee_divisions
    1. Employee from employee_divisions has employee_type='DOCTOR', status='APPROVED'
      1. in case of error return 422  error view $employee ('Employee must be an active DOCTOR')
    2. By contract_id find contractor_legal_entity_id. Check employee belongs to legal entity.
      1. in case of error return 422  error view $divisions ('Employee must be within current legal_entity')
    3. By contract_id find contractor_legal_entity_id. Check divisions belongs to legal_entity and divisions.status='active'. 
      1. in case of error return 422  error view $divisions ('Division must be active and within current legal_entity')
    4. Check divisions belongs to contractor_divisions. Find contract_divisions by contract_id and end_date=null
      1.  in case of error return 422  error view $employee  ('Division is not in contract')

Search current contract_employees by contract id

  1. Fetch  ops.contract_employees.id by $contract_id + $employee_id +$division_id and end_date=null. For such row set end_date=now()::date
  2. Insert into ops.contract_employees new employee which was received in request.
    1. set start_date=now()::date+1
    2. end_date=null