feat: Delta Dental of Washington (DDWA) eligibility check

Copies the DDMA flow: persistent Chrome profile, OTP from app or browser,
queued job, credentials under site key DDWA, and a real Delta WA button in
place of the placeholder. Login follows the WA portal: provider page, header
Sign in, then username + CONTINUE before the password page. Password, OTP,
dashboard and search selectors are still DDMA's and unverified on this portal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-03 23:29:59 -05:00
co-authored by Claude Opus 5.5
parent ebc5fba2c9
commit 9f3a3080ff
18 changed files with 2545 additions and 10 deletions
+57
View File
@@ -16,6 +16,7 @@ from selenium_Altus_eligibilityCheckWorker import AutomationAltusEligibilityChec
import os
import time
import helpers_ddma_eligibility as hddma
import helpers_ddwa_eligibility as hddwa
import helpers_deltaindiv_eligibility as hdeltaindiv
import helpers_deltains_eligibility as hdeltains
import helpers_unitedsco_eligibility as hunitedsco
@@ -37,6 +38,7 @@ import helpers_metlife_claim as hmetlife_claim
# Import startup session-clear functions
from ddma_browser_manager import clear_ddma_session_on_startup
from ddwa_browser_manager import clear_ddwa_session_on_startup
from bcbs_ma_browser_manager import clear_bcbs_ma_session
from deltaindiv_browser_manager import clear_deltaindiv_session_on_startup
from deltains_browser_manager import clear_deltains_session_on_startup
@@ -54,6 +56,7 @@ print("=" * 50)
print("SELENIUM AGENT STARTING - CLEARING SESSIONS")
print("=" * 50)
clear_ddma_session_on_startup()
clear_ddwa_session_on_startup()
# Delta Indiv keeps its cookies across restarts so the trusted-device record
# survives and the confirmation code isn't asked every time
# (still cleared via /clear-deltaindiv-session when credentials change).
@@ -467,6 +470,46 @@ async def ddma_eligibility(request: Request):
return {"status": "started", "session_id": sid}
# Endpoint: DDWA (Delta Dental of Washington) eligibility (background, OTP)
async def _ddwa_worker_wrapper(sid: str, data: dict, url: str):
"""Background worker for DDWA eligibility — acquires semaphore, updates counters."""
global active_jobs, waiting_jobs
async with semaphore:
async with lock:
waiting_jobs -= 1
active_jobs += 1
try:
await hddwa.start_ddwa_run(sid, data, url)
finally:
async with lock:
active_jobs -= 1
@app.post("/ddwa-eligibility")
async def ddwa_eligibility(request: Request):
"""
Starts a DDWA eligibility session in the background.
Body: { "data": { ... } }
Returns: { status: "started", session_id: "<uuid>" }
"""
global waiting_jobs
body = await request.json()
data = body.get("data", {})
sid = hddwa.make_session_entry()
hddwa.sessions[sid]["type"] = "ddwa_eligibility"
hddwa.sessions[sid]["last_activity"] = time.time()
async with lock:
waiting_jobs += 1
asyncio.create_task(_ddwa_worker_wrapper(sid, data, url=hddwa.DDWA_PROVIDER_URL))
return {"status": "started", "session_id": sid}
# Endpoint: MetLife Dental eligibility (background, OTP, persistent session)
async def _metlife_worker_wrapper(sid: str, data: dict, url: str):
@@ -1225,6 +1268,8 @@ async def submit_otp(request: Request):
# Try each session store in order
if sid in hddma.sessions:
res = hddma.submit_otp(sid, otp)
elif sid in hddwa.sessions:
res = hddwa.submit_otp(sid, otp)
elif sid in hdeltaindiv.sessions:
res = hdeltaindiv.submit_otp(sid, otp)
elif sid in hdeltains.sessions:
@@ -1268,6 +1313,8 @@ async def session_status(sid: str):
# Try each session store in order
if sid in hddma.sessions:
s = hddma.get_session_status(sid)
elif sid in hddwa.sessions:
s = hddwa.get_session_status(sid)
elif sid in hdeltaindiv.sessions:
s = hdeltaindiv.get_session_status(sid)
elif sid in hdeltains.sessions:
@@ -1323,6 +1370,16 @@ async def clear_ddma_session_endpoint():
return {"status": "error", "message": str(e)}
@app.post("/clear-ddwa-session")
async def clear_ddwa_session_endpoint():
"""Clears the DDWA browser session. Call when credentials are deleted or changed."""
try:
clear_ddwa_session_on_startup()
return {"status": "success", "message": "DDWA session cleared"}
except Exception as e:
return {"status": "error", "message": str(e)}
@app.post("/clear-bcbs-ma-session")
async def clear_bcbs_ma_session_endpoint():
"""Clears the BCBS MA browser session. Call when credentials are deleted or changed."""