ЕСОЗ - публічна документація
Death acts synchronization with DRACS registry_EN
Purpose
This process gets death acts data from the DRACS registry through Trembita exchange gateway, saves it to dracs_death_acts table and prepares them for comparison processes.
Key points
This process uses cron parameter to configure its start time.
This process is used to obtain newest death act records as well as older historical death acts from DRACS registry.
This process uses Oban job processing library as jobs management tool.
Configuration
Value | Description | Example |
---|---|---|
DRACS_DEATH_ACTS_SYNC_SCHEDULE | Cron parameter, represents start time of death acts synchronization with DRACS registry process |
|
DRACS_DEATH_ACTS_SYNC_PERIOD_START | Start date from which historic death acts must be obtained in “yyyy-mm-dd” format |
|
DRACS_DEATH_ACTS_STATUS_UPDATE_DAYS | Parameter in days when existing death acts must be updated with DRACS registry again |
|
Service logic
Check the need to create DailySynchronization job for interval between DRACS_DEATH_ACTS_SYNC_PERIOD_START and now_date() - 1 day:
Make list of all distinct dates from date in DRACS_DEATH_ACTS_SYNC_PERIOD_START to now_date() - 1 day
Get all dates that are already updated from dracs_death_acts_period_updates with updated_at > now() - DRACS_DEATH_ACTS_STATUS_UPDATE_DAYS value
Get all dates that are currently being updated by daily synchronization job in oban_jobs table with state = ‘available’, ‘executing’, ‘retryable’
Compare three lists and form list of dates that must be synchronized with DRACS registry
Create DailySynchronization jobs in oban_jobs table for each day in descending order (newer dates should be synchronized first with DRACS registry) from formed list with following arguments (stored in oban_jobs.args field):
date_from = ‘date_from_list’
date_to = ‘date_from_list’
Daily synchronization job logic
Perform GetDeathArByRegDatePeriod DRACS method (described atDRACS Trembita methods | GetDeathArByRegDatePeriod) with following params:
DateFrom = args.date_from
DateTo = args.date_to
Get ResultData field from methods response and decode it from base64 to get XML file of death act records list.
Parse obtained XML file and form death acts list.
Save each death act from formed list to dracs_death_acts table in transaction according to fields matching (located in the table below)
For each death act validate duplicates - check existence of death act in dracs_death_acts table with following conditions:
ar_reg_date = ArRegDate and ar_reg_number = ArRegNumber
in case not found - insert new death act to dracs_death_acts table, also add technical data:
set id = autogenerate uuid
set inserted_at = now()
set updated_at = now()
set persons_compare_status = ‘READY’
set parties_compare_status = ‘READY'
set settlement_id from uadresses service using RPC call with following logic:
in case locality is null or locality_type = ‘Район’ - get settlement_id where settlement_name = district and area_name = region
in case locality is not null - get settlement_id where settlement_name = locality and area_name = region
in case found - check that condition
op_date = OP_DATE and ar_op_name = AR_OP_NAME
is also met for found recordin case condition is met - full duplicate of death acts already exists, update dracs_death_acts table for found record:
set updated_at = now()
in case condition is not met - death act was updated in DRACS registry, check that fields of death act in database (reg_numb, compose_date, compose_org, is_restore, name, surname, patronymic, date_birth, birth_state, birth_region, birth_district, birth_locality_type, birth_locality, sex, numident, date_death, state, region, district, locality_type, locality, street, house, apartment, doc_seizes) were updated in DRACS registry
in case at least one field was updated
save existing record to dracs_death_acts_hstr table
dracs_death_act_id = id of current death act from dracs_death_acts table
dracs_death_act_data = full data of current death act in jsonb format (without id, inserted_at and updated_at fields)
inserted_at = now()
fully update existing death act in dracs_death_acts table with new values from DRACS registry, also update technical data:
set persons_compare_status = ‘READY’
set parties_compare_status = ‘READY'
set updated_at = now()
set settlement_id from uadresses service using RPC call with following logic:
in case locality is null - get settlement_id where settlement_name = district
in case locality is not null - get settlement_id where settlement_name = locality and region_name = district
in case none of the fields were updated - update dracs_death_acts table for found death act:
set op_date = OP_DATE from response
set ar_op_name = AR_OP_NAME from response
set updated_at = now()
Update existing verification candidates according to saved death acts list:
in case saved death 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_death_acts_hstr table) - check existence of active verification candidates in MPI db (with person_verification_candidates.status = ‘NEW’, person_verification_candidates.enitity_type = ‘death_act’ and person_verification_candidates.enitity_id = dracs_death_act_id) and in PRM db (with party_verification_candidates.status = ‘NEW’, party_verification_candidates.enitity_type = ‘death_act’ and party_verification_candidates.enitity_id = dracs_death_act_id)in case found
deactivate verification candidates:
set status = ‘DEACTIVATED’
set status_reason = 'DEATH_ACT_UPDATED'
set updated_at = now()
update persons and parties compare status for death acts with
ar_op_name = 2 or 3
set persons_compare_status = ‘PROCESSED’
set parties_compare_status = ‘PROCESSED'
in case not found
update persons and parties compare status for death acts with
ar_op_name = 2 or 3
set persons_compare_status = ‘PROCESSED’
set parties_compare_status = ‘PROCESSED'
Update DailySynchronization job details in oban_jobs table:
set state = completed;
set completed_at = now();
Update or insert into dracs_death_acts_period_updates details for dates that were successfully synchronized with DRACS registry:
set updated_at = now_date();
ЕСОЗ - публічна документація