Handoff Packet Day 3 to Day 4

What I asked

Can we do this? Can you please create a handoff statement and complete handoff packet for the next chat? This one is starting to slow down and freeze up. I think it’s because it’s getting too long, so I think it would be good to pick this up in the next chat. Thank you for everything you’ve done. I need the handoff packet to thoroughly explain what we’re doing, where we’ve been, where we were at the start of this chat, what we got accomplished, all of the nice to haves you just mentioned, and what’s planned next for phase one by day, but also what’s planned for phase two and three, etc. I don’t want to lose anything and since the memory is full, if you don’t include it in the handoff packet, it will be lost. Please mention that, before diving in and making changes, I am going to paste in the contents of some of the most used PHP forms. Please emphasize that I need entire pages (phps) or at least big sections to overwrite rather than trying to find specific lines. But also emphasize that we need to be careful not to remove something we’ve already made progress on when doing a re-write because that would cause us to go backwards, and we don’t want to do that. Does that make sense? Any questions?

Handoff Statement

Hi! This packet is a complete snapshot of our Stella Quotes build so the next chat can pick up seamlessly. The current thread is getting long/slow, so we’re moving to a fresh chat.

Important workflow note: before we make any further changes, I (the user) will paste the full contents of the key PHP files we’re about to touch. I prefer “paste-over” updates of whole files or clearly-bounded big sections—not piecemeal single-line edits—so I don’t have to hunt for exact line numbers. At the same time, we must avoid wiping out progress we’ve already made; so if we do a full paste-over, confirm that all new behaviors listed below still work after the overwrite.


Project: Stella Quotes — Context & Status

What we’re building

A broker-facing quoting tool in WordPress that:

  • Starts with a simple Quote Intake (renewal and/or census).

  • Sends the user to a Compare Picker to choose plans.

  • Renders a side-by-side comparison (screen + export) with consistent formatting.

  • Lets users save a quote (custom post type “Quotes”), duplicate it, and return to Intake or Picker.

  • Supports census persistence, composite math (from renewal EO or census), and fast exports (cached).

Where we were at the start of this chat

  • Older shortcodes were long and brittle; census uploads sometimes caused “critical error” when moving past Intake.

  • Exports were slower and not cache-aware; formatting diverged from screen.

  • Duplicate took users straight to the viewing page (no quick way back to Intake/Picker).

  • No clear way to show that a saved quote had a census attached.

What we accomplished in this chat (Day 2 & Day 3 milestones)

1) Shortcodes & Flow

File: includes/class-stq-shortcodes.php

  • Added

    (Only 1st or 15th of a month)
    How do you want to quote?
    Which option should I choose?

    Quote from Renewal (Composite): Use when the employer has a fully-insured, composite-rated small group plan. No census is needed—enter the employee-only renewal rate for any plan they offer (it doesn’t have to be the current plan).

    Quote from Census: Use for new groups, groups without a fully-insured plan (e.g., level-funded), or when you want age-rate detail on the side-by-side.

    Both: Use when the group is composite-rated but the enrollment census has changed since the carrier issued renewal.

    How is the group currently rated?
    This is used to calculate the renewal increase; it doesn’t limit what you compare.
    Current Plans (optional)
    Add the group’s current plan(s) to enable auto-recommendations and current→renewal views.
    (intake form) with renewal vs. census vs. both modes.

  • Persisted census upload to /uploads/stq-data/census/…csv and forwarded census_path through the flow.

  • Compare Picker (

    ):

    • Pre-fills plan selects (and supports optional auto-pick if a helper class exists).

    • Forwards Intake meta and census_path to

       
      Plan #
      Plan Name
      Network Name
      Network Type
      Plan Type
      Deductible - Individual
      Deductible - Family
      Coinsurance - Member
      Coinsurance - Plan
      Out-of-Pocket - Individual
      Out-of-Pocket - Family
      Virtual Visits
      PCP <19
      Primary
      Specialist
      Urgent Care
      Emergency
      Lab/X-Ray
      Imaging
      Inpatient Services
      Outpatient Surgery
      Prescriptions
      OON Deductible (Individual/Family)
      OON Coinsurance (Member)
      OON Out-of-Pocket (Individual/Family)
      .

  • Side-by-side renderer (

     
    Plan #
    Plan Name
    Network Name
    Network Type
    Plan Type
    Deductible - Individual
    Deductible - Family
    Coinsurance - Member
    Coinsurance - Plan
    Out-of-Pocket - Individual
    Out-of-Pocket - Family
    Virtual Visits
    PCP <19
    Primary
    Specialist
    Urgent Care
    Emergency
    Lab/X-Ray
    Imaging
    Inpatient Services
    Outpatient Surgery
    Prescriptions
    OON Deductible (Individual/Family)
    OON Coinsurance (Member)
    OON Out-of-Pocket (Individual/Family)
    ):

    • Composite amounts from either renewal EO anchor or census file anchor via STQ_Calc.

    • Shows Monthly Rate — EO/ES/EC/EF when available.

    • Shows Monthly Total (group) when counts exist.

    • Group-only Δ vs Renewal (single overall delta) when we have counts + baseline (no tier-by-tier Δ).

    • Formatting parity with export (see formatting section below).

  • Added wrapper so we can stack multiple side-by-side sections on one page.

2) Export speed, cache, and parity with screen

File: includes/class-stq-export-compare.php

  • Fast, cache-aware XLSX writer (ZipArchive, compression 0, no pre-calc).

  • Template-aware paste-over into markers:

    • Use [[STQ_TABLE]] or row mode [[STQ_TABLE_ROWS]] in the Excel template.

    • Placeholder replacements: [[STQ_EMPLOYER]], [[STQ_COMPANY]], [[STQ_BROKER_*]], [[STQ_EFFECTIVE]], [[STQ_RATE_STYLE]], [[STQ_RATE_SET]], [[STQ_AREA]], [[STQ_COUNTY]], [[STQ_DATE_TODAY]], [[STQ_PLANS]], [[STQ_DISCLAIMER]].

  • Rows now match the screen:

    • Core benefits + Rx verbatim

    • Monthly EO/ES/EC/EF (if available)

    • Monthly Total (group) and Group Total Δ vs Renewal (when counts + baseline exist)

  • CSV/PDF/HTML export paths also available (with the same table content).

  • Admin-post endpoints:

    • stq_export_compare_xlsx, stq_export_compare_pdf, stq_export_compare_html

    • Extra flags honored if present: sheet, dry_save, nocache, etc.

3) Cases (saved quotes) & router

File: includes/class-stq-cases.php

4) Census strip on saved quotes

  • On a saved quote view: a small neutral strip indicates “Census attached” with Download and Replace actions. This helps brokers know whether they need to update census.

5) Formatting (screen + export)

  • Benefits now match UI expectations:

    • Keep $0 exactly as $0 (no decimals).

    • Preserve mixed strings like $150 + D&C (keep the $ at the front).

    • Rx strings are verbatim (no money/coins formatting).

    • OON rows are set to N/A when suppressed for HMO/EPO via STQ_Format::na_if_oonsuppressed_*.

    • Coinsurance accepts 0.2, 20, 20% and renders as %.


Quick File Map (touched in this chat)

  1. includes/class-stq-shortcodes.php

    • New/changed: quote_intake, compare_picker, compare, bundle

    • Helpers: benefit & coins formatters aligned with export (plus Rx verbatim rule)

  2. includes/class-stq-export-compare.php

    • handle_xlsx, handle_pdf, handle_html

    • build_compare_matrix (appends EO/ES/EC/EF, Monthly Total, Group Δ when applicable)

    • Marker find/label mapping; placeholder replacement

  3. includes/class-stq-cases.php

    • CPT registration for Quotes

    • handle_save, handle_duplicate

    • maybe_render_front (front-end router)

    • render_case (with view switcher)

    • render_quote_list (employer column + new links)


How to Use (day-to-day)

Shortcodes

  • Intake

    (Only 1st or 15th of a month)
    How do you want to quote?
    Which option should I choose?

    Quote from Renewal (Composite): Use when the employer has a fully-insured, composite-rated small group plan. No census is needed—enter the employee-only renewal rate for any plan they offer (it doesn’t have to be the current plan).

    Quote from Census: Use for new groups, groups without a fully-insured plan (e.g., level-funded), or when you want age-rate detail on the side-by-side.

    Both: Use when the group is composite-rated but the enrollment census has changed since the carrier issued renewal.

    How is the group currently rated?
    This is used to calculate the renewal increase; it doesn’t limit what you compare.
    Current Plans (optional)
    Add the group’s current plan(s) to enable auto-recommendations and current→renewal views.

  • Compare Picker (usually rendered after Intake)

  • Side-by-side (render directly if you want, but normally via Picker)

 
Plan #
Plan Name
Network Name
Network Type
Plan Type
Deductible - Individual
Deductible - Family
Coinsurance - Member
Coinsurance - Plan
Out-of-Pocket - Individual
Out-of-Pocket - Family
Virtual Visits
PCP <19
Primary
Specialist
Urgent Care
Emergency
Lab/X-Ray
Imaging
Inpatient Services
Outpatient Surgery
Prescriptions
OON Deductible (Individual/Family)
OON Coinsurance (Member)
OON Out-of-Pocket (Individual/Family)

Bundle multiple SxS blocks on one page

”Multi-Plan


|
 B013 — G9L5CHCS019 — PPO Access 80 5000U012 — DY-AW
Plan #B013S019U012
Plan NameG9L5CHCPPO Access 80 5000DY-AW
Network NameBlue ChoiceAccess PPONavigate
Network TypePPOPPOHMO
Plan TypeCopayCopayCopay
Deductible - Individual$3,100$5,000$3,000
Deductible - Family$9,300$10,000$9,000
Coinsurance - Member20%20%0%
Coinsurance - Plan80%80%100%
Out-of-Pocket - Individual$8,800$9,100$5,500
Out-of-Pocket - Family$17,600$18,200$11,000
Virtual Visits$0$0$0
PCP <19$0$0$0
Primary$0$40$15
Specialist$80$80$50 or $100
Urgent Care$150$50$25
EmergencyD&CD $750$500 + D&C
Lab/X-RayD&CD&CD&C
ImagingD&CD&CD&C
Inpatient ServicesD&CD&CD&C
Outpatient SurgeryD&CD&CD&C
Prescriptions$0-10-50-100-150-250$3-50-125-250$10-40-125-300-500
OON Deductible (Individual/Family)$6,200 / $18,600$10,000 / $20,000N/A
OON Coinsurance (Member)50%50%N/A
OON Out-of-Pocket (Individual/Family)Unlimited / Unlimited$27,300 / $54,600N/A

‘]

Exports (buttons are rendered under the SxS table)

  • Excel / PDF / HTML via admin-post.php with nonce; they reuse all meta (plans, sheet, effective, counts, census_path, etc.).

  • Template: /uploads/stq-templates/Sample Output Pages.xlsx must have either [[STQ_TABLE]] or [[STQ_TABLE_ROWS]] marker on the intended sheet.


Smoke Test Checklist (after any paste-over)

  1. Intake

    • Choose Both or Census only, upload CSV → submit.

    • You should see a confirmation strip (“Census attached ✓”, counts if detected).

  2. Compare Picker

    • Pick 4–6 plans; submit → SxS renders.

  3. Side-by-Side

    • Benefit rows render with expected formatting:

      • $0 shows as $0

      • Mixed strings keep dollar sign: $150 + D&C

      • Rx line is verbatim

      • OON becomes N/A for HMO/EPO plans

    • Monthly rates EO/ES/EC/EF appear if we have renewal EO or census anchor.

    • If counts are set → Monthly Total (group) appears.

    • If counts + baseline → Group Total Δ vs Renewal appears.

  4. Save Quote

    • Click Save Quote → routed to /?stq_case_id=### showing same SxS.

    • At top: “Census attached ✓” with Download/Replace.

  5. Duplicate

    • From quote list, click Duplicate → see Open | Intake | Picker links.

    • Intake returns to the start (to change effective date, etc.).

    • Picker returns to plan selection.

  6. Export

    • Excel/PDF/HTML render the same rows/values as screen (spot-check a few).

    • Template markers resolved; placeholders (employer/effective/rate set) filled.


Caveats & Known Items

  • Caching: XLSX cache key includes many fields but not census_path or cnt_*. In edge cases, two different runs on the same day using different counts/census could hit the same cache. Backlog item: include a hash of census_path (file mtime+md5) and cnt_* in the cache key.

  • Benefit “↑/↓” symbols: if you see arrows next to benefits, those are from existing data/content; we didn’t add benefit deltas (only group total delta is implemented).

  • Template labels: the left column of the Excel template must match our canonical labels (we added an alias map; see code).


Phase Plan

Phase 1 (foundations) — Day by Day

Day 1 (prior):

  • Baseline shortcodes and exports working (original plugin behavior).

Day 2 (this chat—done):

  • Export speed/cache patch with direct-write and template markers.

  • Benefit formatting parity (preserve $0, mixed strings, Rx verbatim, OON suppression).

  • Census persistence; counts detection.

  • Fix intake→picker error path; avoid fatal on upload.

Day 3 (this chat—done):

  • Composite math from renewal EO or census anchor in both screen & export.

  • Group-only Δ vs Renewal (no tier-by-tier deltas).

  • Duplicate flow: direct links to Intake and Picker.

  • “Census attached ✓” strip on saved quotes.

  • to stack multiple SxS sections.

Day 4 (next up in Phase 1):

  • Auto-recommendation per current plan: for each selected “Current plan”, show a sub-page (or section) with (Current, Renewal, 4–6 similar alternatives), broker can override.

  • Template multi-tab support: allow multiple SxS tabs in the Excel template so we can export each current plan’s section to a dedicated sheet.

  • Cache key hardening: include cnt_* and census file hash in XLSX cache key.

  • UI polish: toolbar/link styling, census strip design, quote list actions as compact text links.

Phase 2 (enhancements)

  • Better plan similarity scoring for auto-recommendations (e.g., tier/network/benefit proximity).

  • Saved presets for “bundles” (common layouts brokers like).

  • Importers for common carrier census formats (mapping columns by heuristic).

  • Delta visuals for screen (optional) with toggles: group delta only vs show/hide arrows in a compact row.

  • Access control / roles for who can see which quotes.

Phase 3 (reporting & UX)

  • Summary report export (cover page + highlights).

  • Scenario comparisons (switching enrollment counts to model impact).

  • Audit trail / versioning of quotes (diff saved payloads).

  • Performance analytics (popular plans, average deltas, etc.).


Coding Conventions (to keep us aligned)

  • Paste-over style: Prefer entire-file or large-section replacements. After pasting, run the Smoke Test Checklist above.

  • Don’t regress: If we paste a full file, verify that:

    • Census strip still shows on saved quotes.

    • Duplicate links (Open | Intake | Picker) still appear.

    • Mixed-string benefits still keep their dollar sign.

    • Rx is verbatim.

    • Group-only delta still present where expected.

  • Shortcode safety: sanitize attributes; pass meta through hidden inputs rather than pulling from globals where possible.

  • Template markers: Ensure [[STQ_TABLE]] or [[STQ_TABLE_ROWS]] exists on the active sheet. Labels in the template’s left column should match our canonical names (we have an alias map to be forgiving).

  • Security: Keep nonces:

    • Save quote: _stq_save_case_nonce / action stq_save_case

    • Duplicate: _stq_dup_nonce / action stq_duplicate_case

    • Export: _stq_export_nonce / actions stq_export_compare_*


Quick Reference — Canonical Row Labels (left column)

Plan #
Plan Name
Network Name
Network Type
Plan Type
Tier
Metal
Deductible – Individual
Deductible – Family
Coinsurance – Member
Coinsurance – Plan
Out-of-Pocket – Individual
Out-of-Pocket – Family
Virtual Visits
PCP <19
Primary
Specialist
Urgent Care
Emergency
Lab/X-Ray
Imaging
Inpatient Services
Outpatient Surgery
Prescriptions
OON Deductible (Individual/Family)
OON Coinsurance (Member)
OON Out-of-Pocket (Individual/Family)
Monthly Rate — EO
Monthly Rate — ES
Monthly Rate — EC
Monthly Rate — EF
Monthly Total (group)
Group Total Δ vs Renewal

(The alias map in code tolerates many header variations.)


What the next chat should do first

  1. Ask me to paste the full contents of any file we’re about to alter (I’ll paste class-stq-shortcodes.php, class-stq-export-compare.php, class-stq-cases.php if needed).

  2. Apply changes via whole-file or large-section paste-over.

  3. Run the Smoke Test Checklist.

  4. Then proceed with Phase 1 Day 4 tasks (auto-recommend sections, multi-tab export, cache key hardening, UI polish).

If anything is unclear, the safest path is: request the full current file, prepare a paste-over version, and include a brief note titled “What this paste-over changes” with 3–5 bullets—so we never accidentally go backwards.

That’s everything I need captured so nothing is lost between chats.

Addendum: Phase 3 “AI Analysis & Recommendation” (External GPT) — Implementation Plan

0) Why this exists

We’ll let the quoting tool generate a clean, structured Analysis JSON and a formatted Analysis Markdown summary that a separate, custom GPT can read and turn into a polished broker narrative. The GPT lives outside WordPress; our tool just outputs the inputs it needs.

1) What we will ship (no code in this chat)

A. New outputs from the quote screen

  • Download Analysis JSON — machine-readable export.

  • Copy Analysis Markdown — human-readable summary (also great to paste into the custom GPT prompt).

B. No UI rewrites, no tab reshuffles.
We’ll simply add two buttons next to the existing exports. Zero line hunting later: next chat you’ll get two paste-over blocks only.

2) Data the outputs must contain (source of truth = current quote + DB)

Top-level fields (JSON):

{
“quote_meta”: {
“employer”: “Acme Co”,
“county”: “Travis”,
“rating_area”: 7,
“effective”: “2025-02-01”,
“rate_set”: “2025-Q1”,
“rate_style”: “composite”
},
“enrollment”: {
“counts”: {“EO”: 7, “ES”: 5, “EC”: 3, “EF”: 2, “TOTAL”: 17},
“source”: “renewal|census|both”,
“census_attached”: true
},
“current_offering”: [
{
“carrier”: “BCBSTX”,
“plan_code”: “B046”,
“plan_name”: “Blue Choice PPO 2500”,
“network_type”: “PPO”,
“plan_type”: “Copay”,
“metal”: “S”,
“rx_string”: “$20/$50/$100 + D&C”,
“composite”: {“EO”: 475.00,”ES”: 950.00,”EC”: 950.00,”EF”: 1425.00},
“monthly_total”: 15425.00
}
// If employer has multiple current plans, list each as separate objects
],
“renewal_offering”: [
{
“carrier”: “BCBSTX”,
“plan_code”: “B152”,
“plan_name”: “Blue Choice PPO 3000”,
“successor_to”: “B046”,
“renewal_delta_pct”: 1.072, // 7.2% up; same % across tiers for FI small group
“monthly_total”: 16535.00
}
],
“alternatives”: [
{
“carrier”: “UHC”,
“plan_code”: “U230”,
“plan_name”: “UHC Choice Plus 3000”,
“network_type”: “PPO”,
“match_reason”: “Similar deductible & coinsurance”,
“composite”: {“EO”: 452.20,”ES”: 904.40,”EC”: 904.40,”EF”: 1356.60},
“monthly_total”: 14890.00,
“delta_vs_renewal_pct”: -0.039
}
// 4–6 picks the tool already selects or that the broker picked
],
“benefit_deltas”: [
{
“from_plan_code”: “B046”,
“to_plan_code”: “B152”,
“changes”: [
{“label”: “Deductible – Individual”, “from”: “$2,500”, “to”: “$3,000”, “direction”: “up”},
{“label”: “Coinsurance – Member”, “from”: “20%”, “to”: “20%”, “direction”: “same”},
{“label”: “Prescriptions”, “from”: “$20/$50/$100 + D&C”, “to”: “$25/$55/$110 + D&C”, “direction”: “up”}
]
}
],
“notes”: {
“networks”: [
{“carrier”: “UHC”, “network_name”: “Choice Plus”, “size_hint”: “larger than BCBSTX in Houston”}
],
“assumptions”: [
“Fully-insured small group composite — uniform renewal delta across tiers”,
“Census child-4+ rule applied when census used”
]
}
}

Markdown summary content (same info in narrative form):

  • Employer, effective, area, rate style

  • Current vs renewal plan(s): quick bullets of benefit changes and the single group total delta (we won’t show per-tier deltas, by design)

  • Enrollment counts (EO/ES/EC/EF and Total) and source (renewal/census/both)

  • Alternatives table: plan name, carrier, monthly total, Δ vs Renewal (group total)

  • Short “broker voice” paragraph stub the GPT can expand

Rx values must be verbatim from rx_string.
Mixed text like “$150 + D&C” must retain the leading “$”.

3) Where this data comes from in our plugin

  • Plans/benefits: stq_plans + stq_plan_benefits via STQ_Calc::benefits(...).

  • Composite math: existing STQ_Calc::derive_amounts(...) and anchor_from_census_file(...).

  • Counts: renewal/census fields already flowing through

    (Only 1st or 15th of a month)
    How do you want to quote?
    Which option should I choose?

    Quote from Renewal (Composite): Use when the employer has a fully-insured, composite-rated small group plan. No census is needed—enter the employee-only renewal rate for any plan they offer (it doesn’t have to be the current plan).

    Quote from Census: Use for new groups, groups without a fully-insured plan (e.g., level-funded), or when you want age-rate detail on the side-by-side.

    Both: Use when the group is composite-rated but the enrollment census has changed since the carrier issued renewal.

    How is the group currently rated?
    This is used to calculate the renewal increase; it doesn’t limit what you compare.
    Current Plans (optional)
    Add the group’s current plan(s) to enable auto-recommendations and current→renewal views.
     
    Plan #
    Plan Name
    Network Name
    Network Type
    Plan Type
    Deductible - Individual
    Deductible - Family
    Coinsurance - Member
    Coinsurance - Plan
    Out-of-Pocket - Individual
    Out-of-Pocket - Family
    Virtual Visits
    PCP <19
    Primary
    Specialist
    Urgent Care
    Emergency
    Lab/X-Ray
    Imaging
    Inpatient Services
    Outpatient Surgery
    Prescriptions
    OON Deductible (Individual/Family)
    OON Coinsurance (Member)
    OON Out-of-Pocket (Individual/Family)
    .

  • Current/renewal pairing: same-carrier mapping (saved “renewal_plan” anchor) plus the single group total delta rule (no per-tier deltas).

4) Minimal UI changes (only)

  • In

     
    Plan #
    Plan Name
    Network Name
    Network Type
    Plan Type
    Deductible - Individual
    Deductible - Family
    Coinsurance - Member
    Coinsurance - Plan
    Out-of-Pocket - Individual
    Out-of-Pocket - Family
    Virtual Visits
    PCP <19
    Primary
    Specialist
    Urgent Care
    Emergency
    Lab/X-Ray
    Imaging
    Inpatient Services
    Outpatient Surgery
    Prescriptions
    OON Deductible (Individual/Family)
    OON Coinsurance (Member)
    OON Out-of-Pocket (Individual/Family)
    , beneath current export buttons, add:

    • Download Analysis JSON

    • Copy Analysis Markdown

  • Optionally, a small link: “Open in AI Assistant” (goes to your custom GPT URL).

5) What the next chat will deliver (paste-over only)

  1. class-stq-export-compare.php — a self-contained block that adds two new admin endpoints:

    • admin_post_stq_export_analysis_json → streams the JSON above

    • admin_post_stq_export_analysis_md → streams a Markdown file

  2. class-stq-shortcodes.php — a single paste-over section that adds the two buttons in

     
    Plan #
    Plan Name
    Network Name
    Network Type
    Plan Type
    Deductible - Individual
    Deductible - Family
    Coinsurance - Member
    Coinsurance - Plan
    Out-of-Pocket - Individual
    Out-of-Pocket - Family
    Virtual Visits
    PCP <19
    Primary
    Specialist
    Urgent Care
    Emergency
    Lab/X-Ray
    Imaging
    Inpatient Services
    Outpatient Surgery
    Prescriptions
    OON Deductible (Individual/Family)
    OON Coinsurance (Member)
    OON Out-of-Pocket (Individual/Family)
    and wires hidden fields (plans, counts, renewal, census_path, etc.) to those endpoints.

No line-by-line edits; both are drop-in replacements.

6) Acceptance criteria (done = ✅)

  • Buttons appear in the compare screen with the current export set.

  • JSON validates and contains all sections above (empty arrays allowed).

  • Markdown mirrors the JSON content in human-readable form and includes only a group total renewal delta (no per-tier deltas).

  • Rx strings and mixed money strings (e.g., “$150 + D&C”) retain the dollar sign and formatting.

  • Census presence is indicated and counts reflect source (renewal/census/both).

7) Edge cases

  • No renewal EO and no census → JSON still emits structure; composite arrays empty, deltas omitted.

  • Multiple current plans → each current plan appears; if a renewal pairing exists for each, compute per-pair deltas; otherwise skip delta for unmatched.

  • Age-rated group → allow, but still emit group totals; no per-tier deltas.

  • HMO/EPO OON rows → follow existing suppression logic (we already do this).

8) Risks & safeguards

  • Overwriting prior work — We’ll paste whole, scoped blocks only. Do not hand-edit lines.

  • Template coupling — Outputs don’t depend on Excel template markers.

  • PHI/PII — Census file path is included only as a boolean indicator; no member-level data in JSON/Markdown.

9) Next-chat sequence (no questions needed from you)

  1. You say “ready.”

  2. I send Block A (export file patch) and Block B (shortcode buttons) as full paste-overs.

  3. You paste them exactly where I indicate (I’ll quote the start/end anchors).

  4. Test: click the two new buttons on any compare page.

10) How you’ll use the outputs with your custom GPT

  • JSON: supply as attachment or raw text to the GPT with your trained instructions.

  • Markdown: paste directly; the GPT expands to a client-ready narrative.

11) What not to change when we install this

  • Don’t remove any Day-2/Day-3 logic:

    • OON suppression rules (STQ_Format::na_if_oonsuppressed_*)

    • Benefit formatting rules (preserve $0, keep “$150 + D&C” with the dollar sign)

    • Renewal delta shown only as group total

    • The census attachment banner + download/replace flow

    • Cases/duplicate flow and view switcher


Custom GPT Idea

Thank you. I will paste that to start the next chat. Before I do, I want to run an idea by you. You know how we have talked about pulling in AI to do an analysis and make recommendations, possibly in phase 3? I think I have a way to sort of do that now. Here’s the idea. What I want AI to do is to look at the current plan and the renewal offer (either same plan next year or successor plan) and note any benefit changes and, of course, renewal increase. If multiple plans are offered, note that but also describe the plans (a PPO copay plan, and HMO HSA plan, etc) and show how many employees are enrolled in each plan. Then talk about alternate plan options, the amount of money that could be saved, but also other considerations like the size of the network or higher copays on prescriptions. Then make a recommendation as the broker would do for the client – if there are pros and cons to renewing as is vs moving to a different carrier, that could be noted, etc. Here’s how I’d propose we do this. I can train a custom GPT on how to analyze the plan options and make a recommendation. I can be very detailed. The custom GPT will not be within our quoting tool. Instead, it will need certain pieces of information as input. So maybe we can build the quoting tool in such a way that the info that’s needed as input for the custom GPT is one of the output options from the quoting tool. I would think that creating this output page would be pretty easy, right? So the website could have a page for quotes but also a page for analysis and recommendation that would have a link to the custom GPT. What are your thoughts on this?

ChatGPT Response:

Love this. Yes—decoupling “analysis & recommendation” into its own export is absolutely doable and plays great with your custom GPT. We don’t need to run AI inside WordPress; we just need to produce a clean, machine-readable packet (plus an optional human-readable summary) that you can paste into the GPT.

Here’s a tight plan that fits what we’ve already built.

What we add

  1. An “Analysis Pack” export alongside the existing Excel/PDF/HTML buttons.

    • JSON: machine-readable, stable schema.

    • Markdown (optional): nicely formatted text you can paste as-is.

    • A Copy to Clipboard button and a link to your Custom GPT (you’ll provide the URL).

  2. The JSON includes everything your GPT needs to:

    • Identify current plan(s), renewal offer(s), and any alternatives shown on the SxS.

    • Compare key benefits (deductibles, OOP, coins, PCP/Specialist, ER, imaging, Rx string verbatim).

    • Show group totals and delta vs renewal (we already compute these).

    • Show enrollment by plan if we can detect it in the census; otherwise just overall EO/ES/EC/EF counts.

JSON schema (proposed)

We’ll output this for the currently rendered SxS (and, with , we can include an array of sections—one per lineup).

{
“quote_meta”: {
“quote_id”: 262,
“employer”: “Acme Co”,
“effective”: “2025-01-01”,
“rate_set”: “2025-Q1”,
“rating_area”: 1,
“county”: “Travis”,
“rate_style”: “composite”
},
“census”: {
“path”: “/wp-content/uploads/stq-data/census/census-2025-…csv”,
“counts”: { “EO”: 10, “ES”: 5, “EC”: 2, “EF”: 3, “TOTAL”: 20 },
“enrollment_by_plan”: [
{ “plan_code”: “B015”, “employees”: 12 }
// present only if the census has a recognizable “Plan” column
]
},
“lineup”: {
“current_plans”: [
{
“carrier”: “BCBSTX”,
“plan_code”: “B015”,
“name”: “Silver Copay 3000”,
“network_type”: “PPO”,
“plan_type”: “Copay”,
“metal”: “S”,
“benefits”: {
“deductible_individual”: “$3,000”,
“deductible_family”: “$9,000”,
“coins_member”: “30%”,
“coins_plan”: “70%”,
“oop_individual”: “$8,500”,
“oop_family”: “$17,000”,
“pcp_under19”: “$0”,
“primary_adult”: “$35”,
“specialist”: “$75”,
“urgent_care”: “$100”,
“emergency”: “$500 + D&C”,
“lab_xray”: “D&C”,
“imaging”: “$250 + D&C”,
“inpatient”: “$350 + D&C”,
“outpatient_surgery”: “$300 + D&C”,
“rx_string”: “T1 $10 / T2 $40 / T3 50% to $250”
},
“monthly_rates”: { “EO”: 462.9, “ES”: 925.81, “EC”: 925.81, “EF”: 1388.71 },
“group_total”: 9720.96
}
],
“renewal_offers”: [
{
“for_plan_code”: “B015”,
“offer_plan_code”: “B015”,
“offer_name”: “Silver Copay 3500”,
“rate_change_pct”: 0.013, // +1.3%
“group_total”: 9782.80,
“benefit_changes”: {
“deductible_individual”: { “from”: “$3,000”, “to”: “$3,500” },
“oop_individual”: { “from”: “$8,500”, “to”: “$9,200” },
“emergency”: { “from”: “$500 + D&C”, “to”: “$750 + D&C” }
// include only fields that changed
}
}
],
“alternatives”: [
{
“plan_code”: “S015”,
“name”: “Silver HMO 30”,
“carrier”: “BSW”,
“network_type”: “HMO”,
“plan_type”: “Copay”,
“metal”: “S”,
“monthly_rates”: { “EO”: 426.04, “ES”: 852.08, “EC”: 852.08, “EF”: 1278.11 },
“group_total”: 8946.79,
“delta_vs_renewal_pct”: -0.067
}
]
}
}

Notes

  • Rx is verbatim (exact string we show on screen).

  • We already compute group_total and delta_vs_renewal_pct (group-level only).

  • If the census has per-plan enrollment, we’ll include it; if not, the GPT can infer per-plan impact qualitatively using the totals and counts.

Prompt scaffold (auto-included in the Markdown export)

We’ll ship a top block the GPT can use immediately:

SYSTEM ROLE: You are an experienced employee benefits broker preparing a client-facing renewal memo.

TASK: Using the JSON below:
1) Summarize the current plan lineup and (if present) enrollment.
2) Summarize the carrier’s renewal offer(s) and call out notable benefit changes.
3) Compare monthly group totals and % deltas vs renewal for the alternatives.
4) Discuss qualitative tradeoffs (network type/size, Rx structure, cost-sharing shifts).
5) Provide a clear recommendation with rationale and optional next steps.

CONSTRAINTS:
– Keep Rx descriptions exactly as provided; do not reformat drug tiers.
– If enrollment by plan is missing, acknowledge it and focus on group totals and qualitative factors.
– Keep numbers consistent with the JSON; round currency to $X,XXX.XX and percents to one decimal.

SYSTEM ROLE: You are an experienced employee benefits broker preparing a client-facing renewal memo.

TASK: Using the JSON below:
1) Summarize the current plan lineup and (if present) enrollment.
2) Summarize the carrier’s renewal offer(s) and call out notable benefit changes.
3) Compare monthly group totals and % deltas vs renewal for the alternatives.
4) Discuss qualitative tradeoffs (network type/size, Rx structure, cost-sharing shifts).
5) Provide a clear recommendation with rationale and optional next steps.

CONSTRAINTS:
– Keep Rx descriptions exactly as provided; do not reformat drug tiers.
– If enrollment by plan is missing, acknowledge it and focus on group totals and qualitative factors.
– Keep numbers consistent with the JSON; round currency to $X,XXX.XX and percents to one decimal.

Then we append either:

  • the JSON (for your custom GPT that expects structured input), or

  • a compact Markdown version with tables (human-readable + copy/paste friendly).

Where this lives in the UI

  • Under the existing Download Excel / PDF / HTML / Save Quote row, add:

    • Download Analysis JSON

    • Copy Analysis Markdown

    • Open Custom GPT (link you provide)

  • On saved quotes (/?stq_case_id=###), the same buttons appear so you can generate analysis later.

What we’ll implement (next chat, via paste-over blocks)

  • In class-stq-export-compare.php:

    • New handlers: stq_export_analysis_json and stq_export_analysis_md. Each gathers the same matrix we already build, plus the amounts, counts, baseline, and emits the JSON/Markdown.

  • In class-stq-shortcodes.php

     
    Plan #
    Plan Name
    Network Name
    Network Type
    Plan Type
    Deductible - Individual
    Deductible - Family
    Coinsurance - Member
    Coinsurance - Plan
    Out-of-Pocket - Individual
    Out-of-Pocket - Family
    Virtual Visits
    PCP <19
    Primary
    Specialist
    Urgent Care
    Emergency
    Lab/X-Ray
    Imaging
    Inpatient Services
    Outpatient Surgery
    Prescriptions
    OON Deductible (Individual/Family)
    OON Coinsurance (Member)
    OON Out-of-Pocket (Individual/Family)
    :

    • Add the two new buttons under the table (same nonce & meta bundling style as the other exports).

  • Optional: a simple shortcode [stq_analysis_view id="..."] that renders the Markdown analysis directly on a page for quick copy.

Why this works well

  • No model lock-in: any GPT (yours, later ours) can consume this JSON.

  • Minimal extra work: we’re reusing the data we already compute for screen/export.

  • Deterministic: the packet contains the ground truth; your GPT only interprets it.

Assumptions I’ll bake in unless you say otherwise

  • The JSON schema above is acceptable as v1.

  • We’ll include all plans currently on the SxS as “alternatives”.

  • We’ll include benefit diffs only for “current vs renewal” where we can match on plan code or offer mapping; otherwise we’ll ship both sets and let the GPT note differences.

If that sounds good, I’ll prep paste-over blocks for:

  1. the two new admin-post handlers (JSON & Markdown),

  2. the added buttons in

     
    Plan #
    Plan Name
    Network Name
    Network Type
    Plan Type
    Deductible - Individual
    Deductible - Family
    Coinsurance - Member
    Coinsurance - Plan
    Out-of-Pocket - Individual
    Out-of-Pocket - Family
    Virtual Visits
    PCP <19
    Primary
    Specialist
    Urgent Care
    Emergency
    Lab/X-Ray
    Imaging
    Inpatient Services
    Outpatient Surgery
    Prescriptions
    OON Deductible (Individual/Family)
    OON Coinsurance (Member)
    OON Out-of-Pocket (Individual/Family)
    .

Then you can paste the full files in the next chat and we’ll run a quick smoke test.