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

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Purpose

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

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

Configuration

Value

Description

Example

DRACS_MARRIAGE_ACTS_SYNC_SCHEDULE

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

0 2 * * *

DRACS_MARRIAGE_ACTS_SYNC_PERIOD_START

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

2022-01-01

DRACS_MARRIAGE_ACTS_STATUS_UPDATE_DAYS

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

180

Service logic

1. Define act dates to be synchronized

Check the need to create marriage acts DailySynchronization job according to dracs_marriage_acts_period_updates table (MIMIR db):

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

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

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

  4. Create Marriage 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 GetMarriageArByRegDatePeriod DRACS method (described at https://e-health-ua.atlassian.net/wiki/spaces/DRACS2/pages/17858101249/UPD+DRACS+Trembita+methods#GetMarriageArByRegDatePeriod) 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 marriage act records list.

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

3. Save data to MIMIR database

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

 dracs_marriage_acts to GetMarriageArByRegDatePeriod response fields matching

dracs_marriage_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

husband_old_surname

HusbandOld_Surname

husband_surname

HusbandSurname

husband_name

HusbandName

husband_patronymic

HusbandPatronymic

husband_numident

HusbandNumident

husband_date_birth

HusbandDateBirth

husband_citizenship

HusbandCitizenship

husband_citizenship_another

HusbandCitizenshipAnother

husband_doc_type

HusbandDocType

husband_doc_name

HusbandDocName

husband_series_numb

HusbandSERIES_NUMB

husband_doc_date

HusbandDocDate

husband_doc_org_name

HusbandDocOrgName

husband_birth_state

HusbandBirthState

husband_birth_region

HusbandBirthRegion

husband_birth_district

HusbandBirthDistrict

husband_birth_locality_type

HusbandBirthLocalityType

husband_birth_locality

HusbandBirthLocality

husband_state

HusbandState

husband_region

HusbandRegion

husband_district

HusbandDistrict

husband_locality_type

HusbandLocalityType

husband_locality

HusbandLocality

husband_street

HusbandStreet

husband_house

HusbandHouse

husband_building_part

HusbandBuildingPart

husband_building_part_type

HusbandBuildingPartType

husband_apartment

HusbandApartment

wife_old_surname

WifeOld_Surname

wife_surname

WifeSurname

wife_name

WifeName

wife_patronymic

WifePatronymic

wife_numident

WifeNumident

wife_date_birth

WifeDateBirth

wife_citizenship

WifeCitizenship

wife_citizenship_another

WifeCitizenshipAnother

wife_doc_type

WifeDocType

wife_doc_name

WifeDocName

wife_series_numb

WifeSERIES_NUMB

wife_doc_date

WifeDocDate

wife_doc_org_name

WifeDocOrgName

wife_birth_state

WifeBirthState

wife_birth_region

WifeBirthRegion

wife_birth_district

WifeBirthDistrict

wife_birth_locality_type

WifeBirthLocalityType

wife_birth_locality

WifeBirthLocality

wife_state

WifeState

wife_region

WifeRegion

wife_district

WifeDistrict

wife_locality_type

WifeLocalityType

wife_locality

WifeLocality

wife_street

WifeStreet

wife_house

WifeHouse

wife_building_part

WifeBuildingPart

wife_building_part_type

WifeBuildingPartType

wife_apartment

WifeApartment

  1. For each marriage act validate duplicates - check existence of marriage act in dracs_marriage_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 marriage act to dracs_marriage_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 husband_old_surname <> husband_surname or wife_old_surname <> wife_surname, and these fields are not empty

        2. to 'PROCESSED' - if husband_old_surname = husband_surname and wife_old_surname = wife_surname

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

        1. in case (husband_locality is null or husband_locality_type = ‘Район’) - get settlement_id where settlement_name = husband_district and area_name = husband_region

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

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

        1. in case (wife_locality is null or wife_locality_type = ‘Район’) - get settlement_id where settlement_name = wife_district and area_name = wife_region

        2. in case wife_locality is not null - get settlement_id where settlement_name = wife_locality and area_name = wife_region

    2. in case found:

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

        1. set updated_at = now()

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

            1. dracs_marriage_act_id = id of current marriage act from dracs_marriage_acts table

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

            3. inserted_at = now()

          2. fully update existing marriage act in dracs_marriage_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 husband_old_surname <> husband_surname or wife_old_surname <> wife_surname and ar_op_name = 1 or 4 (surname fields are not empty)

              2. to ‘PROCESSED’ - in another cases

            2. set updated_at = now()

            3. set husband_settlement_id and wife_settlement_id as were described above.

        2. in case none of the fields were updated:

          1. update dracs_marriage_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 marriage acts list:

  1. in case saved marriage 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_marriage_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_marriage_act’ and enitity_id = dracs_marriage_act_id) and in the party_verification_candidates table in PRM db (with status = ‘NEW’, entity_type = ‘dracs_marriage_act’ and entity_id = dracs_marriage_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 = 'MARRIAGE_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 Marriage acts DailySynchronization job details in oban_jobs table:

    1. set state = completed;

    2. set completed_at = now();

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

    1. set updated_at = now_date();

  • No labels