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

RC_Change name acts synchronization with DRACS registry (DRACS 2.0)

Purpose

This process gets change name acts data from the DRACS registry through Trembita exchange gateway, saves it to dracs_change_name_acts table and prepares them for comparison processes.

Key points

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

  2. This process is used to obtain newest change name act records as well as older historical change name acts from DRACS registry.

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

Configuration

Value

Description

Example

Value

Description

Example

DRACS_CHANGE_NAME_ACTS_SYNC_SCHEDULE

Cron parameter, represents start time of change name acts synchronization with DRACS registry process

0 2 * * *

DRACS_CHANGE_NAME_ACTS_SYNC_PERIOD_START

Start date from which historic change name acts must be obtained in “yyyy-mm-dd” format

2022-01-01

DRACS_CHANGE_NAME_ACTS_STATUS_UPDATE_DAYS

Parameter in days when existing change name acts must be updated with DRACS registry again

180

Service logic

1. Define act dates to be synchronized

Check the need to create change name acts DailySynchronization job according to dracs_change_name_acts_period_updates table (MIMIR db):

  1. Make list of all distinct dates from date in range from DRACS_CHANGE_NAME_ACTS_SYNC_PERIOD_START to now_date() - 1 day

  2. Exclude all dates that has been already updated with updated_at > now() - DRACS_CHANGE_NAME_ACTS_STATUS_UPDATE_DAYS value

  3. Exclude all dates that are currently being updated by change name acts daily synchronization job in oban_jobs table with state = ‘available’, ‘executing’, ‘retryable’

  4. Create Change name act DailySynchronization jobs in oban_jobs table for each date in descending order (newer dates should be synchronized first with DRACS registry) from formed list with following arguments (stored in oban_jobs.args field):

    1. args.date_from = ‘date_from_list’

    2. args.date_to = ‘date_from_list’

2. Request data from Trembita

  1. Perform GetChangeNameArByRegDatePeriod DRACS method (described at https://e-health-ua.atlassian.net/wiki/spaces/DRACS2/pages/17858101249/UPD+DRACS+Trembita+methods#GetChangeNameArByRegDatePeriod) with following params:

    1. DateFrom = args.date_from

    2. DateTo = args.date_to

  2. Get ResultData field from method's response and decode it from base64 to get XML file of change name act records list.

  3. Parse obtained XML file and form a change name acts list.

3. Save data to MIMIR database

Save each change name act from the formed list into dracs_change_name_acts table in transaction according to fields matching (located in the table below):

dracs_change_name_acts

ArChangeNameServiceAnswer

dracs_change_name_acts

ArChangeNameServiceAnswer

ar_reg_date

ArRegDate

ar_reg_number

ArRegNumber

op_date

OP_DATE

ar_op_name

AR_OP_NAME

reg_numb

RegNumb

compose_date

СomposeDate

compose_org

ComposeOrg

is_restore

IS_RESTORE

old_surname

Old_Surname

old_name

Old_Name

old_patronymic

Old_Patronymic

new_surname

New_Surname

new_name

New_Name

new_patronymic

New_Patronymic

numident

Numident

date_birth

DateBirth

sex

Sex

citizenship

Citizenship

citizenship_another

CitizenshipAnother

doc_type

DocType

doc_name

DocName

series_numb

SERIES_NUMB

doc_date

DocDate

doc_org_name

DocOrgName

birth_state

BirthState

birth_region

BirthRegion

birth_district

BirthDistrict

birth_locality_type

BirthLocalityType

birth_locality

BirthLocality

state

State

region

Region

district

District

locality_type

LocalityType

locality

Locality

street

Street

house

House

building_part

BuildingPart

building_part_type

BuildingPartType

apartment

Apartment

  1. For each change name act validate duplicates - check existence of change name act in dracs_change_name_acts table with following conditions: ar_reg_date = ArRegDate and ar_reg_number = ArRegNumber

    1. in case not found and ar_op_name = 1 or 4 - insert new change name act to dracs_change_name_acts table, also add technical data:

      1. set id = autogenerate uuid

      2. set inserted_at = now()

      3. set updated_at = now()

      4. set persons_compare_status = ‘READY’

      5. set parties_compare_status = ‘READY’

      6. set settlement_id from uadresses service using RPC call with following logic:

        1. in case (locality is null or locality_type = ‘Район’) - get settlement_id where settlement_name = district and area_name = region

        2. in case locality is not null - get settlement_id where settlement_name = locality and area_name = region

    2. in case found:

      1. If op_date = OP_DATE and ar_op_name = AR_OP_NAME . So, full duplicate of change name act already exists, then update dracs_change_name_acts table for found record:

        1. set updated_at = now()

      2. Else, change name act was updated in DRACS registry. Then, check that fields of change name act in database (according to fields matching, but exclude technical fields ar_reg_date, ar_reg_number, op_date, ar_op_name) were updated in DRACS registry:

        1. in case at least one field was updated:

          1. save existing record to dracs_change_name_acts_hstr table:

            1. dracs_change_name_act_id = id of current change name act from dracs_change_name_acts table

            2. dracs_change_name_act_data = full data of current change name act in jsonb format (without id, inserted_at and updated_at fields)

            3. inserted_at = now()

          2. fully update existing change name act in dracs_change_name_acts table with new values from DRACS registry, also update technical data:

            1. set persons_compare_status and parties_compare_status fields:

              1. to ‘READY’ - if ar_op_name = 1 or 4

              2. to ‘PROCESSED’ - in another cases

            2. set updated_at = now()

            3. set settlement_id as were described above.

        2. in case none of the fields were updated:

          1. update dracs_change_name_acts table for found marriage act:

            1. set op_date = OP_DATE from response

            2. set ar_op_name = AR_OP_NAME from response

            3. set updated_at = now()

4. Update verification candidates

Update existing verification candidates according to saved change name acts list:

  1. In case saved change name act is cancelled (ar_op_name = 2 or 3) or fully updated from DRACS (ar_op_name = 4 and existing act was saved to dracs_change_name_acts_hstr table):

    1. Check existence of active verification candidates with the act in the person_verification_candidates table in MPI db (with status = ‘NEW’, entity_type = ‘dracs_change_name_act’ and enitity_id = dracs_change_name_act_id) and in the party_verification_candidates table in PRM db (with status = ‘NEW’, entity_type = ‘dracs_change_name_act’ and entity_id = dracs_change_name_act_id)

      1. in case found:

        1. Deactivate each verification candidate updating following fields in the person_verification_candidates table or party_verification_candidates table:

          1. set status = ‘DEACTIVATED’

          2. set status_reason = 'CHANGE_NAME_ACT_UPDATED'

          3. set updated_at = now()

        2. Check existence of other active verification candidates with the person in the person_verification_candidates table in MPI db (with status = ‘NEW’, entity_type in ‘dracs_marriage_act’, ‘dracs_divorce_act’, ‘dracs_change_name_act’) or with the party in party_verification_candidates in PRM db (with status = ‘NEW’, entity_type in ‘dracs_marriage_act’, ‘dracs_divorce_act’, ‘dracs_change_name_act’) from each deactivated candidate

          1. in case no more active verification candidates found for person or party, update its verification status in person_verifications or party_verifications table:

            1. set dracs_name_change_verification_status = ‘VERIFIED’

            2. set dracs_name_change_verification_reason = ‘AUTO_OFFLINE’

            3. set updated_at = now()

5. Complete the job

  1. Update Change name acts DailySynchronization job details in oban_jobs table:

    1. set state = completed;

    2. set completed_at = now();

  2. Update or insert into dracs_change_name_acts_period_updates table details for dates that were successfully synchronized with DRACS registry:

    1. set updated_at = now_date();

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