fix: handle DDMA site redesign in eligibility check flow

DDMA now often skips the family-members results table and navigates
straight to the single-patient detail page, and labels the patient's
name "Subscriber name:" instead of "Name:". Update step1/step2 to
detect the detail-page URL correctly (it's nested under the search
path, so a plain substring check couldn't tell them apart), extract
the name from the new label, and fall back to parsing "Coverage is:"
for eligibility status when there's no results row to read it from.
Also fix a status-text substring bug ("active" matching inside
"inactive") and stop the backend from collapsing an unknown
eligibility result into INACTIVE. Skip name extraction entirely when
the caller already knows the patient (existing-patient recheck).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-01 21:20:38 -04:00
co-authored by Claude Sonnet 5
parent b860fd213f
commit f8235787db
2 changed files with 75 additions and 27 deletions
@@ -138,8 +138,9 @@ async function processDdmaResult(
// 4) Determine and update eligibility status + insurance provider name
const eligStatus = (seleniumResult?.eligibility ?? "").toLowerCase();
const newStatus =
eligStatus === "active" || eligStatus === "y" ? "ACTIVE" : "INACTIVE";
let newStatus = "UNKNOWN";
if (eligStatus === "active" || eligStatus === "y") newStatus = "ACTIVE";
else if (eligStatus === "inactive" || eligStatus === "n" || eligStatus === "termed") newStatus = "INACTIVE";
await storage.updatePatient(patient.id, {
status: newStatus,
insuranceProvider: "Delta Dental MA",