Reframe healthcare filing as standard vs expedited; e2e test + bug fixes

Copy: drop paper/electronic/fax framing across the revalidation + enrollment
marketing pages and the order-confirmation email; present two service tiers:
- Standard filing  (no CMS account; we prepare CMS-855, you sign, we submit to MAC)
- Expedited filing (CMS I&A surrogate access; same-day PECOS filing + tracking)
Internal worker todos + the _STANDARD_FILING_SLUGS identifier updated to match.

New scripts/test_healthcare_e2e.py validates the whole order line (slug
consistency x6 places, price agreement, intake field collection+enforcement,
worker dispatch, handler execution producing CMS-855 PDF+anchor, free-tool
action_urls). 45 checks.

Bugs found + fixed by the test:
- medicare-enrollment requires practice_state server-side but the wizard never
  enforced it -> orders could be paid then stall. Wizard now requires it.
- determine_form_type defaulted org NPIs to the individual 855I because
  enumeration_type is never collected -> wrong form, CMS rejection. Now does a
  live NPPES lookup (safe 855I fallback).
This commit is contained in:
justin 2026-06-05 03:58:46 -05:00
parent 5cfe9702e2
commit 695ace207c
7 changed files with 381 additions and 54 deletions

View file

@ -41,7 +41,7 @@ _SLUG_META = {
"enrollment record, and submit. Capture the PECOS tracking ID."
),
"access": (
"PECOS via CMS I&A surrogacy (preferred). Fallback: paper CMS-855I/B/R, provider wet-signs cert page, mail to provider's MAC."
"Standard: prepare CMS-855I/B/R, provider signs cert, submit to MAC. Expedited: file in PECOS via CMS I&A surrogate access."
),
"priority": "high",
},
@ -53,7 +53,7 @@ _SLUG_META = {
"reason, correct any stale data, and re-certify the record."
),
"access": (
"NPPES via CMS I&A surrogacy. No paper option (NPPES is web-only)."
"NPPES via CMS I&A surrogate access (online-only)."
),
"priority": "high",
},
@ -66,7 +66,7 @@ _SLUG_META = {
"changes and certify."
),
"access": (
"NPPES via CMS I&A surrogacy. No paper option (NPPES is web-only)."
"NPPES via CMS I&A surrogate access (online-only)."
),
"priority": "normal",
},
@ -78,7 +78,7 @@ _SLUG_META = {
"Confirm taxonomy, practice location, and authorized official."
),
"access": (
"PECOS via CMS I&A surrogacy (preferred). Fallback: paper CMS-855, provider wet-signs, mail to MAC."
"Standard: prepare CMS-855, provider signs cert, submit to MAC. Expedited: file in PECOS via CMS I&A surrogate access."
),
"priority": "high",
},
@ -104,17 +104,17 @@ _SLUG_META = {
"record. Set the next revalidation reminder."
),
"access": (
"PECOS/NPPES via CMS I&A surrogacy; screening is public. Paper CMS-855 fallback for the enrollment/revalidation piece."
"Standard CMS-855 filing for the enrollment/revalidation piece; NPPES + PECOS via CMS I&A surrogate access; screening is public."
),
"priority": "high",
},
}
# Slugs whose fulfilment includes a paper CMS-855 (auto-filled official form,
# e-signed, then printed + USPS Priority-mailed to the provider's MAC). The
# Slugs whose fulfilment includes a CMS-855 (auto-filled official form, signed
# via the secure e-sign link, then submitted to the provider's MAC). The
# bundle's revalidation piece is handled by the dedicated revalidation order it
# spawns, so it is not listed here.
_PAPER_855_SLUGS = {
_STANDARD_FILING_SLUGS = {
"npi-revalidation",
"npi-reactivation",
"medicare-enrollment",
@ -151,16 +151,16 @@ class _BaseNPIHandler:
)
# For PECOS enrollment/revalidation we generate the official CMS-855,
# send it for e-signature, then a human prints + USPS-mails it to the MAC.
paper_note = ""
if self.SERVICE_SLUG in _PAPER_855_SLUGS:
# send it for e-signature, then a human submits it to the MAC.
filing_note = ""
if self.SERVICE_SLUG in _STANDARD_FILING_SLUGS:
try:
paper_note = self._generate_855_for_signing(
filing_note = self._generate_855_for_signing(
order_number, intake, provider, customer_email
)
except Exception as exc: # never block the admin todo on PDF issues
LOG.error("[%s] CMS-855 generation failed: %s", order_number, exc)
paper_note = f"CMS-855 auto-generation FAILED ({exc}); prepare the form manually."
filing_note = f"CMS-855 auto-generation FAILED ({exc}); prepare the form manually."
description = (
f"{meta['action']}\n\n"
@ -171,9 +171,9 @@ class _BaseNPIHandler:
f"Practice state: {practice_state or 'not provided'}\n"
f"Portal: {meta['portal']}\n"
f"Access model: {meta['access']}\n"
+ (f"\n{paper_note}\n" if paper_note else "")
+ (f"\n{filing_note}\n" if filing_note else "")
+ "\nReview-staged: complete/verify the form, get it signed, then "
"print and USPS Priority Mail it to the provider's MAC (or file in "
"submit it to the provider's MAC (standard), or file in "
"PECOS if surrogate access was granted). Mark this order complete."
)
@ -191,7 +191,7 @@ class _BaseNPIHandler:
Returns a human-readable note for the admin todo describing what was
generated and what still needs manual completion. The signed PDF is
printed and USPS Priority-mailed to the MAC by the fulfilment team.
submitted to the MAC by the fulfilment team.
"""
try:
from scripts.document_gen.templates.cms855_pdf_filler import (
@ -231,13 +231,13 @@ class _BaseNPIHandler:
)
note_lines = [
f"PAPER CMS-{form_type.upper()} generated (official form, auto-filled where possible).",
f"CMS-{form_type.upper()} generated (official form, auto-filled where possible).",
f"Unsigned PDF: {document_key}",
]
if signed and customer_email:
note_lines.append(f"E-sign link emailed to {customer_email}. After signing, print + USPS Priority Mail to the MAC.")
note_lines.append(f"E-sign link emailed to {customer_email}. After signing, submit to the MAC (standard) or file via PECOS surrogate access (expedited).")
else:
note_lines.append("No customer email or esign infra — send the form for wet signature manually.")
note_lines.append("No customer email or esign infra — send the form for signature manually.")
if missing:
note_lines.append("MANUAL COMPLETION NEEDED:")
note_lines.extend(f" - {m}" for m in missing)