feat: BCBS MA persistent session, Expand All fix, address/gender extraction
- Persistent Chrome profile (bcbs_ma_browser_manager) reused across patients; login probes /myportal/ to skip login + OTP while the session is active - Expand All: JS-click the expandCollapseViews span, verify sections opened, and unclip fixed-height result tables so the PDF includes every row - Extract patient address and gender from the results page and save to patient - Uppercase member IDs (XXA...), matching older lowercase records - Add /clear-bcbs-ma-session endpoint Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,7 @@ from typing import Dict, Any
|
||||
from selenium.common.exceptions import WebDriverException
|
||||
|
||||
from selenium_BCBS_MA_eligibilityCheckWorker import AutomationBCBSMAEligibilityCheck
|
||||
from bcbs_ma_browser_manager import get_browser_manager
|
||||
|
||||
# In-memory session store
|
||||
sessions: Dict[str, Dict[str, Any]] = {}
|
||||
@@ -39,10 +40,10 @@ async def _remove_session_later(sid: str, delay: int = 30):
|
||||
async def start_bcbs_ma_run(sid: str, data: dict, url: str):
|
||||
"""
|
||||
Full BCBS MA eligibility workflow for one session.
|
||||
Always fresh Chrome — no persistent session because BCBS MA always
|
||||
requires OTP (the prefix changes each login).
|
||||
Uses the persistent BCBS MA browser — if the portal login is still
|
||||
active, login() returns SUCCESS and the OTP step is skipped.
|
||||
|
||||
OTP handling:
|
||||
OTP handling (only when the saved login has expired):
|
||||
a) Accept OTP submitted from the app via /submit-otp (sets otp_value)
|
||||
b) Poll the browser directly to detect user entry in the open window
|
||||
"""
|
||||
@@ -130,9 +131,13 @@ async def start_bcbs_ma_run(sid: str, data: dict, url: str):
|
||||
|
||||
# ── Already logged in (no OTP path) ──────────────────────────────────
|
||||
elif isinstance(login_result, str) and login_result == "SUCCESS":
|
||||
print("[BCBS MA] Login succeeded without OTP")
|
||||
print("[BCBS MA] Logged in without OTP")
|
||||
s["status"] = "running"
|
||||
|
||||
# Remember which account this browser profile is logged in as
|
||||
if bot.username:
|
||||
get_browser_manager().save_credentials_hash(bot.username)
|
||||
|
||||
# ── Step 1: search member ──────────────────────────────────────────────
|
||||
step1_result = bot.step1()
|
||||
if isinstance(step1_result, str) and step1_result.startswith("ERROR"):
|
||||
@@ -160,12 +165,8 @@ async def start_bcbs_ma_run(sid: str, data: dict, url: str):
|
||||
return {"status": "error", "message": s["message"]}
|
||||
|
||||
finally:
|
||||
# Always close the disposable browser
|
||||
try:
|
||||
if bot:
|
||||
bot.close_driver()
|
||||
except Exception:
|
||||
pass
|
||||
# Never quit Chrome here — the persistent browser keeps the BCBS MA
|
||||
# login for the next patient and stays open on the results page
|
||||
s["driver"] = None
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user