feat: add member details PDF step to MH history and CMSP flows

After clicking the member ID link, print the member details page via CDP
before navigating to service history. Adds member details as a panel in
the side-by-side PDF viewer: MH History shows 3 panels (eligibility,
member details, service history); CMSP shows 4 panels (eligibility,
member details, service history, accumulator).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Gitead
2026-05-14 11:33:02 -04:00
parent 06526cd1bc
commit 0628f9f7fc
5 changed files with 102 additions and 14 deletions

View File

@@ -281,7 +281,6 @@ class AutomationMassHealthEligibilityHistoryCheck:
wait = WebDriverWait(self.driver, 30)
substep = "init"
try:
# Primary: ng-bind="member.memberNumber" is the stable Angular binding on the link
substep = "ng_bind_link"
member_link = wait.until(
EC.element_to_be_clickable(
@@ -296,6 +295,27 @@ class AutomationMassHealthEligibilityHistoryCheck:
print(f"[step3] FAILED at substep='{substep}': {e}")
return f"ERROR:STEP3:{substep}"
# ── step 3b — print member details page as PDF via CDP ───────────────────────
def step3b_member_details_pdf(self):
wait = WebDriverWait(self.driver, 30)
try:
wait.until(lambda d: d.execute_script("return document.readyState") == "complete")
time.sleep(2)
safe_member = "".join(c for c in str(self.memberId) if c.isalnum() or c in "-_.")
pdf_filename = f"eligibility_member_details_{safe_member}.pdf"
pdf_data = self.driver.execute_cdp_cmd("Page.printToPDF", {"printBackground": True})
pdf_bytes = base64.b64decode(pdf_data["data"])
pdf_path = os.path.join(self.download_dir, pdf_filename)
with open(pdf_path, "wb") as f:
f.write(pdf_bytes)
print("Member details PDF saved at:", pdf_path)
return pdf_path
except Exception as e:
print(f"[step3b_member_details_pdf] failed: {e}")
return None
# ── step 4 — click "View Service History" on member details page ─────────────
def step4_view_service_history(self):
@@ -382,10 +402,12 @@ class AutomationMassHealthEligibilityHistoryCheck:
"status": "partial",
"message": step3_result,
"pdf_path": eligibility_pdf_path,
"history_pdf_path": None,
"file_type": "pdf",
}
# Print member details page
member_details_pdf_path = self.step3b_member_details_pdf()
# Click "View Service History"
step4_result = self.step4_view_service_history()
if step4_result.startswith("ERROR"):
@@ -393,7 +415,7 @@ class AutomationMassHealthEligibilityHistoryCheck:
"status": "partial",
"message": step4_result,
"pdf_path": eligibility_pdf_path,
"history_pdf_path": None,
"member_details_pdf_path": member_details_pdf_path,
"file_type": "pdf",
}
@@ -403,9 +425,10 @@ class AutomationMassHealthEligibilityHistoryCheck:
result = {
"status": "success",
"pdf_path": eligibility_pdf_path,
"member_details_pdf_path": member_details_pdf_path,
"history_pdf_path": history_pdf_path,
"file_type": "pdf",
"message": "Eligibility and service history PDFs captured successfully",
"message": "Eligibility, member details, and service history PDFs captured",
}
if self.extracted_data:
result.update(self.extracted_data)