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

RC (CSI-2818) PIS. Terminate declaration_EN

Purpose

This WS is designed to terminate active declaration by Patient.

Specification

Apiary

Authorization

  1. Verify the validity of access token

    • in case of error - return 401 (“Invalid access token”) in case of validation fails

  2. Verify that token is not expired

    • in case of error - return 401 (“Invalid access token”)

  3. Check user scopes in order to perform this action (scope = 'declaration:terminate_pis')

    • return 403 (“Your scope does not allow to access this resource. Missing allowances: ‘declaration:terminate_pis’) in case of invalid scope(s)

Validation

Validate Person

  • Get person_id from token (x-person-id header)

  • Validate patient status is active (status = ‘active' & is_active = 'true’)

    • in case of error - return 404 ('not found')

  • Validate verification status of person not NOT_VERIFIED

    • in case of error - return return 403 ("Access denied. Person is not verified")

Validate confidant person and relationship (optional)

If person is not legally capable - system must ensure that declaration is terminated by confidant person and there is registered and verified their relationship

Get applicant_person_id from token, compare it to person_id from token:

Validate Declaration

  • Check that declaration with such ID:

    • exists in the system (ops DB)

    • belongs to patient

      • in case of error - return 404 ('not found')

  • Check declaration status = active

    • in case of error return 403. Message: ‘Declaration is not active’

  • Check declaration status one of the following (active, pending_verification)

    • in case of error return 409. Message: ‘Invalid declaration status’

Service logic

  1. Update declaration in ops.declarations table:

    1. set status = 'TERMINATED'

    2. set reason_description = $.reason_description from request

    3. set declarations.reason to `manual_person`

  2. Add new status to event manager

field

value

field

value

event_type

StatusChangeEvent

entity_type

Declaration

entity_id

$.id

properties.status.new_value

$.status

event_time

$.update_at

changed_by

$.changed_by

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