Correction updates existing member data on an active policy via Excel upload (files.action = correction). The final step creates pending correction endorsements on the employees table — data is not updated until those endorsements are applied downstream.

Processing is in EmployeeServiceController::employeesCorrectionProcess, queued after the same format and data validation steps used for inception and deletion.

Overview

flowchart LR A["Upload Excel action correction"] --> B["excelFileFormatValidation"] B --> C["excelFileDataValidation"] C --> D["employeesCorrectionProcess job"] D --> E["emp_endorsement pending on employees"] B -->|errors| F["files.status failed"] C -->|errors| F D -->|loop done| G["files.status success"]

In short:

Key files and routes

AreaLocation
UI app/Views/employee_upload.php — action Correction
Upload EmployeeController::employeesUplodWithEvents
Validation excelFileFormatValidation, excelFileDataValidation
Correction process EmployeeServiceController::employeesCorrectionProcess
Column config API getCorrectionExcelColumns() — used when building correction Excel programmatically
Job employeesCorrectionProcess in JobWorker.php
Endorsements EmpEndorsementModelactions = c, table_name = employees, status = pending

Routes (group /employee, authMVC):

i
files.policy_id is the client policy id. Lookup requires active employees + employee_polices on that policy and branch.

Sync vs background jobs

Step< 1 MB≥ 1 MB
Format validationInline on uploadJob excelFileFormatValidation
Data validationJob excelFileDataValidationSame
Correction processJob employeesCorrectionProcessSame

Step 1: excelFileFormatValidation

Format error codes

CodeMeaning
1Mandatory missing
2Wrong format
3Not in allowed list (e.g. invalid Field value)
4Custom validation failed
5File / policy problem
6Column headers wrong

Step 2: excelFileDataValidation

Rows grouped by EMP ID; for correction the critical check is name_and_empid_check_in_db:

On success → queues employeesCorrectionProcess (with optional batch_file_id for TPA multi-file flows).

Step 3: employeesCorrectionProcess

flowchart TD A["Read each Excel row"] --> B["Match emp_code plus name on active policy"] B --> C{"Pending correction for same field?"} C -->|Yes| D["Skip row"] C -->|No| E["Insert emp_endorsement actions c"] E --> F["old_value from DB new_value from Excel"]

Per row:

Skips insert when a pending correction endorsement already exists for the same emp_code, name, and field_name (actions = c, endorsement_id IS NULL, status != truncated).

Sets files.status = success when the loop completes and sends a success pull notification. Rows with no DB match are not endorsed (no row-level failure on the file record).

TPA batch: If batch_file_id is set, also queues updateEmployeeDataFromTpa, reconTpaApiDataWithEmployeepolicies, and initializeDeletionProcessForTpaApiData.

Correction Excel columns

ColHeaderRequiredNotes
AS.NoYes
BEMP IDYes
CNAME OF EMP/DEPYesMust match DB before correction
DFieldYesname, dob, relationship, email_corporate
EValueYesNew value; DOB as d-M-Y
FDate of CorrectionYesd-M-Y
GChange eventYese.g. correction
HRemarksNoStored on endorsement

Row layout examples

Fix DOB — one row, one field:

EMP IDNAMEFieldValueDate of CorrectionChange eventRemarks
EMP001 Raj Kumar dob 15-Jan-1985 19-May-2026 correction Typo in upload

Multiple fixes — use separate rows (same or different members):

EMP IDNAMEFieldValue
EMP001Raj Kumaremail_corporateraj.kumar@company.com
EMP001Priya KumarrelationshipSpouse

Developer steps

  1. Upload with upload-action-type=correction; note file_id.
  2. On validation failure, check /employee/excel_error/{file_id} for code 10.
  3. After success, query emp_endorsement where file_id = upload id, actions = 'c', status = 'pending'.
  4. Compare field_name, old_value, new_value per row to the Excel.
  5. To generate correction Excel in code, use getCorrectionExcelColumns() for header layout.

Common pitfalls

Related: Inception, Deletion.