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

RC_warranty_Active person search algorithm

Purpose

This algorithm is used to search for active person based on a fixed dataset.

This algorithm is used in following WS:

Key points

  1. This algorithm uses dataset data to get id of active person from mpi database.

  2. This algorithm uses tax_id or document as primary search parameters, so one of these fields must be present. Last name and given name are mandatory.

  3. If active person can not be identified clearly with dataset, error is returned.

  4. This algorithm can be used in different processes and is not limited to specific process.

Specification

{ "tax_id": "2323232323", "document": { "type": "PASSPORT", "number": "СТ123123" }, "last_name": "Петров", "given_name": "Петро Петрович" }

Diagram

 

Source:

Validate dataset

  • Check dataset contains all mandatory fields (tax_id or document.type and document.number, last_name, given_name)

    • in case of error - return ('tax_id or document, last_name, given_name fields are mandatory for search')

  • Check tax_id field from dataset equals to following regexp: ^[0-9]{10}$

    • in case of error - return ('Invalid tax_id format for active person search')

  • Check document.type field from dataset contains document type that is a value from DOCUMENT_TYPE dictionary

    • in case of error - return ('Invalid document type for active person search')

  • Check document.type field from dataset contains document type that is allowed to use for active person search, field value exists in ACTIVE_PERSON_SEARCH_DOCUMENT_TYPES config parameter

    • in case of error - return ('Forbidden document type for active person search')

  • Check document.number field from dataset equals to following regexp (for each document.type):

    • PASSPORT, COMPLEMENTARY_PROTECTION_CERTIFICATE, REFUGEE_CERTIFICATE – ^((?![ЫЪЭЁ])([А-ЯҐЇІЄ])){2}[0-9]{6}$

    • NATIONAL_ID – ^[0-9]{9}$

    • BIRTH_CERTIFICATE, TEMPORARY_PASSPORT – ^((?![ЫЪЭЁыъэё@%&$^#`~:,.*|}{?!])[A-ZА-ЯҐЇІЄ0-9№\/()-]){2,25}$

    • TEMPORARY_CERTIFICATE – ^(((?![ЫЪЭЁ])([А-ЯҐЇІЄ])){2}[0-9]{4,6}|[0-9]{9}|((?![ЫЪЭЁ])([А-ЯҐЇІЄ])){2}[0-9]{5}\/[0-9]{5})$

    • BIRTH_CERTIFICATE_FOREIGN, PERMANENT_RESIDENCE_PERMIT – string value between 1 and 255 characters

      • in case of error - return ('Invalid document number for active person search')

Service logic

  1. Get active person search dataset, check its format:

    1. if dataset contains field ‘tax_id’, use ‘persons.tax_id’ value as primary search condition.

    2. if dataset contains field ‘document’, use ‘person_documents.number’ and ‘person_documents.type’ as primary search condition.

  2. Perform primary search for active persons (status = ‘active’ and is_active = true) in mpi database using one of conditions from p.1:

    1. in case query returned 0 records - return error ‘No active person found’, end search.

    2. in case query returned 1 or more records - proceed to p.3.

  3. Filter obtained active persons records with ‘document’ field with following logic:

    1. if primary search was performed with ‘tax_id’ search condition and dataset contains field ‘document’, filter active persons with ‘person_documents.number’ = ‘dataset.document.number’ and ‘person_documents.type’ = ‘dataset.document.type’

      1. in case filtered query returned 0 records - return error ‘No active person found’, end search.

      2. in case filtered query returned 1 or more records - proceed to p.4.

    2. if primary search was performed with ‘tax_id’ search condition and dataset does not contain field ‘document’ or primary search was performed with ‘document’ search condition - proceed to p.4.

  4. Filter obtained active persons records with ‘last_name’ field with following steps:

    1. perform normalization of ‘persons.last_name’ field of found active persons and ‘dataset.last_name’ field

    2. check ‘persons.last_name’ field of found active persons equals to ‘dataset.last_name’ field

      1. in case filtered query returned 0 records - return error ‘No active person found’, end search.

      2. in case filtered query returned 1 or more records - proceed to p.5.

  5. Filter obtained active persons records with ‘given_name’ field with following steps: ('persons.first_name' equals to or is present in ‘dataset.given_name’):

    1. perform normalization of concatenated ‘persons.first_name’ and ‘persons.second_name’ fields of found active persons and ‘dataset.given_name’ field

    2. check concatenated ‘persons.first_name’ and ‘persons.second_name’ fields of found active persons equals ‘dataset.given_name’ field

      1. in case filtered query returned 0 records - return error ‘No active person found’, end search.

      2. in case filtered query returned 1 record - use person_id as a result, end search.

      3. in case filtered query returned more than 1 record - return error ‘Impossible to clearly identify an active person’, end search.

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