Versions Compared

Key

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

Table of Contents

...

json schema

Validation

Validate token

  • Verify the validity of access token
    • Return 401 in case validation fails
  • Check if token is not expired
    • in case error return 401 - "Token is expired"

...

  • Check if user is active
    • in case error return 403 - (user is not active)
  • check nhs_legal_entity is active
    • in case error return 403 - (Client is not active)
  • Check user role = "NHS ADMIN SIGNER"
    • in case error return 403 "User is not allowed to perform this action"

Validate scopes

  • Check user scopes in order to perform this action (scope = 'contract_requests:update')
    • Return 403 in case invalid scope(s) "Your scope does not allow to access this resource. Missing allowances: contract_requests:update"

Validate data

  1. Validate contract request id.
    1. Check contract_requests.id = $.id
      1. in case error return 404 ("Contract request with id=$id doesn't exist")
  2. Validate contract_request.status=NEW
    • in case error return 422 - "Incorrect status of contract request to modify it"
  3. Validate nhs side fields are not empty - in case error return 422 "Field $ could not be empty"
    1. nhs_signer_base
    2. nhs_contract_price
    3. nhs_payment_method
    4. issue_city
  4. Validate contractor_legal_entity_id
    1. Legal_entities.id = $.contractor_legal_entity_id and Legal_entities.status='ACTIVE',
      1. in case error return 422 ("Legal entity in contract request should be active")
  5. Validate contractor_owner_id
    1. Employee status='APPROVED' and employees.legal_entity_id=contractor_legal_entity_id and employee_type='OWNER'
      1. in case error return 422, $contractor_owner_id (Contractor owner must be active within current legal entity in contract request)
  6. Validate contractor_employee_divisions
    1. Employees from employee_divisions has employee_type='DOCTOR', status='APPROVED', division is not null
      1. in case of error return 422  error view $employee ('Employee must be active DOCTOR with linked division')
    2. 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')
    3. Check employee belongs to division
      1.  in case of error return 422  error view $employee  ('Employee must be within current division')
  7. Validate start_date
    1. start_date > now()
      1. in case error return 422 $start_date ("Contract request start date should be in future")

Generate human readable contract request number

If status is changed to APPROVED AND $.contract_number is NULL - generate human readable contract request number

  • Use algorithm to generate contract request number
  • contract request number structure XXXX-1234-5678-C , where:
    • XXXX - series: numbers + only some letters (A, E, H, K, M, P, T, X)
    • 1234-5678 - randomly generated numbers and letters A, E, H, K, M, P, T, X.
    •  C - checksum: Should be calculated using the Damn algorithm or Verhoeff algorithm

Validate uniqueness of human readable contract request number

...

Generate Printout form 

After status is changed to APPROVED - generate printout form

Invoke MAN to render printuot form.

Request mapping:

Parameter
Source
idCONTRACT_REQUEST

...

fieldvalue
event_typeStatusChangeEvent
entity_typeContract_request
entity_id$.id
properties.status.new_value$.status
event_time$.update_at
changed_by$.user_id
inserted_atnow()
updated_atnow()

...