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

RC_Divorce acts synchronization with DRACS registry (DRACS 2.0)

Purpose

This process gets divorce acts data from the DRACS registry through Trembita exchange gateway, saves it to dracs_divorce_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 divorce act records as well as older historical divorce acts from DRACS registry.

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

Configuration

Value

Description

Example

Value

Description

Example

DRACS_DIVORCE_ACTS_SYNC_SCHEDULE

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

0 2 * * *

DRACS_DIVORCE_ACTS_SYNC_PERIOD_START

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

2022-01-01

DRACS_DIVORCE_ACTS_STATUS_UPDATE_DAYS

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

180

Service logic

1. Define act dates to be synchronized

Check the need to create divorce acts DailySynchronization job according to dracs_divorce_acts_period_updates table (MIMIR db):

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

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

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

  4. Create Divorce 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 GetDivorceArByRegDatePeriod DRACS method (described RC_DRACS Trembita methods (DRACS 2.0) | GetDivorceArByRegDatePeriod ) 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 divorce act records list.

  3. Parse obtained XML file and form a divorce acts list.

3. Save data to MIMIR database

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

dracs_divorce_acts

ArMarriageDivorceServiceAnswer

dracs_divorce_acts

ArMarriageDivorceServiceAnswer

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

mn_old_surname

MnOld_Surname

mn_surname

MnSurname

mn_name

MnName

mn_patronymic

MnPatronymic

mn_numident

MnNumident

mn_date_birth

MnDateBirth

mn_citizenship

MnCitizenship

mn_citizenship_another

MnCitizenshipAnother

mn_doc_type

MnDocType

mn_doc_name

MnDocName

mn_series_numb

MnSERIES_NUMB

mn_doc_date

MnDocDate

mn_doc_org_name

MnDocOrgName

mn_birth_state

MnBirthState

mn_birth_region

MnBirthRegion

mn_birth_district

MnBirthDistrict

mn_birth_locality_type

MnBirthLocalityType

mn_birth_locality

MnBirthLocality

mn_state

MnState

mn_region

MnRegion

mn_district

MnDistrict

mn_locality_type

MnLocalityType

mn_locality

MnLocality

mn_street

MnStreet

mn_house

MnHouse

mn_building_part

MnBuildingPart

mn_building_part_type

MnBuildingPartType

mn_apartment

MnApartment

wmn_old_surname

WmnOld_Surname

wmn_surname

WmnSurname

wmn_name

WmnName

wmn_patronymic

WmnPatronymic

wmn_numident

WmnNumident

wmn_date_birth

WmnDateBirth

wmn_citizenship

WmnCitizenship

wmn_citizenship_another

WmnCitizenshipAnother

wmn_doc_type

WmnDocType

wmn_doc_name

WmnDocName

wmn_series_numb

WmnSERIES_NUMB

wmn_doc_date

WmnDocDate

wmn_doc_org_name

WmnDocOrgName

wmn_birth_state

WmnBirthState

wmn_birth_region

WmnBirthRegion

wmn_birth_district

WmnBirthDistrict

wmn_birth_locality_type

WmnBirthLocalityType

wmn_birth_locality

WmnBirthLocality

wmn_state

WmnState

wmn_region

WmnRegion

wmn_district

WmnDistrict

wmn_locality_type

WmnLocalityType

wmn_locality

WmnLocality

wmn_street

WmnStreet

wmn_house

WmnHouse

wmn_building_part

WmnBuildingPart

wmn_building_part_type

WmnBuildingPartType

wmn_apartment

WmnApartment

  1. For each divorce act validate duplicates - check existence of divorce act in dracs_divorce_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 divorce act to dracs_divorce_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 and parties_compare_status:

        1. to ‘READY’ - if mn_old_surname <> mn_surname or wmn_old_surname <> wmn_surname

        2. to 'PROCESSED' - if mn_old_surname = mn_surname and wmn_old_surname = wmn_surname

      5. set mn_settlement_id from uadresses service using RPC call with following logic:

        1. in case (mn_locality is null or mn_locality_type = ‘Район’) - get settlement_id where settlement_name = mn_district and area_name = mn_region

        2. in case husband_locality is not null - get settlement_id where settlement_name = husband_locality and area_name = husband_region

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

        1. in case (wmn_locality is null or wmn_locality_type = ‘Район’) - get settlement_id where settlement_name = wmn_district and area_name = wmn_region

        2. in case wmn_locality is not null - get settlement_id where settlement_name = wmn_locality and area_name = wmn_region

    2. in case found:

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

        1. set updated_at = now()

      2. Else, divorce act was updated in DRACS registry. Then, check that fields of divorce 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_divorce_acts_hstr table:

            1. dracs_divorce_act_id = id of current divorce act from dracs_divorce_acts table

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

            3. inserted_at = now()

          2. fully update existing divorce act in dracs_divorce_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 mn_old_surname <> mn_surname or wmn_old_surname <> wmn_surname and ar_op_name = 1 or 4

              2. to ‘PROCESSED’ - in another cases

            2. set updated_at = now()

            3. set mn_settlement_id and wmn_settlement_id as were described above.

        2. in case none of the fields were updated:

          1. update dracs_divorce_acts table for found divorce 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 divorce acts list:

  1. in case saved divorce 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_divorce_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_divorce_act’ and enitity_id = dracs_divorce_act_id) and in the party_verification_candidates table in PRM db (with status = ‘NEW’, entity_type = ‘dracs_divorce_act’ and entity_id = dracs_divorce_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 = 'DIVORCE_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 Divorce acts DailySynchronization job details in oban_jobs table:

    1. set state = completed;

    2. set completed_at = now();

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

    1. set updated_at = now_date();

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