ЕСОЗ - публічна документація
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:
TRUSTED PIS. Patient sign-in | Search or create user
TRUSTED PIS. Confidant patient sign-in
Key points
This algorithm uses dataset data to get id of active person from mpi database.
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.
If active person can not be identified clearly with dataset, error is returned.
This algorithm can be used in different processes and is not limited to specific process.
Specification
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 dictionaryin 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 parameterin case of error - return ('Forbidden document type for active person search')
Check
document.number
field from dataset equals to following regexp (for eachdocument.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
Get active person search dataset, check its format:
if dataset contains field ‘tax_id’, use ‘persons.tax_id’ value as primary search condition.
if dataset contains field ‘document’, use ‘person_documents.number’ and ‘person_documents.type’ as primary search condition.
Perform primary search for active persons (status = ‘active’ and is_active = true) in mpi database using one of conditions from p.1:
in case query returned 0 records - return error ‘No active person found’, end search.
in case query returned 1 or more records - proceed to p.3.
Filter obtained active persons records with ‘document’ field with following logic:
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’
in case filtered query returned 0 records - return error ‘No active person found’, end search.
in case filtered query returned 1 or more records - proceed to p.4.
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.
Filter obtained active persons records with ‘last_name’ field with following steps:
perform normalization of ‘persons.last_name’ field of found active persons and ‘dataset.last_name’ field
check ‘persons.last_name’ field of found active persons equals to ‘dataset.last_name’ field
in case filtered query returned 0 records - return error ‘No active person found’, end search.
in case filtered query returned 1 or more records - proceed to p.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’):
perform normalization of concatenated ‘persons.first_name’ and ‘persons.second_name’ fields of found active persons and ‘dataset.given_name’ field
check concatenated ‘persons.first_name’ and ‘persons.second_name’ fields of found active persons equals ‘dataset.given_name’ field
in case filtered query returned 0 records - return error ‘No active person found’, end search.
in case filtered query returned 1 record - use
person_id
as a result, end search.in case filtered query returned more than 1 record - return error ‘Impossible to clearly identify an active person’, end search.
ЕСОЗ - публічна документація