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

RC_DRACS certificates synchronization for Person (DRACS 2.0)

Purpose

This process gets certificates data of specific person from the DRACS registry through Trembita exchange gateway and uses it for further comparison with person.

Key points

  1. This process uses cron parameter to configure its start time.

  2. This process is used to obtain all cerificates of specified type of person from DRACS registry.

  3. This process is used to verify persons legal capacity (by documents with type MARRIAGE_CERTIFICATE, DIVORCE_CERTIFICATE).

  4. This process gets limited amount of persons for synchronization with DRACS certificates registry.

  5. This process uses Oban job processing library as jobs management tool.

Configuration

Value

Description

Example

Value

Description

Example

DRACS_CERTIFICATES_PERSONS_SYNCHRONIZATION_SCHEDULE

Cron parameter, represents start time of Persons synchronization with DRACS certificates registry process

*/3 * * * *

DRACS_CERTIFICATES_PERSONS_SYNCHRONIZATION_BATCH_SIZE

Size of Persons list that will be synchronized online with DRACS certificates registry

100

Service logic

Step 1. Prepare list of Persons to be synced

Get the list of active Persons (status=active, is_active=true) who meet the following criteria:

  • mpi.person_verifications.legal_capacity_verification_status = VERIFICATION_NEEDED and legal_capacity_verification_reason = ONLINE_TRIGGERED

Order selected records in descending way by person_verifications.updated_at

Update person_verifications record by person_id:

  • legal_capacity_verification_status = IN_REVIEW

  • legal_capacity_verification_reason = AUTO_ONLINE

Step 1.1. Update Person

Make data pre-estimation for a synchronization:

  1. If a person has no certificate document that can be synched (MARRIAGE_CERTIFICATE or DIVORCE_CERTIFICATE) at all, then update person_verifications record by person_id:

    1. legal_capacity_verification_status = VERIFICATION_NOT_NEEDED

    2. legal_capacity_verification_reason = AUTO_DATA_ABSENT

    3. legal_capacity_entity_id = null

    4. legal_capacity_entity_type = null

    5. legal_capacity_unverified_at = null

  2. If a person has both legal capacity documents that can be synched (MARRIAGE_CERTIFICATE and DIVORCE_CERTIFICATE), then use legal capacity document with greater issued_at date for corresponding steps

    • if both documents have the same issued_at date - use DIVORCE_CERTIFICATE data for the corresponding steps;

  3. If a person has legal capacity document that can be synched (MARRIAGE_CERTIFICATE or DIVORCE_CERTIFICATE) but document number can not be parsed into separate serial and number fields using rules: number – get only digits from the end of the documents.number, serials – get everything else from documents.number (without digits for number), then update person_verifications record by person_id:

    1. legal_capacity_verification_status = NOT_VERIFIED

    2. legal_capacity_verification_reason = AUTO_INCORRECT_DATA

    3. legal_capacity_entity_id = null

    4. legal_capacity_entity_type = null

    5. legal_capacity_unverified_at = now()

Step 2. Get Person certificate from DRACS

Check person’s certificate – invoke RPC call with third-party GetCertByNumRoleNames service using the following request params:

  • ByParam - based on persons legal capacity document:

    • if person has MARRIAGE_CERTIFICATE = set 4

    • if person has DIVORCE_CERTIFICATE = set 5

  • Role - based on persons gender and legal capacity document:

    • if persons gender in FEMALE and person has MARRIAGE_CERTIFICATE = set 2

    • if persons gender is MALE and person has MARRIAGE_CERTIFICATE = set 3

    • if persons gender in FEMALE and person has DIVORCE_CERTIFICATE = set 6

    • if persons gender is MALE and person has DIVORCE_CERTIFICATE = set 5

  • CertNumber = get only digits from the end of the documents.number

  • CertSerial = get everything else from documents.number (without digits for CertNumber)

  • Surname = mpi.persons.last_name

  • Name = mpi.persons.first_name

  • Patronymic = mpi.persons.second_name (skip if empty)

Step 3. Prepare obtained certificates

If GetCertByNumRoleNames call in Step 2 was successful and ResultCode = 0, parse obtained XML file and form certs list.

Get only active certificates (with CertStatus = 1), skip records with any other status.

If marriage certs were requested (ByParam = 4), save each cert from formed list to dracs_marriage_certs table in transaction according to fields matching:

dracs_marriage_certs

GetCertByNumRoleNames

dracs_marriage_certs

GetCertByNumRoleNames

cert_status

CertStatus

cert_repeat

CertRepeat

cert_serial

CertSerial

cert_number

CertNumber

cert_serialnumber 

CertSerialNumber 

cert_org

CertOrg

cert_date

CertDate

ar_org

ArOrg

ar_numb

AR_NUMB

ar_composedate

AR_COMPOSEDATE

husband_old_surname

HusbandOld_Surname

husband_surname

HusbandSurname

husband_name

HusbandName

husband_patronymic

HusbandPatronymic

husband_citizenship

HusbandCitizenship

husband_citizenship_another

HusbandCitizenshipAnother

husband_date_birth

HusbandBirthdate

husband_place_of_birth

HusbandPlaceofBirth

wife_old_surname

WifeOld_Surname

wife_surname

WifeSurname

wife_name

WifeName

wife_patronymic

WifePatronymic

wife_citizenship

WifeCitizenship

wife_citizenship_another

WifeCitizenship Another

wife_date_birth

WifeBirthdate

wife_place_of_birth

WifePlaceofBirth

For each certificate validate duplicates - check existence of marriage certificate in dracs_marriage_certs table with following conditions: cert_serial = CertSerial and cert_number = CertNumber and cert_status = CertStatus and ar_numb = AR_NUMB and ar_composedate = AR_COMPOSEDATE

  1. in case not found - insert new marriage certificate record to dracs_marriage_certs table, also add technical data:

    1. set id = autogenerate uuid

    2. set inserted_at = now()

    3. set updated_at = now()

  2. in case found - do not insert marriage certificate, use existing record for next steps.

If divorce certs were requested (ByParam = 5), save each cert from formed list to dracs_divorce_certs table in transaction according to fields matching:

dracs_divorce_certs

GetCertByNumRoleNames

dracs_divorce_certs

GetCertByNumRoleNames

cert_status

CertStatus

cert_repeat

CertRepeat

cert_serial

CertSerial

cert_number

CertNumber

cert_serialnumber 

CertSerialNumber 

cert_org

CertOrg

cert_date

CertDate

receiver

Receiver

ar_org

ArOrg

ar_numb

AR_NUMB

ar_composedate

AR_COMPOSEDATE

husband_old_surname

HusbandOld_Surname

husband_surname

HusbandSurname

husband_name

HusbandName

husband_patronymic

HusbandPatronymic

wife_old_surname

WifeOld_Surname

wife_surname

WifeSurname

wife_name

WifeName

wife_patronymic

WifePatronymic

For each certificate validate duplicates - check existence of divorce certificate in dracs_divorce_certs table with following conditions: cert_serial = CertSerial and cert_number = CertNumber and cert_status = CertStatus and ar_numb = AR_NUMB and ar_composedate = AR_COMPOSEDATE

  1. in case not found - insert new divorce certificate record to dracs_divorce_certs table, also add technical data:

    1. set id = autogenerate uuid

    2. set inserted_at = now()

    3. set updated_at = now()

  2. in case found - do not insert divorce certificate, use existing record for next steps.

Step 3.1. Technical error returned

In case GetCertByNumRoleNames ResultCode <> 0 or connection error or timeout is occured - check that persons legal_capacity_verification_status = ‘IN_REVIEW’

  1. if true - rollback it in person_verifications table in MPI db for person_id to previous state

  2. if false - skip this person, go to next person in list.

Step 4. Verify Persons legal capacity

Check that person_verifications.legal_capacity_verification_status equals to IN_REVIEW (because if changed to any other status, then its mean that person record has been changed while current sync with DRACS certificates performed, or person should not be synchronized by DRACS certificates):

  • if equals – invoke this Step.

  • if not equal – skip this Step, go to Step 5.

In case no active marriage or divorce certificate for a person was found, update person_verifications table in MPI db for person_id, set values:

  • legal_capacity_verification_status = NOT_VERIFIED

  • legal_capacity_verification_reason = AUTO_NOT_FOUND

  • legal_capacity_entity_id = null

  • legal_capacity_entity_type = null

  • legal_capacity_unverified_at = now()

In case active marriage or divorce certificate for a person was found:

Step 5. Select next Person

Select the next person from the obtained list and return to Step 2 of the process.

  1. in case no more persons are available - end the process.

 

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