6.6 KiB
6.6 KiB
2026-04-04 — Daily tasks
VidalGetBenefDetailsV2 (Enrollment Dump API)
Context
- Goal: Add
VidalApiController::VidalGetBenefDetailsV2, mirroringVidalGetBenefDetailsend-to-end (batch gate, JSON dump,saveVidalAPIDatajob, employee match,tpa_idupdate, e-card job, batch file status), but calling the Enrollment info integration used inTestingController::getVidalEnrollmentInfo()for URL, headers, and request body shape only. - Reference sample:
public/tmp/Enrollment Dump API.docx— HTTP 200 body isstatus,data(array of member rows),trace,successful. - Note on “same format”: The raw Enrollment API uses different field names (
beneficiaryName,membershipNo,employeeNo,dateOfBirth,relation, etc.). The implementation normalizes each row to the same internal dependent shape as V1 (name,empNo,relationship,gender,dob,enrollmentId,policyNumber,age) so matching,saveVidalAPIData, and logging stay unchanged.
Plan
-
HTTP contract (from Testing, env-aware URL)
- URL:
vidalEnrollmentInfoApiUrl()— ifVIDAL_API_BASE_URLends with/api, strip it and append/enrollment/info(matcheshttps://devapigw.vidalhealthtpa.com/partner-integration/enrollment/info); otherwise fall back to that dev URL. - Headers:
Content-Type: application/json,ocp-apim-subscription-key: {VIDAL_API_SUBSCRIPTION_KEY}(same asgetVidalEnrollmentInfo). - Body:
policyNo,startIndex,endIndex(paginated windows; current page size 100 in code).
- URL:
-
Fetch loop
- Keep the same batch_files prerequisite as V1 (TPA export rows for
client_policy_id). - Replace V1’s per–export-date
startDate/endDatecalls with pagination until a page returns fewer thanpageSizerows or an empty page (after the first).
- Keep the same batch_files prerequisite as V1 (TPA export rows for
-
Response handling
- Require
status === 'SUCCESS'; ifsuccessfulis present andfalse, treat as failure. - Read rows from
data(top-level array in the decoded JSON). - Map each row through
normalizeVidalEnrollmentRecordToDependentFormat()(reference map fromrelationship.csvbaked into code,membershipNo→enrollmentId,beneficiaryName→name, plussi/doj/descfortpa_api_data— see Relationship & TPA columns below).
- Require
-
Downstream (unchanged from V1)
- Write merged dependents JSON under
writable/tmp/, queuesaveVidalAPIData, run the same DB match/update and e-card / batch_file status logic. - SQL: V2 uses valid
UPDATE employee_polices SET tpa_id = … WHERE id = …(no stray comma beforeWHERE).
- Write merged dependents JSON under
-
Wiring
- Route:
GET VidalGetBenefDetailsV2→VidalApiController::VidalGetBenefDetailsV2. Acl.php: public entry like V1.JobWorker.php: jobVidalGetBenefDetailsV2→VidalApiController(method name matches job name).
- Route:
-
Follow-ups (optional)
- Switch
ApiServiceControllerTPA pull fromVidalGetBenefDetailstoVidalGetBenefDetailsV2when product confirms Enrollment API for all policies. - Revisit emp_code ↔ employeeNo matching if dependents share the same
employeeNoin real dumps (doc sample shows repeatedemployeeNofor family members).
- Switch
Tasks
- Implement
normalizeVidalEnrollmentRecordToDependentFormat,vidalEnrollmentInfoApiUrl, andVidalGetBenefDetailsV2inVidalApiController.php. - Register route, ACL, and
JobWorkerjobVidalGetBenefDetailsV2. - Document plan and tasks in this file (
2026-04-04.md).
Job payload (same shape as V1)
policy_no, client_policy_id, file_id, return_type (job when queued).
Manual check
- With valid env and data: enqueue
VidalGetBenefDetailsV2or callGET …/VidalGetBenefDetailsV2with the same query/body conventions as V1 (if wired), and confirm logs showVIDAL V2 - TPA ID Pullandtpa_api_datarows aftersaveVidalAPIData.
Vidal relationship.csv → Nhance + tpa_api_data extra columns
Context
- Reference file:
public/tmp/relationship.csv— documentation only (not read at runtime). Column A = VidalVIDAL_RELSHIP_DESCRIPTION, column C =OUR RELATIONSHIPS(separator,,). Only rows with a non-empty “ours” value are represented in code (currently eight entries). - Scope (per request): Use this mapping only in
VidalGetBenefDetailsV2(vianormalizeVidalEnrollmentRecordToDependentFormat) and insaveVidalAPIData. V1VidalGetBenefDetails/ legacy JSON rows withoutvidal_relation_rawkeep the previous behaviour (strtolower(relationship)only).
Plan
- Baked-in map —
vidalRelationshipReferenceMap()returns the associative array (lowercase Vidal → lowercase Nhance) copied from the reference CSV. Constructor sets$this->vidalRelationshipMaponce from that method. To add mappings, edit the PHP array and keep the CSV in sync as documentation. - Map function —
mapVidalRelationshipToNhance($vidalRelationDescription)returns a hit from$this->vidalRelationshipMapif present; elseEmployee/Employees→self; elsestrtolower(str_replace('-', ' ', $raw)). - V2 normalization —
normalizeVidalEnrollmentRecordToDependentFormat()setsrelationshipfrom the mapper, addsvidal_relation_rawfor persistence/audit,sifrombaseSumInsured,dojfromdateOfJoining(Y-m-d vianormalizeVidalEnrollmentDateToYmd),descfrombuildVidalEnrollmentDescForTpaRow()(productName,remarks,insuredName). saveVidalAPIData— Ifvidal_relation_rawis present, recomputerelationwithmapVidalRelationshipToNhance(keeps DB aligned even if JSON is tweaked). Setselffrom mappedrelation === 'self'. Populatedesc,si,dojperTpaApiDataModel::$allowedFields.descstored asVidal relation: … | …plus JSONdescwhen both exist.- Model — No schema change; fields already in
app/Models/TpaApiDataModel.php:desc,si,doj.
Tasks
- Add
vidalRelationshipReferenceMap()+ constructor copy to$vidalRelationshipMap,mapVidalRelationshipToNhance, and date helper onVidalApiController. - Extend enrollment normalization with
vidal_relation_raw,si,doj,desc. - Update
saveVidalAPIDatamapping and extra columns. - Document in
2026-04-04.md.
Caveats
- CSV lines like
Father (2),,Selfmap that exact Vidal string to Nhanceself; ensure APIrelationstrings match the CSV keys (case-insensitive). - Rows in the CSV with no “ours” value are ignored; those relations fall through to
Employee/Employeesor generic lowercasing.