-- Screen and Data group permissions --
SET @pim_module_id = (SELECT `id` FROM `ohrm_module` WHERE `name`='pim');
INSERT INTO `ohrm_screen` (`name`, `module_id`, `action_url`, `route_name`) VALUES
    ('Employee Data Export', @pim_module_id, 'manageDataEmployeeInformationReport', NULL);

SET @employee_data_export_screen_id = (SELECT `id` FROM `ohrm_screen` WHERE `name`='Employee Data Export');

INSERT INTO `ohrm_data_group` (`name`, `description`, `can_read`, `can_create`, `can_update`, `can_delete`) VALUES
    ('employee_data_export', 'Employee Management - Employee Data Export', '1', '0', '0', '0');

SET @employee_data_export_datagroup_id = (SELECT `id` FROM `ohrm_data_group` WHERE `name`='employee_data_export');
SET @sys_admin_role_id = (SELECT `id` FROM `ohrm_user_role` WHERE `name`='ConfigAdmin');
INSERT INTO `ohrm_user_role_data_group` (`user_role_id`, `data_group_id`, `can_read`, `can_create`, `can_update`, `can_delete`, `self`, `restriction_id`) VALUES
    (@sys_admin_role_id, @employee_data_export_datagroup_id, '1', '1', '1', '1', '0', NULL);

INSERT INTO `ohrm_user_role_screen` (`user_role_id`, `screen_id`, `can_read`, `can_create`, `can_update`, `can_delete`) VALUES
    ('1', @employee_data_export_screen_id, '1', '1', '1', '1');

SET @employee_data_export_datagroup_id = (SELECT `id` FROM `ohrm_data_group` WHERE `name`='employee_data_export');
SET @admin_user_role_id = (SELECT `id` FROM `ohrm_user_role` WHERE `name`='Admin');
INSERT INTO `ohrm_user_role_data_group` (`user_role_id`, `data_group_id`, `can_read`, `can_create`, `can_update`, `can_delete`, `self`, `restriction_id`) VALUES
    (@admin_user_role_id, @employee_data_export_datagroup_id, '1', '0', '0', '0', '0', NULL);

INSERT INTO `ohrm_data_group_screen` (`data_group_id`, `screen_id`, `permission`, `self`) VALUES
    (@employee_data_export_datagroup_id, @employee_data_export_screen_id, '1', '0');

SET @admin_user_role_type = (SELECT `id` FROM `ohrm_user_role_type` WHERE `name`='Admin');
INSERT INTO `ohrm_user_role_type_data_group` (`user_role_type_id`, `data_group_id`, `can_read`, `can_create`, `can_update`, `can_delete`) VALUES
    (@admin_user_role_type, @employee_data_export_datagroup_id, '1', '0', '0', '0');

-- ESB Queue Tags --
INSERT INTO `ohrm_external_async_event_tag` (`name`, `description`, `enabled`) VALUES
    ('payroll_changed_employee', 'This tag is for changed employee related events', 1),
    ('payroll_changed_employee_with_future_effective', 'This tag is for changed employee related events future effective events are notified on that date', 1);

INSERT INTO `ohrm_external_async_event_queue` (`name`, `description`, `enabled`, `is_delayed`) VALUES
    ('Queue_For_Changed_Employee_Detection', 'This queue is for changed employee detection related events', 1, 0),
    ('Queue_For_Changed_Employee_Detection_With_Future_Effective', 'This queue is for integration related events with future effective events notified when that future date is reached', 1, 0);

SET @changed_employee_queue_id := (SELECT `id` FROM `ohrm_external_async_event_queue` WHERE `name`='Queue_For_Changed_Employee_Detection');
SET @changed_employee_future_effective_queue_id := (SELECT `id` FROM `ohrm_external_async_event_queue` WHERE `name`='Queue_For_Changed_Employee_Detection_With_Future_Effective');

SET @changed_employee_tag_id = (SELECT id FROM `ohrm_external_async_event_tag` WHERE name = 'payroll_changed_employee');
SET @changed_employee_future_effective_tag_id = (SELECT id FROM `ohrm_external_async_event_tag` WHERE name = 'payroll_changed_employee_with_future_effective');

SET @employe_added_event_id = (SELECT id FROM `ohrm_async_event` WHERE name = 'employee_added');
INSERT INTO `ohrm_external_async_event_event_tag` (`event_id`, `tag_id`) VALUES
    (@employe_added_event_id, @changed_employee_tag_id),
    (@employe_added_event_id, @changed_employee_future_effective_tag_id);

SET @employe_updated_event_id = (SELECT id FROM `ohrm_async_event` WHERE name = 'employee_updated');
INSERT INTO `ohrm_external_async_event_event_tag` (`event_id`, `tag_id`) VALUES
    (@employe_updated_event_id, @changed_employee_tag_id),
    (@employe_updated_event_id, @changed_employee_future_effective_tag_id);

SET @direct_deposit_updated_event_id = (SELECT id FROM `ohrm_async_event` WHERE name = 'pim.save_direct_deposit_record');
INSERT INTO `ohrm_external_async_event_event_tag` (`event_id`, `tag_id`) VALUES
    (@direct_deposit_updated_event_id, @changed_employee_tag_id),
    (@direct_deposit_updated_event_id, @changed_employee_future_effective_tag_id);

SET @salary_record_updated_event_id = (SELECT id FROM `ohrm_async_event` WHERE name = 'pim.save_salary_record');
INSERT INTO `ohrm_external_async_event_event_tag` (`event_id`, `tag_id`) VALUES
    (@salary_record_updated_event_id, @changed_employee_tag_id),
    (@salary_record_updated_event_id, @changed_employee_future_effective_tag_id);

SET @job_history_updated_event_id = (SELECT id FROM `ohrm_async_event` WHERE name = 'pim.save_job_record');
INSERT INTO `ohrm_external_async_event_event_tag` (`event_id`, `tag_id`) VALUES
    (@job_history_updated_event_id, @changed_employee_tag_id),
    (@job_history_updated_event_id, @changed_employee_future_effective_tag_id);

SET @custom_field_update_event_id = (SELECT id FROM `ohrm_async_event` WHERE name = 'pim.custom_field_value_update');
INSERT INTO `ohrm_external_async_event_event_tag` (`event_id`, `tag_id`) VALUES
    (@custom_field_update_event_id, @changed_employee_tag_id),
    (@custom_field_update_event_id, @changed_employee_future_effective_tag_id);

SET @custom_field_delete_event_id = (SELECT id FROM `ohrm_async_event` WHERE name = 'pim.custom_field_value_delete');
INSERT INTO `ohrm_external_async_event_event_tag` (`event_id`, `tag_id`) VALUES
    (@custom_field_delete_event_id, @changed_employee_tag_id),
    (@custom_field_delete_event_id, @changed_employee_future_effective_tag_id);

-- Delta Report Changes for Payrolls
SET @employee_terminated_event_id = (SELECT id FROM `ohrm_async_event` WHERE name = 'employees_terminated');
INSERT INTO `ohrm_external_async_event_event_tag` (`event_id`, `tag_id`) VALUES
    (@employee_terminated_event_id, @changed_employee_tag_id),
    (@employee_terminated_event_id, @changed_employee_future_effective_tag_id);

SET @employee_activated_event_id = (SELECT id FROM `ohrm_async_event` WHERE name = 'employees_activated');
INSERT INTO `ohrm_external_async_event_event_tag` (`event_id`, `tag_id`) VALUES
    (@employee_activated_event_id, @changed_employee_tag_id),
    (@employee_activated_event_id, @changed_employee_future_effective_tag_id);

SET @direct_deposit_deleted_event_id = (SELECT id FROM `ohrm_async_event` WHERE name = 'pim.delete_direct_deposit_record');
INSERT INTO `ohrm_external_async_event_event_tag` (`event_id`, `tag_id`) VALUES
    (@direct_deposit_deleted_event_id, @changed_employee_tag_id),
    (@direct_deposit_deleted_event_id, @changed_employee_future_effective_tag_id);

SET @job_change_effective_date_reached = (SELECT id FROM `ohrm_async_event` WHERE name = 'pim.job_change_effective_date_reached');
INSERT INTO `ohrm_external_async_event_event_tag` (`event_id`, `tag_id`) VALUES
    (@job_change_effective_date_reached, @changed_employee_future_effective_tag_id);

SET @custom_field_change_effective_date_reached = (SELECT id FROM `ohrm_async_event` WHERE name = 'pim.custom_field_change_effective_date_reached');
INSERT INTO `ohrm_external_async_event_event_tag` (`event_id`, `tag_id`) VALUES
    (@custom_field_change_effective_date_reached, @changed_employee_future_effective_tag_id);

SET @salary_change_effective_date_reached = (SELECT id FROM `ohrm_async_event` WHERE name = 'pim.salary_change_effective_date_reached');
INSERT INTO `ohrm_external_async_event_event_tag` (`event_id`, `tag_id`) VALUES
    (@salary_change_effective_date_reached, @changed_employee_future_effective_tag_id);

SET @joined_date_reached = (SELECT id FROM `ohrm_async_event` WHERE name = 'pim.first_time_joined_date_reached');
INSERT INTO `ohrm_external_async_event_event_tag` (`event_id`, `tag_id`) VALUES
    (@joined_date_reached, @changed_employee_future_effective_tag_id);

SET @current_job_record_update_due_to_delete_event_id = (SELECT id FROM `ohrm_async_event` WHERE name = 'pim.current_job_record_updated_due_to_history_delete');
INSERT INTO `ohrm_external_async_event_event_tag` (`event_id`, `tag_id`) VALUES
    (@current_job_record_update_due_to_delete_event_id, @changed_employee_future_effective_tag_id);

SET @current_salary_record_update_due_to_delete_event_id = (SELECT id FROM `ohrm_async_event` WHERE name = 'pim.current_salary_record_updated_due_to_history_delete');
INSERT INTO `ohrm_external_async_event_event_tag` (`event_id`, `tag_id`) VALUES
    (@current_salary_record_update_due_to_delete_event_id, @changed_employee_future_effective_tag_id);

SET @latest_job_record_update_due_to_delete_event_id = (SELECT id FROM `ohrm_async_event` WHERE name = 'pim.latest_job_record_updated_due_to_history_delete');
INSERT INTO `ohrm_external_async_event_event_tag` (`event_id`, `tag_id`) VALUES
    (@latest_job_record_update_due_to_delete_event_id, @changed_employee_tag_id);

SET @latest_salary_record_update_due_to_delete_event_id = (SELECT id FROM `ohrm_async_event` WHERE name = 'pim.latest_salary_record_updated_due_to_history_delete');
INSERT INTO `ohrm_external_async_event_event_tag` (`event_id`, `tag_id`) VALUES
    (@latest_salary_record_update_due_to_delete_event_id, @changed_employee_tag_id);

INSERT INTO `ohrm_external_data_queue_consumer` (`name`, `description`, `consumer_class`, `enabled`, `queue_id`, `message_consume_limit`) VALUES
    ('Changed Employee Detection queue consumer', 'This Consumer detects the changed employee records', 'IntegrationQueueConsumer', 1, @changed_employee_queue_id, 25),
    ('Changed Employee Detection queue consumer with future effective', 'This Consumer detects the changed employee records with future effective', 'IntegrationQueueConsumer', 1, @changed_employee_future_effective_queue_id, 25);

SET @changed_employee_detection_cosumer_id = (SELECT id FROM `ohrm_external_data_queue_consumer` WHERE name = 'Changed Employee Detection queue consumer');
SET @changed_employee_detection_cosumer_with_future_effective_id = (SELECT id FROM `ohrm_external_data_queue_consumer` WHERE name = 'Changed Employee Detection queue consumer with future effective');
INSERT INTO `ohrm_external_async_event_tag_queue` (`queue_id`, `tag_id`) VALUES
    (@changed_employee_queue_id, @changed_employee_tag_id),
    (@changed_employee_future_effective_queue_id, @changed_employee_future_effective_tag_id);


SET @save_emergency_contact_event_id = (SELECT `id` FROM `ohrm_async_event` WHERE (`name` = 'pim.save_emergency_contact_record'));
INSERT INTO `ohrm_external_async_event_event_tag` (`event_id`, `tag_id`) VALUES
    (@save_emergency_contact_event_id, @changed_employee_tag_id),
    (@save_emergency_contact_event_id, @changed_employee_future_effective_tag_id);

SET @delete_emergency_contact_event_id = (SELECT `id` FROM `ohrm_async_event` WHERE (`name` = 'pim.delete_emergency_contact_record'));
INSERT INTO `ohrm_external_async_event_event_tag` (`event_id`, `tag_id`) VALUES
    (@delete_emergency_contact_event_id, @changed_employee_tag_id),
    (@delete_emergency_contact_event_id, @changed_employee_future_effective_tag_id);

SET @save_qualification_event_id = (SELECT `id` FROM `ohrm_async_event` WHERE (`name` = 'pim.save_work_experience_qualification_record'));
INSERT INTO `ohrm_external_async_event_event_tag` (`event_id`, `tag_id`) VALUES
    (@save_qualification_event_id, @changed_employee_tag_id),
    (@save_qualification_event_id, @changed_employee_future_effective_tag_id);

SET @delete_qualification_event_id = (SELECT `id` FROM `ohrm_async_event` WHERE (`name` = 'pim.delete_work_experience_qualification_record'));
INSERT INTO `ohrm_external_async_event_event_tag` (`event_id`, `tag_id`) VALUES
    (@delete_qualification_event_id, @changed_employee_tag_id),
    (@delete_qualification_event_id, @changed_employee_future_effective_tag_id);

SET @save_qualification_event_id = (SELECT `id` FROM `ohrm_async_event` WHERE (`name` = 'pim.save_education_qualification_record'));
INSERT INTO `ohrm_external_async_event_event_tag` (`event_id`, `tag_id`) VALUES
    (@save_qualification_event_id, @changed_employee_tag_id),
    (@save_qualification_event_id, @changed_employee_future_effective_tag_id);

SET @delete_qualification_event_id = (SELECT `id` FROM `ohrm_async_event` WHERE (`name` = 'pim.delete_education_qualification_record'));
INSERT INTO `ohrm_external_async_event_event_tag` (`event_id`, `tag_id`) VALUES
    (@delete_qualification_event_id, @changed_employee_tag_id),
    (@delete_qualification_event_id, @changed_employee_future_effective_tag_id);

SET @save_skill_qualification_event_id = (SELECT `id` FROM `ohrm_async_event` WHERE (`name` = 'pim.save_skill_qualification_record'));
INSERT INTO `ohrm_external_async_event_event_tag` (`event_id`, `tag_id`) VALUES
    (@save_skill_qualification_event_id, @changed_employee_tag_id),
    (@save_skill_qualification_event_id, @changed_employee_future_effective_tag_id);

SET @delete_skill_qualification_event_id = (SELECT `id` FROM `ohrm_async_event` WHERE (`name` = 'pim.delete_skill_qualification_record'));
INSERT INTO `ohrm_external_async_event_event_tag` (`event_id`, `tag_id`) VALUES
    (@delete_skill_qualification_event_id, @changed_employee_tag_id),
    (@delete_skill_qualification_event_id, @changed_employee_future_effective_tag_id);

SET @save_language_qualification_event_id = (SELECT `id` FROM `ohrm_async_event` WHERE (`name` = 'pim.save_language_qualification_record'));
INSERT INTO `ohrm_external_async_event_event_tag` (`event_id`, `tag_id`) VALUES
    (@save_language_qualification_event_id, @changed_employee_tag_id),
    (@save_language_qualification_event_id, @changed_employee_future_effective_tag_id);

SET @delete_language_qualification_event_id = (SELECT `id` FROM `ohrm_async_event` WHERE (`name` = 'pim.delete_language_qualification_record'));
INSERT INTO `ohrm_external_async_event_event_tag` (`event_id`, `tag_id`) VALUES
    (@delete_language_qualification_event_id, @changed_employee_tag_id),
    (@delete_language_qualification_event_id, @changed_employee_future_effective_tag_id);

SET @save_license_qualification_event_id = (SELECT `id` FROM `ohrm_async_event` WHERE (`name` = 'pim.save_license_qualification_record'));
INSERT INTO `ohrm_external_async_event_event_tag` (`event_id`, `tag_id`) VALUES
    (@save_license_qualification_event_id, @changed_employee_tag_id),
    (@save_license_qualification_event_id, @changed_employee_future_effective_tag_id);

SET @delete_license_qualification_event_id = (SELECT `id` FROM `ohrm_async_event` WHERE (`name` = 'pim.delete_license_qualification_record'));
INSERT INTO `ohrm_external_async_event_event_tag` (`event_id`, `tag_id`) VALUES
    (@delete_license_qualification_event_id, @changed_employee_tag_id),
    (@delete_license_qualification_event_id, @changed_employee_future_effective_tag_id);

SET @event_id = (SELECT `id` FROM `ohrm_async_event` WHERE (`name` = 'pim.job_record_updated_due_to_history_delete'));
INSERT INTO `ohrm_external_async_event_event_tag` (`event_id`, `tag_id`) VALUES
    (@event_id, @changed_employee_tag_id),
    (@event_id, @changed_employee_future_effective_tag_id);

SET @event_id = (SELECT `id` FROM `ohrm_async_event` WHERE (`name` = 'pim.salary_record_updated_due_to_history_delete'));
INSERT INTO `ohrm_external_async_event_event_tag` (`event_id`, `tag_id`) VALUES
    (@event_id, @changed_employee_tag_id),
    (@event_id, @changed_employee_future_effective_tag_id);


INSERT INTO `ohrm_external_integration_process` (`name`, `configuration`, `parameters`, `isConsumer`, `enabled`)
SELECT * FROM (SELECT 'ChangedEmployeeVerification' as name, '{
    "replacementParameters": [],
    "subscribedEvents": [
        "employee_added",
        "employee_updated",
        "pim.save_job_record",
        "pim.save_direct_deposit_record",
        "pim.delete_direct_deposit_record",
        "pim.save_salary_record",
        "pim.custom_field_value_update",
        "pim.custom_field_value_delete",
        "employees_activated",
        "employees_activation_scheduled",
        "employees_terminated",
        "employees_termination_scheduled",
        "pim.latest_job_record_updated_due_to_history_delete",
        "pim.job_record_updated_due_to_history_delete",
        "pim.latest_salary_record_updated_due_to_history_delete",
        "pim.salary_record_updated_due_to_history_delete"
    ],
    "processCoordinator": "BasicIntegrationProcessCoordinator",
    "dataFlow": [
        {
            "name": "ChangeVerifierMediator",
            "properties": {
                "eventsToExecute": {
                    "eventNameFieldName": "name",
                    "eventNameFieldPath": [
                        "event"
                    ],
                    "eventNames": [
                        "employee_added"
                    ],
                    "defaultSave": true
                },
                "preDataPath": [],
                "postDataPath": [],
                "comparisons": [],
                "fieldsToBeExtracted": [
                    {
                        "fieldPath": [
                            "data",
                            "employee"
                        ],
                        "currentFieldNames": [
                            "empNumber"
                        ],
                        "newFieldNames": [
                            "empNumber"
                        ]
                    },
                    {
                        "fieldPath": [
                            "event"
                        ],
                        "currentFieldNames": [
                            "timestamp",
                            "id"
                        ],
                        "newFieldNames": [
                            "date",
                            "id"
                        ]
                    },
                    {
                        "fieldPath": [],
                        "currentFieldNames": [
                            "integration_process_id"
                        ],
                        "newFieldNames": [
                            "integration_process_id"
                        ]
                    }
                ]
            }
        },
        {
            "name": "ChangeVerifierMediator",
            "properties": {
                "eventsToExecute": {
                    "eventNameFieldName": "name",
                    "eventNameFieldPath": [
                        "event"
                    ],
                    "eventNames": [
                        "employee_updated"
                    ],
                    "defaultSave": false
                },
                "preDataPath": [
                    "data",
                    "preUpdateEmployee"
                ],
                "postDataPath": [
                    "data",
                    "employee"
                ],
                "comparisons": [
                    {
                        "fieldName": "firstName",
                        "mappedReportFieldName": "employeeFirstname",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "lastName",
                        "mappedReportFieldName": "employeeLastname",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "middleName",
                        "mappedReportFieldName": "employeeMiddlename",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "employeeId",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "otherId",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "ssn",
                        "mappedReportFieldName": "employeeSSN",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "sin",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "emp_gender",
                        "mappedReportFieldName": "empGender",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "emp_marital_status",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "nation_code",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "emp_birthday",
                        "mappedReportFieldName": "empBirthday",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "city",
                        "mappedReportFieldName": "city_code",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "country",
                        "mappedReportFieldName": "cou_name",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "emp_mobile",
                        "mappedReportFieldName": "mobile",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "emp_work_email",
                        "mappedReportFieldName": "workEmail",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "emp_oth_email",
                        "mappedReportFieldName": "otherEmail",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "province",
                        "mappedReportFieldName": "province_code",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "emp_zipcode",
                        "mappedReportFieldName": "zipcode",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "street1",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "street2",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    }
                ],
                "fieldsToBeExtracted": [
                    {
                        "fieldPath": [
                            "data",
                            "employee"
                        ],
                        "currentFieldNames": [
                            "empNumber"
                        ],
                        "newFieldNames": [
                            "empNumber"
                        ]
                    },
                    {
                        "fieldPath": [
                            "event"
                        ],
                        "currentFieldNames": [
                            "timestamp",
                            "id"
                        ],
                        "newFieldNames": [
                            "date",
                            "id"
                        ]
                    },
                    {
                        "fieldPath": [],
                        "currentFieldNames": [
                            "integration_process_id"
                        ],
                        "newFieldNames": [
                            "integration_process_id"
                        ]
                    }
                ]
            }
        },
        {
            "name": "ChangeVerifierMediator",
            "properties": {
                "eventsToExecute": {
                    "eventNameFieldName": "name",
                    "eventNameFieldPath": [
                        "event"
                    ],
                    "eventNames": [
                        "pim.save_job_record"
                    ],
                    "defaultSave": false
                },
                "preDataPath": [
                    "data",
                    "old-job-record-before-save"
                ],
                "postDataPath": [
                    "data",
                    "new-job-record"
                ],
                "comparisons": [
                    {
                        "fieldName": "joined_date",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "probation_end_date",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "date_of_permanency",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "id",
                        "mappedReportFieldName": "JobTitle.id",
                        "oldFieldPath": [
                            "data",
                            "old-job-record-before-save",
                            "JobTitle"
                        ],
                        "newFieldPath": [
                            "data",
                            "new-job-record",
                            "JobTitle"
                        ]
                    },
                    {
                        "fieldName": "id",
                        "mappedReportFieldName": "EmploymentStatus.id",
                        "oldFieldPath": [
                            "data",
                            "old-job-record-before-save",
                            "EmploymentStatus"
                        ],
                        "newFieldPath": [
                            "data",
                            "new-job-record",
                            "EmploymentStatus"
                        ]
                    },
                    {
                        "fieldName": "id",
                        "mappedReportFieldName": "JobCategory.id",
                        "oldFieldPath": [
                            "data",
                            "old-job-record-before-save",
                            "JobCategory"
                        ],
                        "newFieldPath": [
                            "data",
                            "new-job-record",
                            "JobCategory"
                        ]
                    },
                    {
                        "fieldName": "id",
                        "mappedReportFieldName": "SubUnit.id",
                        "oldFieldPath": [
                            "data",
                            "old-job-record-before-save",
                            "SubUnit"
                        ],
                        "newFieldPath": [
                            "data",
                            "new-job-record",
                            "SubUnit"
                        ]
                    },
                    {
                        "fieldName": "location_id",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "work_schedule_id",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "cost_centre_id",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    }
                ],
                "fieldsToBeExtracted": [
                    {
                        "fieldPath": [
                            "data",
                            "new-job-record"
                        ],
                        "currentFieldNames": [
                            "employee_number",
                            "effective_date"
                        ],
                        "newFieldNames": [
                            "empNumber",
                            "effectiveDate"
                        ]
                    },
                    {
                        "fieldPath": [
                            "event"
                        ],
                        "currentFieldNames": [
                            "timestamp",
                            "id"
                        ],
                        "newFieldNames": [
                            "date",
                            "id"
                        ]
                    },
                    {
                        "fieldPath": [],
                        "currentFieldNames": [
                            "integration_process_id"
                        ],
                        "newFieldNames": [
                            "integration_process_id"
                        ]
                    }
                ]
            }
        },
        {
            "name": "ChangeVerifierMediator",
            "properties": {
                "eventsToExecute": {
                    "eventNameFieldName": "name",
                    "eventNameFieldPath": [
                        "event"
                    ],
                    "eventNames": [
                        "pim.save_direct_deposit_record"
                    ],
                    "defaultSave": false
                },
                "preDataPath": [
                    "data",
                    "old-direct-deposit-record"
                ],
                "postDataPath": [
                    "data",
                    "new-direct-deposit-record"
                ],
                "comparisons": [
                    {
                        "fieldName": "branch_location",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "amount",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "account_number",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "institute_name",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "account_type",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "routing_number",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    }
                ],
                "fieldsToBeExtracted": [
                    {
                        "fieldPath": [
                            "data",
                            "new-direct-deposit-record"
                        ],
                        "currentFieldNames": [
                            "employee_number"
                        ],
                        "newFieldNames": [
                            "empNumber"
                        ]
                    },
                    {
                        "fieldPath": [
                            "event"
                        ],
                        "currentFieldNames": [
                            "timestamp",
                            "id"
                        ],
                        "newFieldNames": [
                            "date",
                            "id"
                        ]
                    },
                    {
                        "fieldPath": [],
                        "currentFieldNames": [
                            "integration_process_id"
                        ],
                        "newFieldNames": [
                            "integration_process_id"
                        ]
                    }
                ]
            }
        },
        {
            "name": "SalaryValueChangeVerifierMediator",
            "properties": {
                "eventsToExecute": {
                    "eventNameFieldName": "name",
                    "eventNameFieldPath": [
                        "event"
                    ],
                    "eventNames": [
                        "pim.save_salary_record"
                    ],
                    "defaultSave": false
                },
                "preDataPath": [
                    "data",
                    "old-salary-record-before-save"
                ],
                "postDataPath": [
                    "data",
                    "new-salary-record"
                ],
                "comparisons": [
                    {
                        "fieldName": "pay_grade_id",
                        "oldFieldPath": [
                            "data",
                            "old-salary-record-before-save"
                        ],
                        "newFieldPath": [
                            "data",
                            "new-salary-record"
                        ]
                    },
                    {
                        "fieldName": "currency_id",
                        "oldFieldPath": [
                            "data",
                            "old-salary-record-before-save"
                        ],
                        "newFieldPath": [
                            "data",
                            "new-salary-record"
                        ]
                    },
                    {
                        "fieldName": "value",
                        "oldFieldPath": [
                            "data",
                            "old-salary-components-before-save"
                        ],
                        "newFieldPath": [
                            "data",
                            "employee-salary-component-data"
                        ]
                    }
                ],
                "fieldsToBeExtracted": [
                    {
                        "fieldPath": [
                            "data",
                            "new-salary-record"
                        ],
                        "currentFieldNames": [
                            "employee_number",
                            "effective_date"
                        ],
                        "newFieldNames": [
                            "empNumber",
                            "effectiveDate"
                        ]
                    },
                    {
                        "fieldPath": [
                            "event"
                        ],
                        "currentFieldNames": [
                            "timestamp",
                            "id"
                        ],
                        "newFieldNames": [
                            "date",
                            "id"
                        ]
                    },
                    {
                        "fieldPath": [],
                        "currentFieldNames": [
                            "integration_process_id"
                        ],
                        "newFieldNames": [
                            "integration_process_id"
                        ]
                    }
                ]
            }
        },
        {
            "name": "CustomFieldValuesChangeVerifierMediator",
            "properties": {
                "eventsToExecute": {
                    "eventNameFieldName": "name",
                    "eventNameFieldPath": [
                        "event"
                    ],
                    "eventNames": [
                        "pim.custom_field_value_update",
                        "pim.custom_field_value_delete"
                    ],
                    "defaultSave": false
                },
                "preDataPath": [
                    "data",
                    "oldValues"
                ],
                "postDataPath": [
                    "data",
                    "values"
                ],
                "comparisons": [
                    {
                        "fieldName": "value",
                        "oldFieldPath": [
                            "data",
                            "oldValues"
                        ],
                        "newFieldPath": [
                            "data",
                            "values"
                        ]
                    }
                ],
                "fieldsToBeExtracted": [
                    {
                        "fieldPath": [
                            "data"
                        ],
                        "currentFieldNames": [
                            "emp_number",
                            "effective_date"
                        ],
                        "newFieldNames": [
                            "empNumber",
                            "effectiveDate"
                        ]
                    },
                    {
                        "fieldPath": [
                            "event"
                        ],
                        "currentFieldNames": [
                            "timestamp",
                            "id"
                        ],
                        "newFieldNames": [
                            "date",
                            "id"
                        ]
                    },
                    {
                        "fieldPath": [],
                        "currentFieldNames": [
                            "integration_process_id"
                        ],
                        "newFieldNames": [
                            "integration_process_id"
                        ]
                    }
                ],
                "comparisonRules": {
                    "comparisonMethod": "",
                    "customSectionIds": [],
                    "customFieldUniqueNames": []
                }
            }
        },
        {
            "name": "ChangeVerifierMediator",
            "properties": {
                "eventsToExecute": {
                    "eventNameFieldName": "name",
                    "eventNameFieldPath": [
                        "event"
                    ],
                    "eventNames": [
                        "employees_terminated",
                        "employees_termination_scheduled"
                    ],
                    "defaultSave": true
                },
                "preDataPath": [],
                "postDataPath": [],
                "comparisons": [],
                "fieldsToBeExtracted": [
                    {
                        "fieldPath": [
                            "data",
                            "employee"
                        ],
                        "currentFieldNames": [
                            "empNumber"
                        ],
                        "newFieldNames": [
                            "empNumber"
                        ]
                    },
                    {
                        "fieldPath": [
                            "data",
                            "terminationRecord"
                        ],
                        "currentFieldNames": [
                            "date",
                            "reasonId",
                            "note"
                        ],
                        "newFieldNames": [
                            "::param::terminationDate::",
                            "::param::terminationReasonId::",
                            "::param::terminationNote::"
                        ]
                    },
                    {
                        "fieldPath": [
                            "data"
                        ],
                        "currentFieldNames": [
                            "scheduledTerminationDateReached"
                        ],
                        "newFieldNames": [
                            "::param::scheduledTerminationDateReached::"
                        ]
                    },
                    {
                        "fieldPath": [
                            "event"
                        ],
                        "currentFieldNames": [
                            "timestamp",
                            "id"
                        ],
                        "newFieldNames": [
                            "date",
                            "id"
                        ]
                    },
                    {
                        "fieldPath": [],
                        "currentFieldNames": [
                            "integration_process_id"
                        ],
                        "newFieldNames": [
                            "integration_process_id"
                        ]
                    }
                ]
            }
        },
        {
            "name": "ChangeVerifierMediator",
            "properties": {
                "eventsToExecute": {
                    "eventNameFieldName": "name",
                    "eventNameFieldPath": [
                        "event"
                    ],
                    "eventNames": [
                        "employees_activated",
                        "employees_activation_scheduled"
                    ],
                    "defaultSave": true
                },
                "preDataPath": [],
                "postDataPath": [],
                "comparisons": [],
                "fieldsToBeExtracted": [
                    {
                        "fieldPath": [
                            "data",
                            "employee"
                        ],
                        "currentFieldNames": [
                            "empNumber"
                        ],
                        "newFieldNames": [
                            "empNumber"
                        ]
                    },
                    {
                        "fieldPath": [
                            "data",
                            "terminationRecord"
                        ],
                        "currentFieldNames": [
                            "reactivationDate"
                        ],
                        "newFieldNames": [
                            "::param::reactivationDate::"
                        ]
                    },
                    {
                        "fieldPath": [
                            "data"
                        ],
                        "currentFieldNames": [
                            "scheduledActivationDateReached"
                        ],
                        "newFieldNames": [
                            "::param::scheduledActivationDateReached::"
                        ]
                    },
                    {
                        "fieldPath": [
                            "event"
                        ],
                        "currentFieldNames": [
                            "timestamp",
                            "id"
                        ],
                        "newFieldNames": [
                            "date",
                            "id"
                        ]
                    },
                    {
                        "fieldPath": [],
                        "currentFieldNames": [
                            "integration_process_id"
                        ],
                        "newFieldNames": [
                            "integration_process_id"
                        ]
                    }
                ]
            }
        },
        {
            "name": "ChangeVerifierMediator",
            "properties": {
                "eventsToExecute": {
                    "eventNameFieldName": "name",
                    "eventNameFieldPath": [
                        "event"
                    ],
                    "eventNames": [
                        "pim.delete_direct_deposit_record"
                    ],
                    "defaultSave": true
                },
                "preDataPath": [],
                "postDataPath": [],
                "comparisons": [],
                "fieldsToBeExtracted": [
                    {
                        "fieldPath": [
                            "data"
                        ],
                        "currentFieldNames": [
                            "emp_number"
                        ],
                        "newFieldNames": [
                            "empNumber"
                        ]
                    },
                    {
                        "fieldPath": [
                            "event"
                        ],
                        "currentFieldNames": [
                            "timestamp",
                            "id"
                        ],
                        "newFieldNames": [
                            "date",
                            "id"
                        ]
                    },
                    {
                        "fieldPath": [],
                        "currentFieldNames": [
                            "integration_process_id"
                        ],
                        "newFieldNames": [
                            "integration_process_id"
                        ]
                    }
                ]
            }
        },
        {
            "name": "ChangeVerifierMediator",
            "properties": {
                "eventsToExecute": {
                    "eventNameFieldName": "name",
                    "eventNameFieldPath": [
                        "event"
                    ],
                    "eventNames": [
                        "pim.latest_job_record_updated_due_to_history_delete",
                        "pim.job_record_updated_due_to_history_delete"
                    ],
                    "defaultSave": false
                },
                "preDataPath": [
                    "data",
                    "old-job-record"
                ],
                "postDataPath": [
                    "data",
                    "new-job-record"
                ],
                "comparisons": [
                    {
                        "fieldName": "joined_date",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "probation_end_date",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "date_of_permanency",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "id",
                        "mappedReportFieldName": "JobTitle.id",
                        "oldFieldPath": [
                            "data",
                            "old-job-record",
                            "JobTitle"
                        ],
                        "newFieldPath": [
                            "data",
                            "new-job-record",
                            "JobTitle"
                        ]
                    },
                    {
                        "fieldName": "id",
                        "mappedReportFieldName": "EmploymentStatus.id",
                        "oldFieldPath": [
                            "data",
                            "old-job-record",
                            "EmploymentStatus"
                        ],
                        "newFieldPath": [
                            "data",
                            "new-job-record",
                            "EmploymentStatus"
                        ]
                    },
                    {
                        "fieldName": "id",
                        "mappedReportFieldName": "JobCategory.id",
                        "oldFieldPath": [
                            "data",
                            "old-job-record",
                            "JobCategory"
                        ],
                        "newFieldPath": [
                            "data",
                            "new-job-record",
                            "JobCategory"
                        ]
                    },
                    {
                        "fieldName": "id",
                        "mappedReportFieldName": "SubUnit.id",
                        "oldFieldPath": [
                            "data",
                            "old-job-record",
                            "SubUnit"
                        ],
                        "newFieldPath": [
                            "data",
                            "new-job-record",
                            "SubUnit"
                        ]
                    },
                    {
                        "fieldName": "location_id",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "work_schedule_id",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "cost_centre_id",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    }
                ],
                "fieldsToBeExtracted": [
                    {
                        "fieldPath": [
                            "data",
                            "new-job-record"
                        ],
                        "currentFieldNames": [
                            "employee_number",
                            "effective_date"
                        ],
                        "newFieldNames": [
                            "empNumber",
                            "effectiveDate"
                        ]
                    },
                    {
                        "fieldPath": [
                            "event"
                        ],
                        "currentFieldNames": [
                            "timestamp",
                            "id"
                        ],
                        "newFieldNames": [
                            "date",
                            "id"
                        ]
                    },
                    {
                        "fieldPath": [],
                        "currentFieldNames": [
                            "integration_process_id"
                        ],
                        "newFieldNames": [
                            "integration_process_id"
                        ]
                    }
                ]
            }
        },
        {
            "name": "SalaryValueChangeVerifierMediator",
            "properties": {
                "eventsToExecute": {
                    "eventNameFieldName": "name",
                    "eventNameFieldPath": [
                        "event"
                    ],
                    "eventNames": [
                        "pim.latest_salary_record_updated_due_to_history_delete",
                        "pim.salary_record_updated_due_to_history_delete"
                    ],
                    "defaultSave": false
                },
                "preDataPath": [
                    "data",
                    "old-salary-record"
                ],
                "postDataPath": [
                    "data",
                    "new-salary-record"
                ],
                "comparisons": [
                    {
                        "fieldName": "pay_grade_id",
                        "oldFieldPath": [
                            "data",
                            "old-salary-record"
                        ],
                        "newFieldPath": [
                            "data",
                            "new-salary-record"
                        ]
                    },
                    {
                        "fieldName": "currency_id",
                        "oldFieldPath": [
                            "data",
                            "old-salary-record"
                        ],
                        "newFieldPath": [
                            "data",
                            "new-salary-record"
                        ]
                    },
                    {
                        "fieldName": "value",
                        "oldFieldPath": [
                            "data",
                            "old-salary-components"
                        ],
                        "newFieldPath": [
                            "data",
                            "employee-salary-component-data"
                        ]
                    }
                ],
                "fieldsToBeExtracted": [
                    {
                        "fieldPath": [
                            "data",
                            "new-salary-record"
                        ],
                        "currentFieldNames": [
                            "employee_number",
                            "effective_date"
                        ],
                        "newFieldNames": [
                            "empNumber",
                            "effectiveDate"
                        ]
                    },
                    {
                        "fieldPath": [
                            "event"
                        ],
                        "currentFieldNames": [
                            "timestamp",
                            "id"
                        ],
                        "newFieldNames": [
                            "date",
                            "id"
                        ]
                    },
                    {
                        "fieldPath": [],
                        "currentFieldNames": [
                            "integration_process_id"
                        ],
                        "newFieldNames": [
                            "integration_process_id"
                        ]
                    }
                ]
            }
        },
        {
            "name": "DispatchDataToDatabaseMediator",
            "properties": {
                "changeIdentification": {
                    "fieldName": "changeDetected",
                    "fieldPath": [
                        "changeVerificationData"
                    ]
                },
                "insertMode": "SQL",
                "extractedData": {
                    "fieldPath": [
                        "changeVerificationData",
                        "extractedInfo"
                    ]
                },
                "databaseMapping": [
                    {
                        "tableName": "ohrm_external_payroll_changed_employee",
                        "entityName": "ChangedEmployee",
                        "mappingfields": [
                            {
                                "entityField": "changedEmpNumber",
                                "tableField": "changed_emp_number",
                                "extractingFieldName": "empNumber"
                            },
                            {
                                "entityField": "changedDate",
                                "tableField": "changed_date",
                                "extractingFieldName": "date"
                            },
                            {
                                "entityField": "async_event_id",
                                "tableField": "async_event_id",
                                "extractingFieldName": "id"
                            },
                            {
                                "entityField": "external_integration_process_id",
                                "tableField": "external_integration_process_id",
                                "extractingFieldName": "integration_process_id"
                            },
                            {
                                "entityField": "fields_changed",
                                "tableField": "fields_changed",
                                "extractingFieldName": "fieldsChanged",
                                "preProcessing": [
                                    "json-encode",
                                    "encrypt"
                                ]
                            }
                        ]
                    }
                ]
            }
        }
    ]
}' as configuration, NULL as parameters, '1' as isConsumer, '1' as enabled) as temp
WHERE NOT EXISTS (
    SELECT name FROM `ohrm_external_integration_process` WHERE name = 'ChangedEmployeeVerification'
) LIMIT 1;

INSERT INTO `ohrm_external_integration_process` (`name`, `configuration`, `parameters`, `isConsumer`, `enabled`)
SELECT * FROM (SELECT 'ChangedEmployeeVerificationWithFutureEffective' as name, '{
    "replacementParameters": [],
    "subscribedEvents": [
        "employee_added",
        "employee_updated",
        "pim.save_job_record",
        "pim.save_direct_deposit_record",
        "pim.delete_direct_deposit_record",
        "pim.save_salary_record",
        "pim.custom_field_value_update",
        "pim.custom_field_value_delete",
        "employees_activated",
        "employees_terminated",
        "pim.job_change_effective_date_reached",
        "pim.custom_field_change_effective_date_reached",
        "pim.salary_change_effective_date_reached",
        "pim.first_time_joined_date_reached",
        "pim.current_job_record_updated_due_to_history_delete",
        "pim.job_record_updated_due_to_history_delete",
        "pim.current_salary_record_updated_due_to_history_delete",
        "pim.salary_record_updated_due_to_history_delete"
    ],
    "processCoordinator": "BasicIntegrationProcessCoordinator",
    "dataFlow": [
        {
            "name": "ChangeVerifierMediator",
            "properties": {
                "eventsToExecute": {
                    "eventNameFieldName": "name",
                    "eventNameFieldPath": [
                        "event"
                    ],
                    "eventNames": [
                        "employee_added"
                    ],
                    "defaultSave": true
                },
                "preDataPath": [],
                "postDataPath": [],
                "skipIfDateInFuture": [
                    "data",
                    "employee",
                    "joined_date"
                ],
                "comparisons": [],
                "fieldsToBeExtracted": [
                    {
                        "fieldPath": [
                            "data",
                            "employee"
                        ],
                        "currentFieldNames": [
                            "empNumber"
                        ],
                        "newFieldNames": [
                            "empNumber"
                        ]
                    },
                    {
                        "fieldPath": [
                            "event"
                        ],
                        "currentFieldNames": [
                            "timestamp",
                            "id"
                        ],
                        "newFieldNames": [
                            "date",
                            "id"
                        ]
                    },
                    {
                        "fieldPath": [],
                        "currentFieldNames": [
                            "integration_process_id"
                        ],
                        "newFieldNames": [
                            "integration_process_id"
                        ]
                    }
                ]
            }
        },
        {
            "name": "ChangeVerifierMediator",
            "properties": {
                "eventsToExecute": {
                    "eventNameFieldName": "name",
                    "eventNameFieldPath": [
                        "event"
                    ],
                    "eventNames": [
                        "employee_updated"
                    ],
                    "defaultSave": false
                },
                "preDataPath": [
                    "data",
                    "preUpdateEmployee"
                ],
                "postDataPath": [
                    "data",
                    "employee"
                ],
                "skipIfDateInFuture": [
                    "data",
                    "employee",
                    "joined_date"
                ],
                "comparisons": [
                    {
                        "fieldName": "firstName",
                        "mappedReportFieldName": "employeeFirstname",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "lastName",
                        "mappedReportFieldName": "employeeLastname",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "middleName",
                        "mappedReportFieldName": "employeeMiddlename",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "employeeId",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "otherId",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "ssn",
                        "mappedReportFieldName": "employeeSSN",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "sin",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "emp_gender",
                        "mappedReportFieldName": "empGender",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "emp_marital_status",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "nation_code",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "emp_birthday",
                        "mappedReportFieldName": "empBirthday",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "city",
                        "mappedReportFieldName": "city_code",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "country",
                        "mappedReportFieldName": "cou_name",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "emp_mobile",
                        "mappedReportFieldName": "mobile",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "emp_work_email",
                        "mappedReportFieldName": "workEmail",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "emp_oth_email",
                        "mappedReportFieldName": "otherEmail",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "province",
                        "mappedReportFieldName": "province_code",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "emp_zipcode",
                        "mappedReportFieldName": "zipcode",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "street1",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "street2",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    }
                ],
                "fieldsToBeExtracted": [
                    {
                        "fieldPath": [
                            "data",
                            "employee"
                        ],
                        "currentFieldNames": [
                            "empNumber"
                        ],
                        "newFieldNames": [
                            "empNumber"
                        ]
                    },
                    {
                        "fieldPath": [
                            "event"
                        ],
                        "currentFieldNames": [
                            "timestamp",
                            "id"
                        ],
                        "newFieldNames": [
                            "date",
                            "id"
                        ]
                    },
                    {
                        "fieldPath": [],
                        "currentFieldNames": [
                            "integration_process_id"
                        ],
                        "newFieldNames": [
                            "integration_process_id"
                        ]
                    }
                ]
            }
        },
        {
            "name": "ChangeVerifierMediator",
            "properties": {
                "eventsToExecute": {
                    "eventNameFieldName": "name",
                    "eventNameFieldPath": [
                        "event"
                    ],
                    "eventNames": [
                        "pim.save_job_record"
                    ],
                    "defaultSave": false
                },
                "preDataPath": [
                    "data",
                    "old-job-record-before-save"
                ],
                "postDataPath": [
                    "data",
                    "new-job-record"
                ],
                "skipIfPropertyTrue": [
                    "data",
                    "future_effective_change"
                ],
                "comparisons": [
                    {
                        "fieldName": "joined_date",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "probation_end_date",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "date_of_permanency",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "id",
                        "mappedReportFieldName": "JobTitle.id",
                        "oldFieldPath": [
                            "data",
                            "old-job-record-before-save",
                            "JobTitle"
                        ],
                        "newFieldPath": [
                            "data",
                            "new-job-record",
                            "JobTitle"
                        ]
                    },
                    {
                        "fieldName": "id",
                        "mappedReportFieldName": "EmploymentStatus.id",
                        "oldFieldPath": [
                            "data",
                            "old-job-record-before-save",
                            "EmploymentStatus"
                        ],
                        "newFieldPath": [
                            "data",
                            "new-job-record",
                            "EmploymentStatus"
                        ]
                    },
                    {
                        "fieldName": "id",
                        "mappedReportFieldName": "JobCategory.id",
                        "oldFieldPath": [
                            "data",
                            "old-job-record-before-save",
                            "JobCategory"
                        ],
                        "newFieldPath": [
                            "data",
                            "new-job-record",
                            "JobCategory"
                        ]
                    },
                    {
                        "fieldName": "id",
                        "mappedReportFieldName": "SubUnit.id",
                        "oldFieldPath": [
                            "data",
                            "old-job-record-before-save",
                            "SubUnit"
                        ],
                        "newFieldPath": [
                            "data",
                            "new-job-record",
                            "SubUnit"
                        ]
                    },
                    {
                        "fieldName": "location_id",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "work_schedule_id",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "cost_centre_id",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    }
                ],
                "fieldsToBeExtracted": [
                    {
                        "fieldPath": [
                            "data",
                            "new-job-record"
                        ],
                        "currentFieldNames": [
                            "employee_number",
                            "effective_date"
                        ],
                        "newFieldNames": [
                            "empNumber",
                            "effectiveDate"
                        ]
                    },
                    {
                        "fieldPath": [
                            "event"
                        ],
                        "currentFieldNames": [
                            "timestamp",
                            "id"
                        ],
                        "newFieldNames": [
                            "date",
                            "id"
                        ]
                    },
                    {
                        "fieldPath": [],
                        "currentFieldNames": [
                            "integration_process_id"
                        ],
                        "newFieldNames": [
                            "integration_process_id"
                        ]
                    }
                ]
            }
        },
        {
            "name": "ChangeVerifierMediator",
            "properties": {
                "eventsToExecute": {
                    "eventNameFieldName": "name",
                    "eventNameFieldPath": [
                        "event"
                    ],
                    "eventNames": [
                        "pim.save_direct_deposit_record"
                    ],
                    "defaultSave": false
                },
                "preDataPath": [
                    "data",
                    "old-direct-deposit-record"
                ],
                "postDataPath": [
                    "data",
                    "new-direct-deposit-record"
                ],
                "comparisons": [
                    {
                        "fieldName": "branch_location",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "amount",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "account_number",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "institute_name",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "account_type",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "routing_number",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    }
                ],
                "fieldsToBeExtracted": [
                    {
                        "fieldPath": [
                            "data",
                            "new-direct-deposit-record"
                        ],
                        "currentFieldNames": [
                            "employee_number"
                        ],
                        "newFieldNames": [
                            "empNumber"
                        ]
                    },
                    {
                        "fieldPath": [
                            "event"
                        ],
                        "currentFieldNames": [
                            "timestamp",
                            "id"
                        ],
                        "newFieldNames": [
                            "date",
                            "id"
                        ]
                    },
                    {
                        "fieldPath": [],
                        "currentFieldNames": [
                            "integration_process_id"
                        ],
                        "newFieldNames": [
                            "integration_process_id"
                        ]
                    }
                ]
            }
        },
        {
            "name": "SalaryValueChangeVerifierMediator",
            "properties": {
                "eventsToExecute": {
                    "eventNameFieldName": "name",
                    "eventNameFieldPath": [
                        "event"
                    ],
                    "eventNames": [
                        "pim.save_salary_record"
                    ],
                    "defaultSave": false
                },
                "preDataPath": [
                    "data",
                    "old-salary-record-before-save"
                ],
                "postDataPath": [
                    "data",
                    "new-salary-record"
                ],
                "skipIfPropertyTrue": [
                    "data",
                    "future_effective_change"
                ],
                "comparisons": [
                    {
                        "fieldName": "pay_grade_id",
                        "oldFieldPath": [
                            "data",
                            "old-salary-record-before-save"
                        ],
                        "newFieldPath": [
                            "data",
                            "new-salary-record"
                        ]
                    },
                    {
                        "fieldName": "currency_id",
                        "oldFieldPath": [
                            "data",
                            "old-salary-record-before-save"
                        ],
                        "newFieldPath": [
                            "data",
                            "new-salary-record"
                        ]
                    },
                    {
                        "fieldName": "value",
                        "oldFieldPath": [
                            "data",
                            "old-salary-components-before-save"
                        ],
                        "newFieldPath": [
                            "data",
                            "employee-salary-component-data"
                        ]
                    }
                ],
                "fieldsToBeExtracted": [
                    {
                        "fieldPath": [
                            "data",
                            "new-salary-record"
                        ],
                        "currentFieldNames": [
                            "employee_number",
                            "effective_date"
                        ],
                        "newFieldNames": [
                            "empNumber",
                            "effectiveDate"
                        ]
                    },
                    {
                        "fieldPath": [
                            "event"
                        ],
                        "currentFieldNames": [
                            "timestamp",
                            "id"
                        ],
                        "newFieldNames": [
                            "date",
                            "id"
                        ]
                    },
                    {
                        "fieldPath": [],
                        "currentFieldNames": [
                            "integration_process_id"
                        ],
                        "newFieldNames": [
                            "integration_process_id"
                        ]
                    }
                ]
            }
        },
        {
            "name": "CustomFieldValuesChangeVerifierMediator",
            "properties": {
                "eventsToExecute": {
                    "eventNameFieldName": "name",
                    "eventNameFieldPath": [
                        "event"
                    ],
                    "eventNames": [
                        "pim.custom_field_value_update",
                        "pim.custom_field_value_delete"
                    ],
                    "defaultSave": false
                },
                "preDataPath": [
                    "data",
                    "oldValues"
                ],
                "postDataPath": [
                    "data",
                    "values"
                ],
                "skipIfPropertyTrue": [
                    "data",
                    "future_effective_change"
                ],
                "comparisons": [
                    {
                        "fieldName": "value",
                        "oldFieldPath": [
                            "data",
                            "oldValues"
                        ],
                        "newFieldPath": [
                            "data",
                            "values"
                        ]
                    }
                ],
                "fieldsToBeExtracted": [
                    {
                        "fieldPath": [
                            "data"
                        ],
                        "currentFieldNames": [
                            "emp_number",
                            "effective_date"
                        ],
                        "newFieldNames": [
                            "empNumber",
                            "effectiveDate"
                        ]
                    },
                    {
                        "fieldPath": [
                            "event"
                        ],
                        "currentFieldNames": [
                            "timestamp",
                            "id"
                        ],
                        "newFieldNames": [
                            "date",
                            "id"
                        ]
                    },
                    {
                        "fieldPath": [],
                        "currentFieldNames": [
                            "integration_process_id"
                        ],
                        "newFieldNames": [
                            "integration_process_id"
                        ]
                    }
                ],
                "comparisonRules": {
                    "comparisonMethod": "",
                    "customSectionIds": [],
                    "customFieldUniqueNames": []
                }
            }
        },
        {
            "name": "ChangeVerifierMediator",
            "properties": {
                "eventsToExecute": {
                    "eventNameFieldName": "name",
                    "eventNameFieldPath": [
                        "event"
                    ],
                    "eventNames": [
                        "employees_terminated"
                    ],
                    "defaultSave": true
                },
                "preDataPath": [],
                "postDataPath": [],
                "skipIfDateInFuture": [
                    "data",
                    "employee",
                    "joined_date"
                ],
                "comparisons": [],
                "fieldsToBeExtracted": [
                    {
                        "fieldPath": [
                            "data",
                            "employee"
                        ],
                        "currentFieldNames": [
                            "empNumber"
                        ],
                        "newFieldNames": [
                            "empNumber"
                        ]
                    },
                    {
                        "fieldPath": [
                            "data",
                            "terminationRecord"
                        ],
                        "currentFieldNames": [
                            "date",
                            "reasonId",
                            "note"
                        ],
                        "newFieldNames": [
                            "::param::terminationDate::",
                            "::param::terminationReasonId::",
                            "::param::terminationNote::"
                        ]
                    },
                    {
                        "fieldPath": [
                            "data"
                        ],
                        "currentFieldNames": [
                            "scheduledTerminationDateReached"
                        ],
                        "newFieldNames": [
                            "::param::scheduledTerminationDateReached::"
                        ]
                    },
                    {
                        "fieldPath": [
                            "event"
                        ],
                        "currentFieldNames": [
                            "timestamp",
                            "id"
                        ],
                        "newFieldNames": [
                            "date",
                            "id"
                        ]
                    },
                    {
                        "fieldPath": [],
                        "currentFieldNames": [
                            "integration_process_id"
                        ],
                        "newFieldNames": [
                            "integration_process_id"
                        ]
                    }
                ]
            }
        },
        {
            "name": "ChangeVerifierMediator",
            "properties": {
                "eventsToExecute": {
                    "eventNameFieldName": "name",
                    "eventNameFieldPath": [
                        "event"
                    ],
                    "eventNames": [
                        "employees_activated"
                    ],
                    "defaultSave": true
                },
                "preDataPath": [],
                "postDataPath": [],
                "skipIfDateInFuture": [
                    "data",
                    "employee",
                    "joined_date"
                ],
                "comparisons": [],
                "fieldsToBeExtracted": [
                    {
                        "fieldPath": [
                            "data",
                            "employee"
                        ],
                        "currentFieldNames": [
                            "empNumber"
                        ],
                        "newFieldNames": [
                            "empNumber"
                        ]
                    },
                    {
                        "fieldPath": [
                            "data",
                            "terminationRecord"
                        ],
                        "currentFieldNames": [
                            "reactivationDate"
                        ],
                        "newFieldNames": [
                            "::param::reactivationDate::"
                        ]
                    },
                    {
                        "fieldPath": [
                            "data"
                        ],
                        "currentFieldNames": [
                            "scheduledActivationDateReached"
                        ],
                        "newFieldNames": [
                            "::param::scheduledActivationDateReached::"
                        ]
                    },
                    {
                        "fieldPath": [
                            "event"
                        ],
                        "currentFieldNames": [
                            "timestamp",
                            "id"
                        ],
                        "newFieldNames": [
                            "date",
                            "id"
                        ]
                    },
                    {
                        "fieldPath": [],
                        "currentFieldNames": [
                            "integration_process_id"
                        ],
                        "newFieldNames": [
                            "integration_process_id"
                        ]
                    }
                ]
            }
        },
        {
            "name": "ChangeVerifierMediator",
            "properties": {
                "eventsToExecute": {
                    "eventNameFieldName": "name",
                    "eventNameFieldPath": [
                        "event"
                    ],
                    "eventNames": [
                        "pim.delete_direct_deposit_record"
                    ],
                    "defaultSave": true
                },
                "preDataPath": [],
                "postDataPath": [],
                "comparisons": [],
                "fieldsToBeExtracted": [
                    {
                        "fieldPath": [
                            "data"
                        ],
                        "currentFieldNames": [
                            "emp_number"
                        ],
                        "newFieldNames": [
                            "empNumber"
                        ]
                    },
                    {
                        "fieldPath": [
                            "event"
                        ],
                        "currentFieldNames": [
                            "timestamp",
                            "id"
                        ],
                        "newFieldNames": [
                            "date",
                            "id"
                        ]
                    },
                    {
                        "fieldPath": [],
                        "currentFieldNames": [
                            "integration_process_id"
                        ],
                        "newFieldNames": [
                            "integration_process_id"
                        ]
                    }
                ]
            }
        },
        {
            "name": "ChangeVerifierMediator",
            "properties": {
                "eventsToExecute": {
                    "eventNameFieldName": "name",
                    "eventNameFieldPath": [
                        "event"
                    ],
                    "eventNames": [
                        "pim.job_change_effective_date_reached"
                    ],
                    "defaultSave": false
                },
                "preDataPath": [
                    "data",
                    "old-job-record"
                ],
                "postDataPath": [
                    "data",
                    "new-job-record"
                ],
                "comparisons": [
                    {
                        "fieldName": "joined_date",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "probation_end_date",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "date_of_permanency",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "id",
                        "mappedReportFieldName": "JobTitle.id",
                        "oldFieldPath": [
                            "data",
                            "old-job-record",
                            "JobTitle"
                        ],
                        "newFieldPath": [
                            "data",
                            "new-job-record",
                            "JobTitle"
                        ]
                    },
                    {
                        "fieldName": "id",
                        "mappedReportFieldName": "EmploymentStatus.id",
                        "oldFieldPath": [
                            "data",
                            "old-job-record",
                            "EmploymentStatus"
                        ],
                        "newFieldPath": [
                            "data",
                            "new-job-record",
                            "EmploymentStatus"
                        ]
                    },
                    {
                        "fieldName": "id",
                        "mappedReportFieldName": "JobCategory.id",
                        "oldFieldPath": [
                            "data",
                            "old-job-record",
                            "JobCategory"
                        ],
                        "newFieldPath": [
                            "data",
                            "new-job-record",
                            "JobCategory"
                        ]
                    },
                    {
                        "fieldName": "id",
                        "mappedReportFieldName": "SubUnit.id",
                        "oldFieldPath": [
                            "data",
                            "old-job-record",
                            "SubUnit"
                        ],
                        "newFieldPath": [
                            "data",
                            "new-job-record",
                            "SubUnit"
                        ]
                    },
                    {
                        "fieldName": "location_id",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "work_schedule_id",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "cost_centre_id",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    }
                ],
                "fieldsToBeExtracted": [
                    {
                        "fieldPath": [
                            "data",
                            "new-job-record"
                        ],
                        "currentFieldNames": [
                            "employee_number",
                            "effective_date"
                        ],
                        "newFieldNames": [
                            "empNumber",
                            "effectiveDate"
                        ]
                    },
                    {
                        "fieldPath": [
                            "event"
                        ],
                        "currentFieldNames": [
                            "id"
                        ],
                        "newFieldNames": [
                            "id"
                        ]
                    },
                    {
                        "fieldPath": [
                            "data",
                            "new-job-record"
                        ],
                        "currentFieldNames": [
                            "effective_date",
                            "effective_date"
                        ],
                        "newFieldNames": [
                            "date",
                            "effectiveDate"
                        ]
                    },
                    {
                        "fieldPath": [],
                        "currentFieldNames": [
                            "integration_process_id"
                        ],
                        "newFieldNames": [
                            "integration_process_id"
                        ]
                    }
                ]
            }
        },
        {
            "name": "CustomFieldValuesChangeVerifierMediator",
            "properties": {
                "eventsToExecute": {
                    "eventNameFieldName": "name",
                    "eventNameFieldPath": [
                        "event"
                    ],
                    "eventNames": [
                        "pim.custom_field_change_effective_date_reached"
                    ],
                    "defaultSave": false
                },
                "preDataPath": [
                    "data",
                    "oldValues"
                ],
                "postDataPath": [
                    "data",
                    "values"
                ],
                "comparisons": [
                    {
                        "fieldName": "value",
                        "oldFieldPath": [
                            "data",
                            "oldValues"
                        ],
                        "newFieldPath": [
                            "data",
                            "values"
                        ]
                    }
                ],
                "fieldsToBeExtracted": [
                    {
                        "fieldPath": [
                            "data"
                        ],
                        "currentFieldNames": [
                            "emp_number",
                            "effective_date"
                        ],
                        "newFieldNames": [
                            "empNumber",
                            "effectiveDate"
                        ]
                    },
                    {
                        "fieldPath": [
                            "event"
                        ],
                        "currentFieldNames": [
                            "id"
                        ],
                        "newFieldNames": [
                            "id"
                        ]
                    },
                    {
                        "fieldPath": [
                            "data"
                        ],
                        "currentFieldNames": [
                            "effective_date",
                            "effective_date"
                        ],
                        "newFieldNames": [
                            "date",
                            "effectiveDate"
                        ]
                    },
                    {
                        "fieldPath": [],
                        "currentFieldNames": [
                            "integration_process_id"
                        ],
                        "newFieldNames": [
                            "integration_process_id"
                        ]
                    }
                ],
                "comparisonRules": {
                    "comparisonMethod": "",
                    "customSectionIds": [],
                    "customFieldUniqueNames": []
                }
            }
        },
        {
            "name": "SalaryValueChangeVerifierMediator",
            "properties": {
                "eventsToExecute": {
                    "eventNameFieldName": "name",
                    "eventNameFieldPath": [
                        "event"
                    ],
                    "eventNames": [
                        "pim.salary_change_effective_date_reached"
                    ],
                    "defaultSave": false
                },
                "preDataPath": [
                    "data",
                    "old-salary-record"
                ],
                "postDataPath": [
                    "data",
                    "new-salary-record"
                ],
                "comparisons": [
                    {
                        "fieldName": "pay_grade_id",
                        "oldFieldPath": [
                            "data",
                            "old-salary-record"
                        ],
                        "newFieldPath": [
                            "data",
                            "new-salary-record"
                        ]
                    },
                    {
                        "fieldName": "currency_id",
                        "oldFieldPath": [
                            "data",
                            "old-salary-record"
                        ],
                        "newFieldPath": [
                            "data",
                            "new-salary-record"
                        ]
                    },
                    {
                        "fieldName": "value",
                        "oldFieldPath": [
                            "data",
                            "old-salary-components"
                        ],
                        "newFieldPath": [
                            "data",
                            "employee-salary-component-data"
                        ]
                    }
                ],
                "fieldsToBeExtracted": [
                    {
                        "fieldPath": [
                            "data",
                            "new-salary-record"
                        ],
                        "currentFieldNames": [
                            "employee_number",
                            "effective_date"
                        ],
                        "newFieldNames": [
                            "empNumber",
                            "effectiveDate"
                        ]
                    },
                    {
                        "fieldPath": [
                            "event"
                        ],
                        "currentFieldNames": [
                            "id"
                        ],
                        "newFieldNames": [
                            "id"
                        ]
                    },
                    {
                        "fieldPath": [
                            "data",
                            "new-salary-record"
                        ],
                        "currentFieldNames": [
                            "effective_date",
                            "effective_date"
                        ],
                        "newFieldNames": [
                            "date",
                            "effectiveDate"
                        ]
                    },
                    {
                        "fieldPath": [],
                        "currentFieldNames": [
                            "integration_process_id"
                        ],
                        "newFieldNames": [
                            "integration_process_id"
                        ]
                    }
                ]
            }
        },
        {
            "name": "ChangeVerifierMediator",
            "properties": {
                "eventsToExecute": {
                    "eventNameFieldName": "name",
                    "eventNameFieldPath": [
                        "event"
                    ],
                    "eventNames": [
                        "pim.first_time_joined_date_reached"
                    ],
                    "defaultSave": true
                },
                "preDataPath": [],
                "postDataPath": [],
                "comparisons": [],
                "fieldsToBeExtracted": [
                    {
                        "fieldPath": [
                            "data",
                            "employee"
                        ],
                        "currentFieldNames": [
                            "empNumber"
                        ],
                        "newFieldNames": [
                            "empNumber"
                        ]
                    },
                    {
                        "fieldPath": [
                            "event"
                        ],
                        "currentFieldNames": [
                            "id"
                        ],
                        "newFieldNames": [
                            "id"
                        ]
                    },
                    {
                        "fieldPath": [
                            "data",
                            "employee"
                        ],
                        "currentFieldNames": [
                            "joined_date"
                        ],
                        "newFieldNames": [
                            "date"
                        ]
                    },
                    {
                        "fieldPath": [],
                        "currentFieldNames": [
                            "integration_process_id"
                        ],
                        "newFieldNames": [
                            "integration_process_id"
                        ]
                    }
                ]
            }
        },
        {
            "name": "ChangeVerifierMediator",
            "properties": {
                "eventsToExecute": {
                    "eventNameFieldName": "name",
                    "eventNameFieldPath": [
                        "event"
                    ],
                    "eventNames": [
                        "pim.current_job_record_updated_due_to_history_delete",
                        "pim.job_record_updated_due_to_history_delete"
                    ],
                    "defaultSave": false
                },
                "preDataPath": [
                    "data",
                    "old-job-record"
                ],
                "postDataPath": [
                    "data",
                    "new-job-record"
                ],
                "comparisons": [
                    {
                        "fieldName": "joined_date",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "probation_end_date",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "date_of_permanency",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "id",
                        "mappedReportFieldName": "JobTitle.id",
                        "oldFieldPath": [
                            "data",
                            "old-job-record",
                            "JobTitle"
                        ],
                        "newFieldPath": [
                            "data",
                            "new-job-record",
                            "JobTitle"
                        ]
                    },
                    {
                        "fieldName": "id",
                        "mappedReportFieldName": "EmploymentStatus.id",
                        "oldFieldPath": [
                            "data",
                            "old-job-record",
                            "EmploymentStatus"
                        ],
                        "newFieldPath": [
                            "data",
                            "new-job-record",
                            "EmploymentStatus"
                        ]
                    },
                    {
                        "fieldName": "id",
                        "mappedReportFieldName": "JobCategory.id",
                        "oldFieldPath": [
                            "data",
                            "old-job-record",
                            "JobCategory"
                        ],
                        "newFieldPath": [
                            "data",
                            "new-job-record",
                            "JobCategory"
                        ]
                    },
                    {
                        "fieldName": "id",
                        "mappedReportFieldName": "SubUnit.id",
                        "oldFieldPath": [
                            "data",
                            "old-job-record",
                            "SubUnit"
                        ],
                        "newFieldPath": [
                            "data",
                            "new-job-record",
                            "SubUnit"
                        ]
                    },
                    {
                        "fieldName": "location_id",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "work_schedule_id",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    },
                    {
                        "fieldName": "cost_centre_id",
                        "oldFieldPath": [],
                        "newFieldPath": []
                    }
                ],
                "fieldsToBeExtracted": [
                    {
                        "fieldPath": [
                            "data",
                            "new-job-record"
                        ],
                        "currentFieldNames": [
                            "employee_number",
                            "effective_date"
                        ],
                        "newFieldNames": [
                            "empNumber",
                            "effectiveDate"
                        ]
                    },
                    {
                        "fieldPath": [
                            "event"
                        ],
                        "currentFieldNames": [
                            "timestamp",
                            "id"
                        ],
                        "newFieldNames": [
                            "date",
                            "id"
                        ]
                    },
                    {
                        "fieldPath": [],
                        "currentFieldNames": [
                            "integration_process_id"
                        ],
                        "newFieldNames": [
                            "integration_process_id"
                        ]
                    }
                ]
            }
        },
        {
            "name": "SalaryValueChangeVerifierMediator",
            "properties": {
                "eventsToExecute": {
                    "eventNameFieldName": "name",
                    "eventNameFieldPath": [
                        "event"
                    ],
                    "eventNames": [
                        "pim.current_salary_record_updated_due_to_history_delete",
                        "pim.salary_record_updated_due_to_history_delete"
                    ],
                    "defaultSave": false
                },
                "preDataPath": [
                    "data",
                    "old-salary-record"
                ],
                "postDataPath": [
                    "data",
                    "new-salary-record"
                ],
                "comparisons": [
                    {
                        "fieldName": "pay_grade_id",
                        "oldFieldPath": [
                            "data",
                            "old-salary-record"
                        ],
                        "newFieldPath": [
                            "data",
                            "new-salary-record"
                        ]
                    },
                    {
                        "fieldName": "currency_id",
                        "oldFieldPath": [
                            "data",
                            "old-salary-record"
                        ],
                        "newFieldPath": [
                            "data",
                            "new-salary-record"
                        ]
                    },
                    {
                        "fieldName": "value",
                        "oldFieldPath": [
                            "data",
                            "old-salary-components"
                        ],
                        "newFieldPath": [
                            "data",
                            "employee-salary-component-data"
                        ]
                    }
                ],
                "fieldsToBeExtracted": [
                    {
                        "fieldPath": [
                            "data",
                            "new-salary-record"
                        ],
                        "currentFieldNames": [
                            "employee_number",
                            "effective_date"
                        ],
                        "newFieldNames": [
                            "empNumber",
                            "effectiveDate"
                        ]
                    },
                    {
                        "fieldPath": [
                            "event"
                        ],
                        "currentFieldNames": [
                            "timestamp",
                            "id"
                        ],
                        "newFieldNames": [
                            "date",
                            "id"
                        ]
                    },
                    {
                        "fieldPath": [],
                        "currentFieldNames": [
                            "integration_process_id"
                        ],
                        "newFieldNames": [
                            "integration_process_id"
                        ]
                    }
                ]
            }
        },
        {
            "name": "DispatchDataToDatabaseMediator",
            "properties": {
                "changeIdentification": {
                    "fieldName": "changeDetected",
                    "fieldPath": [
                        "changeVerificationData"
                    ]
                },
                "insertMode": "SQL",
                "extractedData": {
                    "fieldPath": [
                        "changeVerificationData",
                        "extractedInfo"
                    ]
                },
                "databaseMapping": [
                    {
                        "tableName": "ohrm_external_payroll_changed_employee",
                        "entityName": "ChangedEmployee",
                        "mappingfields": [
                            {
                                "entityField": "changedEmpNumber",
                                "tableField": "changed_emp_number",
                                "extractingFieldName": "empNumber"
                            },
                            {
                                "entityField": "changedDate",
                                "tableField": "changed_date",
                                "extractingFieldName": "date"
                            },
                            {
                                "entityField": "async_event_id",
                                "tableField": "async_event_id",
                                "extractingFieldName": "id"
                            },
                            {
                                "entityField": "external_integration_process_id",
                                "tableField": "external_integration_process_id",
                                "extractingFieldName": "integration_process_id"
                            },
                            {
                                "entityField": "fields_changed",
                                "tableField": "fields_changed",
                                "extractingFieldName": "fieldsChanged",
                                "preProcessing": [
                                    "json-encode",
                                    "encrypt"
                                ]
                            }
                        ]
                    }
                ]
            }
        }
    ]
}' as configuration, NULL as parameters, '1' as isConsumer, '1' as enabled) as temp
WHERE NOT EXISTS (
    SELECT name FROM `ohrm_external_integration_process` WHERE name = 'ChangedEmployeeVerificationWithFutureEffective'
) LIMIT 1;

INSERT INTO `ohrm_external_integration_process` (`name`, `configuration`, `parameters`, `isConsumer`, `enabled`)
SELECT * FROM (SELECT 'ChangedEmployeeReportGeneration' as name, '{
    "replacementParameters": {
        "client_id": "Oauth client id",
        "client_secret": "Oauth client secret"
    },
    "subscribedEvents": [],
    "processCoordinator": "BasicIntegrationProcessCoordinator",
    "dataFlow": [
        {
            "name": "APIDataFetchMediator",
            "properties": {
                "oauthConfig": true,
                "oauthConfigData": {
                    "grantType": "client_credentials",
                    "client_id": "##client_id##",
                    "client_secret": "##client_secret##",
                    "scope": "",
                    "url": "https://[systemURL]/index.php/oauth/issueToken",
                    "redirect_uri": "",
                    "state": "",
                    "username": "",
                    "password": "",
                    "refresh_token": ""
                },
                "method": "get",
                "parameters": [
                    {
                        "parameterName": "limit",
                        "fieldName": "limit",
                        "fieldPath": []
                    },
                    {
                        "parameterName": "offset",
                        "fieldName": "offset",
                        "fieldPath": []
                    }
                ],
                "parametersDataPath": [
                    "filters"
                ],
                "expectedResponseCode": "200",
                "additionalHeaders": [],
                "dataURl": "https://[systemURL]/index.php/api/exportReportData/uniqueName/Changed_Employee_Information_Export_Report/format/csv/culture/en/limit/[limit]/offset/[offset]",
                "aggregatedFieldName": "employeeData",
                "dataConvertConfig": {
                    "from": "csvArray",
                    "to": "phpArray"
                },
                "aggregatedDataSet": "message"
            }
        },
        {
            "name": "ArrayManipulateMediator",
            "properties": {
                "arrayFormats": [
                    {
                        "formatName": "changeArrayValues",
                        "properties": {
                            "arrayPath": [
                                "employeeData"
                            ],
                            "aggregatedFieldName": "Employee Number",
                            "fieldPath": [],
                            "fieldNames": [
                                "Personal-Employee Id"
                            ]
                        }
                    },
                    {
                        "formatName": "changeArrayValues",
                        "properties": {
                            "arrayPath": [
                                "employeeData"
                            ],
                            "aggregatedFieldName": "Changed Date Time",
                            "fieldPath": [],
                            "fieldNames": [
                                "Personal-Changed Time"
                            ]
                        }
                    },
                    {
                        "formatName": "changeArrayValues",
                        "properties": {
                            "arrayPath": [
                                "employeeData"
                            ],
                            "aggregatedFieldName": "Event Recorded Date/Time (UTC)",
                            "fieldPath": [],
                            "fieldNames": [
                                "Personal-Event Recorded Date/Time (UTC)"
                            ]
                        }
                    },
                    {
                        "formatName": "changeArrayValues",
                        "properties": {
                            "arrayPath": [
                                "employeeData"
                            ],
                            "aggregatedFieldName": "Change Event Name",
                            "fieldPath": [],
                            "fieldNames": [
                                "Personal-Change Event Name"
                            ]
                        }
                    },
                    {
                        "formatName": "changeArrayValues",
                        "properties": {
                            "arrayPath": [
                                "employeeData"
                            ],
                            "aggregatedFieldName": "Fields Changed",
                            "fieldPath": [],
                            "fieldNames": [
                                "Personal-Fields Changed"
                            ]
                        }
                    }
                ]
            }
        }
    ]
}' as configuration, NULL as parameters, '0' as isConsumer, '1' as enabled) as temp
WHERE NOT EXISTS (
    SELECT name FROM `ohrm_external_integration_process` WHERE name = 'ChangedEmployeeReportGeneration'
) LIMIT 1;

INSERT INTO `ohrm_external_integration_process` (`name`, `configuration`, `parameters`, `isConsumer`, `enabled`)
SELECT * FROM (SELECT 'ChangedEmployeeHistoryReportGeneration' as name, '{
    "replacementParameters": {
        "client_id": "Oauth client id",
        "client_secret": "Oauth client secret"
    },
    "subscribedEvents": [],
    "processCoordinator": "BasicIntegrationProcessCoordinator",
    "dataFlow": [
        {
            "name": "APIDataFetchMediator",
            "properties": {
                "oauthConfig": true,
                "oauthConfigData": {
                    "grantType": "client_credentials",
                    "client_id": "##client_id##",
                    "client_secret": "##client_secret##",
                    "scope": "",
                    "url": "https://[systemURL]/index.php/oauth/issueToken",
                    "redirect_uri": "",
                    "state": "",
                    "username": "",
                    "password": "",
                    "refresh_token": ""
                },
                "method": "get",
                "parameters": [
                    {
                        "parameterName": "limit",
                        "fieldName": "limit",
                        "fieldPath": []
                    },
                    {
                        "parameterName": "offset",
                        "fieldName": "offset",
                        "fieldPath": []
                    }
                ],
                "parametersDataPath": [
                    "filters"
                ],
                "expectedResponseCode": "200",
                "additionalHeaders": [],
                "dataURl": "https://[systemURL]/index.php/api/exportReportData/uniqueName/Changed_Employee_Information_Export_Report_Separate_JobSalary_History/format/csv/culture/en/limit/[limit]/offset/[offset]",
                "aggregatedFieldName": "employeeData",
                "dataConvertConfig": {
                    "from": "csvArray",
                    "to": "phpArray"
                },
                "aggregatedDataSet": "message"
            }
        },
        {
            "name": "ArrayManipulateMediator",
            "properties": {
                "arrayFormats": [
                    {
                        "formatName": "changeArrayValues",
                        "properties": {
                            "arrayPath": [
                                "employeeData"
                            ],
                            "aggregatedFieldName": "Employee Number",
                            "fieldPath": [],
                            "fieldNames": [
                                "Personal-Employee Id"
                            ]
                        }
                    },
                    {
                        "formatName": "changeArrayValues",
                        "properties": {
                            "arrayPath": [
                                "employeeData"
                            ],
                            "aggregatedFieldName": "Changed Date Time",
                            "fieldPath": [],
                            "fieldNames": [
                                "Personal-Changed Time"
                            ]
                        }
                    },
                    {
                        "formatName": "changeArrayValues",
                        "properties": {
                            "arrayPath": [
                                "employeeData"
                            ],
                            "aggregatedFieldName": "Event Recorded Date/Time (UTC)",
                            "fieldPath": [],
                            "fieldNames": [
                                "Personal-Event Recorded Date/Time (UTC)"
                            ]
                        }
                    },
                    {
                        "formatName": "changeArrayValues",
                        "properties": {
                            "arrayPath": [
                                "employeeData"
                            ],
                            "aggregatedFieldName": "Change Event Name",
                            "fieldPath": [],
                            "fieldNames": [
                                "Personal-Change Event Name"
                            ]
                        }
                    }
                ]
            }
        }
    ]
}' as configuration, NULL as parameters, '0' as isConsumer, '1' as enabled) as temp
WHERE NOT EXISTS (
    SELECT name FROM `ohrm_external_integration_process` WHERE name = 'ChangedEmployeeHistoryReportGeneration'
) LIMIT 1;

SET @changed_employee_detection_integration_id = (SELECT id FROM `ohrm_external_integration_process` WHERE name = 'ChangedEmployeeVerification');
SET @changed_employee_detection_integration_with_future_effective_id = (SELECT id FROM `ohrm_external_integration_process` WHERE name = 'ChangedEmployeeVerificationWithFutureEffective');
INSERT INTO `ohrm_config` (`property`, `value`) VALUES ('esb.employee_data_export_enabled_date', CURDATE());
INSERT INTO `ohrm_integration_process_queue_consumer` (`consumer_id`, `integration_id`) VALUES
    (@changed_employee_detection_cosumer_id, @changed_employee_detection_integration_id);
INSERT INTO `ohrm_integration_process_queue_consumer` (`consumer_id`, `integration_id`) VALUES
    (@changed_employee_detection_cosumer_with_future_effective_id, @changed_employee_detection_integration_with_future_effective_id);

-- Delta Report Update Menu Item and Custom URL
SET @employee_management_folder_id := (SELECT id FROM ohrm_report_folder WHERE name = 'Employee Management');
SET @delta_report := (SELECT id FROM ohrm_advanced_report WHERE unique_name = 'Changed_Employee_Information_Export_Report');
SET @system_user_role_id := (SELECT `id` FROM `ohrm_user_role` WHERE `name` = 'SYSTEM');
SET @system_user_id := (SELECT `id` FROM `ohrm_user` WHERE `user_role_id` = @system_user_role_id);
UPDATE `ohrm_advanced_report` SET `folder_id` = @employee_management_folder_id WHERE `id` IN (@delta_report);
UPDATE `ohrm_advanced_report` SET `custom_url` = '/noncore/pim/manageDataEmployeeInformationReport', `created_by` = @system_user_id WHERE `id` = @delta_report;
UPDATE `ohrm_advanced_report` SET `schedulable` = '0' WHERE `id` = @delta_report;
