Plan Facts Parsing Analysis · v1
Single-class parse covering hospital admission and ICU benefits, daily confinement, HSA compatibility, mental-health and pre-existing condition rules, plus four-tier composite rates.
Cross-write: Substance Abuse reads from Mental/Nervous source.
Lines 1830–1860: the Mental/Nervous Plan Facts field is read once and assigned to BOTH the hospitalIndemnityMentalNervousDisorders field AND hospitalIndemnityDrugAndAlchoholAbuse. If Plan Facts has a separate Substance Abuse field, it's silently dropped, and the Mental/Nervous value overwrites Substance Abuse data on the Quote. This is a real bug.
Single-class. The parser reads $class = $data['Hospital Indemnity']['Classes'][0] at line 1710 and uses that one class for every subsequent lookup. No multi-class iteration.
| Plan Facts field | Quote field | Notes |
|---|---|---|
| Plan Name | name | Direct |
| Participation.[Class].Minimum Participation % | hospitalIndemnityParticipationRequired | Strip % |
| Participation.[Class].Minimum Enrolled Lives | hospitalIndemnityMinimumLives | Numeric |
| HSA Compatibility.[Class].HSA Compatibility | hospitalIndemnityHsaCompatible | "true"/true → Yes (line 1742) |
| Wellness Benefit.[Class].Employee | hospitalIndemnityWellnessBenefit | Direct |
| Admission Benefits.[Class].Hospital Admission Benefit Amount | hospitalIndemnityHospitalAdmission | Currency stripped |
| Admission Benefits.[Class].Hospital Admissions Per Year | hospitalIndemnityAdmissionLimits | "X per year" |
| Admission Benefits.[Class].ICU Admission Benefit Amount | hospitalIndemnityIcuAdmission | Currency stripped |
| Confinement Benefits.[Class].Daily Hospital Confinement Benefit Amount | hospitalIndemnityHospitalConfinement | Currency stripped |
| Confinement Benefits.[Class].Daily Hospital Confinement Benefit Duration | hospitalIndemnityHospitalMaxDays | Direct (e.g. "30 days") |
| Confinement Benefits.[Class].Daily ICU Confinement Benefit Amount | hospitalIndemnityHospitalIcuConfinement | Currency stripped |
| Confinement Benefits.[Class].Daily ICU Confinement Benefit Duration | hospitalIndemnityIcuMaxDays | Direct |
| Other Conditions.[Class].Pregnancy Waiting Period | hospitalIndemnityMaternityWait | Direct |
| Other Conditions.[Class].Mental/Nervous | hospitalIndemnityMentalNervousDisorders | Covered / Not Covered (line 1830) |
| Other Conditions.[Class].Mental/Nervous | hospitalIndemnityDrugAndAlchoholAbuse | ⚠ Reads same source as above — should be Substance Abuse field (line 1847) |
| Pre-existing Conditions.[Class].Look-back Period | hospitalIndemnityPreExistingConditionsLookback | Direct |
| Pre-existing Conditions.[Class].Exclusion Period | hospitalIndemnityPreExistingConditionsExclusion | Direct |
| Portability.[Class].Portability | hospitalIndemnityPortability | Included / Not Included |
| Rates.[Class].Employee Only / + Spouse / + Children / Family | hospitalIndemnityEE, …ES, …EC, …EF | Currency stripped (line 1899) |
Lines 1830–1843 correctly read 'Other Conditions.' . $class . '.Mental/Nervous' and write to hospitalIndemnityMentalNervousDisorders. Lines 1847–1860 read the same source path again and write to hospitalIndemnityDrugAndAlchoholAbuse. If Plan Facts returns a separate Substance Abuse field, it's silently dropped; the Mental/Nervous value gets used in its place.
In app/Services/PlanfactService.php at lines 1847–1860, inside parseQuoteHospitalIndemnity(), the assignment for hospitalIndemnityDrugAndAlchoholAbuse reads from the same Plan Facts path as Mental/Nervous: 'Other Conditions.' . $class . '.Mental/Nervous' This is almost certainly wrong. It should read from a separate Substance Abuse field — likely something like: 'Other Conditions.' . $class . '.Substance Abuse' or: 'Other Conditions.' . $class . '.Substance Abuse and Mental Health' Please: 1. Show me lines 1830–1860 — the Mental/Nervous and Substance Abuse blocks. 2. Look at sample Plan Facts response data (or the schema docs if available) to identify the correct Substance Abuse path key. 3. Fix the source path on lines 1847–1860 to use the correct key. 4. Then grep the rest of PlanfactService.php for any other places where the same source path appears in two consecutive blocks — there may be similar copy-paste errors. Report any you find. Note the field name typo: "DrugAndAlchohol" should probably be "DrugAndAlcohol" — but DO NOT rename the field unless that's a separate ask, since it would touch the Quote model and form templates.
The rate parsing maps coverage tiers by position in the array (Employee Only → EE, +Spouse → ES, +Children → EC, Family → EF). If Plan Facts ever returns these keys in a different order, the alignment breaks silently. Worth confirming whether order is guaranteed.
In app/Services/PlanfactService.php at lines 1899–1918, inside parseQuoteHospitalIndemnity(), the rate parsing iterates the Rates array in order and maps positions to coverage tiers (EE, ES, EC, EF).
If Plan Facts ever returns the rate tiers in a different order (or with different/extra keys), the mapping silently misaligns.
Please:
1. Show me the current iteration logic.
2. Refactor it to look up rates by explicit coverage tier name ("Employee Only", "Employee plus Spouse", "Employee plus Children", "Family") rather than by array position.
3. If a known coverage tier is missing from the response, leave the corresponding Quote field empty rather than substituting a wrong value.
4. Show me the proposed change.
Change line 1847's source path from Mental/Nervous to the correct Substance Abuse key.
Replace position-based iteration with explicit name-based lookup so out-of-order responses don't silently misalign.
Line 1742–1747 accepts "true", true, "false". Add a comment listing the accepted values, or normalize at one entry point.
| File | Lines | Purpose |
|---|---|---|
| app/Services/PlanfactService.php | 259 | Hospital Indemnity endpoint config |
| app/Services/PlanfactService.php | 461 | Dispatch to parseQuoteHospitalIndemnity |
| app/Services/PlanfactService.php | 1703–1921 | Full parser |
| app/Services/PlanfactService.php | 1710 | Single-class selection |
| app/Services/PlanfactService.php | 1847–1860 | Substance Abuse cross-write |
| app/Services/PlanfactService.php | 1899–1918 | Rate position-based lookup |