272 lines
16 KiB
Python
272 lines
16 KiB
Python
#!/usr/bin/env python3
|
|
"""Healthcare (NPI/Medicare) marketing emails, segmented by the compliance
|
|
problem that needs correcting. Mirrors the trucking brand shell
|
|
(scripts/campaign_template.html) so all PW outbound looks consistent.
|
|
|
|
Each segment maps to a real PW service + order page:
|
|
|
|
revalidation_overdue Medicare PECOS Revalidation Filing ($599) /order/npi-revalidation
|
|
npi_reactivation NPI Reactivation ($449) /order/npi-reactivation
|
|
nppes_outdated NPPES Data Update / Attestation ($349) /order/nppes-update
|
|
oig_screening OIG/SAM Exclusion Screening ($299) /order/oig-sam-screening
|
|
compliance_bundle Provider Compliance Bundle (annual) ($899) /order/provider-compliance-bundle
|
|
|
|
Two uses:
|
|
* `--render <segment>` -> writes the listmonk campaign HTML to out/.
|
|
* `--send-test <email>` -> sends every segment as a real test through the
|
|
healthcare HOT SMTP stream (host :2526 -> hcout1 -> .107), so you see exactly
|
|
what a provider receives. Personalization tokens are filled with sample data.
|
|
|
|
Listmonk personalization tokens used (kept identical to trucking so the same
|
|
subscriber-attribs convention applies on real sends):
|
|
{{ .Subscriber.Name }} provider / practice name
|
|
{{ .Subscriber.Attribs.npi }} NPI
|
|
{{ .Subscriber.Attribs.practice }} practice / org name
|
|
{{ .Subscriber.Attribs.detail }} segment-specific detail (e.g. due date)
|
|
{{ UnsubscribeURL }} listmonk per-subscriber unsubscribe
|
|
"""
|
|
from __future__ import annotations
|
|
import argparse, os, smtplib, ssl
|
|
from email.mime.multipart import MIMEMultipart
|
|
from email.mime.text import MIMEText
|
|
from email.utils import formataddr, make_msgid
|
|
|
|
SITE = "https://performancewest.net"
|
|
PHONE = "(888) 411-0383"
|
|
FROM_NAME = "Performance West Compliance"
|
|
FROM_EMAIL = "compliance@performancewest.net"
|
|
REPLY_TO = "info@performancewest.net"
|
|
OUT_DIR = os.path.join(os.path.dirname(__file__), "..", "data", "hc_campaigns")
|
|
|
|
# ── Per-segment content ────────────────────────────────────────────────────
|
|
SEGMENTS = {
|
|
"revalidation_overdue": {
|
|
"subject": "Action needed: your Medicare revalidation is overdue",
|
|
"alert": "Medicare Revalidation Alert",
|
|
"subhead": "Your CMS revalidation deadline has passed",
|
|
"headline": "Your Medicare billing privileges are at risk",
|
|
"lede": ("CMS records indicate the Medicare enrollment revalidation for "
|
|
"<strong>{{ .Subscriber.Attribs.practice }}</strong> "
|
|
"(NPI {{ .Subscriber.Attribs.npi }}) is <strong>past due</strong>."),
|
|
"issue_title": "What this means",
|
|
"issue_html": ("If you do not revalidate, CMS will <strong>deactivate your "
|
|
"Medicare billing privileges</strong> — claims stop paying "
|
|
"and you must re-enroll from scratch, losing your effective date "
|
|
"and any retroactive billing."),
|
|
"detail_label": "Revalidation due",
|
|
"cta_copy": "We file your PECOS revalidation for you, before the clock runs out.",
|
|
"cta_sub": "Most filings submitted within 1-2 business days.",
|
|
"cta_label": "Start my revalidation \u2192",
|
|
"cta_path": "/order/npi-revalidation",
|
|
"price": "$599",
|
|
},
|
|
"npi_reactivation": {
|
|
"subject": "Your NPI / Medicare enrollment appears deactivated",
|
|
"alert": "Provider Enrollment Alert",
|
|
"subhead": "Deactivated enrollment detected",
|
|
"headline": "Your enrollment looks deactivated \u2014 let's fix it fast",
|
|
"lede": ("Our compliance monitoring flagged the enrollment for "
|
|
"<strong>{{ .Subscriber.Attribs.practice }}</strong> "
|
|
"(NPI {{ .Subscriber.Attribs.npi }}) as <strong>deactivated or inactive</strong>."),
|
|
"issue_title": "Why it matters",
|
|
"issue_html": ("A deactivated enrollment means Medicare claims are being "
|
|
"<strong>rejected</strong>. Reactivation restores your billing "
|
|
"privileges — the sooner it's filed, the less revenue you lose."),
|
|
"detail_label": "Status",
|
|
"cta_copy": "We handle the CMS-855 reactivation end to end.",
|
|
"cta_sub": "We verify every field against current CMS requirements.",
|
|
"cta_label": "Reactivate my enrollment \u2192",
|
|
"cta_path": "/order/npi-reactivation",
|
|
"price": "$449",
|
|
},
|
|
"nppes_outdated": {
|
|
"subject": "Your NPPES record may be out of date",
|
|
"alert": "NPPES Data Alert",
|
|
"subhead": "Outdated registry information detected",
|
|
"headline": "Outdated NPPES data can hold up your payments",
|
|
"lede": ("The public NPPES registry record for "
|
|
"<strong>{{ .Subscriber.Attribs.practice }}</strong> "
|
|
"(NPI {{ .Subscriber.Attribs.npi }}) appears <strong>out of date</strong>."),
|
|
"issue_title": "Why it matters",
|
|
"issue_html": ("Payers, clearinghouses, and CMS pull from NPPES. A stale "
|
|
"address, taxonomy, or contact can cause <strong>claim denials, "
|
|
"mail you never receive, and failed credentialing</strong>. CMS "
|
|
"also requires you to attest your NPPES data periodically."),
|
|
"detail_label": "Record",
|
|
"cta_copy": "We update and attest your NPPES record for you.",
|
|
"cta_sub": "Address, taxonomy, contacts, and authorized official.",
|
|
"cta_label": "Update my NPPES record \u2192",
|
|
"cta_path": "/order/nppes-update",
|
|
"price": "$349",
|
|
},
|
|
"oig_screening": {
|
|
"subject": "Are you screening for OIG / SAM exclusions?",
|
|
"alert": "Exclusion Screening Notice",
|
|
"subhead": "Annual OIG/SAM screening requirement",
|
|
"headline": "One excluded individual can cost you everything",
|
|
"lede": ("Federal rules require practices that bill Medicare/Medicaid to "
|
|
"screen employees and vendors against the <strong>OIG LEIE</strong> and "
|
|
"<strong>SAM</strong> exclusion lists \u2014 and to document it."),
|
|
"issue_title": "Why it matters",
|
|
"issue_html": ("Employing or contracting an excluded party triggers <strong>civil "
|
|
"monetary penalties up to $20,000 per claim</strong> plus repayment. "
|
|
"Most practices have <strong>no documented screening process</strong>."),
|
|
"detail_label": "Practice",
|
|
"cta_copy": "We run and document your OIG/SAM exclusion screening.",
|
|
"cta_sub": "Monthly checks with an audit-ready record.",
|
|
"cta_label": "Set up exclusion screening \u2192",
|
|
"cta_path": "/order/oig-sam-screening",
|
|
"price": "$299",
|
|
},
|
|
"compliance_bundle": {
|
|
"subject": "Get your provider compliance handled for the year",
|
|
"alert": "Provider Compliance Review",
|
|
"subhead": "Annual compliance, done for you",
|
|
"headline": "Stop chasing deadlines \u2014 we'll handle the whole year",
|
|
"lede": ("Between revalidation, NPPES attestation, and exclusion screening, "
|
|
"provider compliance is a moving target for "
|
|
"<strong>{{ .Subscriber.Attribs.practice }}</strong> "
|
|
"(NPI {{ .Subscriber.Attribs.npi }})."),
|
|
"issue_title": "What's included",
|
|
"issue_html": ("Revalidation monitoring & filing, NPPES updates/attestation, "
|
|
"and monthly OIG/SAM exclusion screening — one flat annual "
|
|
"price, all tracked, all documented."),
|
|
"detail_label": "Practice",
|
|
"cta_copy": "One annual bundle covers your core CMS obligations.",
|
|
"cta_sub": "We watch the deadlines so you never miss one.",
|
|
"cta_label": "Get the compliance bundle \u2192",
|
|
"cta_path": "/order/provider-compliance-bundle",
|
|
"price": "$899/yr",
|
|
},
|
|
}
|
|
|
|
# Sample values for test sends (real sends use Listmonk subscriber attribs).
|
|
SAMPLE = {
|
|
"name": "Dr. Sample Provider",
|
|
"practice": "Riverbend Family Medicine",
|
|
"npi": "1234567890",
|
|
"detail": "06/30/2024 (706 days overdue)",
|
|
}
|
|
|
|
|
|
def render(seg_key: str, *, test: bool = False) -> tuple[str, str]:
|
|
s = SEGMENTS[seg_key]
|
|
cta_url = f"{SITE}{s['cta_path']}?npi={{{{ .Subscriber.Attribs.npi }}}}"
|
|
html = f"""<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><style>@media only screen and (max-width:600px){{.pw-wrap{{width:100%!important;border-radius:0!important;}}.pw-pad{{padding:24px 16px!important;}}}}body,table,td,p,a{{-webkit-text-size-adjust:100%;}}table{{border-collapse:collapse!important;}}img{{border:0;}}</style></head><body style="margin:0;padding:0;background:#eef0f3;">
|
|
<center>
|
|
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="background:#eef0f3;"><tr><td style="padding:24px 10px;">
|
|
<table role="presentation" class="pw-wrap" width="620" cellpadding="0" cellspacing="0" style="margin:0 auto;border-radius:10px;overflow:hidden;background:#fff;">
|
|
|
|
<!-- Header -->
|
|
<tr><td style="background-color:#0f766e;background:linear-gradient(135deg,#0f766e 0%,#14b8a6 100%);padding:26px 28px;">
|
|
<img src="{SITE}/images/logo.png" alt="Performance West" style="height:44px;margin-bottom:10px;display:block" />
|
|
<h1 style="color:#fff;margin:0;font-size:22px;font-weight:700;font-family:Inter,system-ui,sans-serif;">{s['alert']}</h1>
|
|
<p style="color:#ccfbf1;margin:6px 0 0;font-size:13px;font-family:Inter,system-ui,sans-serif;">{s['subhead']}</p>
|
|
</td></tr>
|
|
|
|
<!-- Body -->
|
|
<tr><td class="pw-pad" style="padding:28px;font-family:Inter,system-ui,sans-serif;color:#1f2937;">
|
|
<p style="font-size:15px;margin:0 0 18px;line-height:1.5;">Hi {{{{ .Subscriber.Name }}}},</p>
|
|
<h2 style="font-size:19px;margin:0 0 14px;color:#0f172a;line-height:1.3;">{s['headline']}</h2>
|
|
<p style="font-size:14px;line-height:1.7;margin:0 0 18px;">{s['lede']}</p>
|
|
|
|
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="margin:22px 0;"><tr><td style="background:#ecfdf5;border:2px solid #6ee7b7;border-radius:10px;padding:18px;">
|
|
<h3 style="margin:0 0 10px;font-size:15px;color:#065f46;font-weight:700;">{s['issue_title']}</h3>
|
|
<div style="font-size:13px;color:#065f46;line-height:1.7;">{s['issue_html']}</div>
|
|
</td></tr></table>
|
|
|
|
<!-- Detail row -->
|
|
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="margin:18px 0;font-size:13px;">
|
|
<tr style="border-bottom:1px solid #e5e7eb;"><td style="padding:10px 0;color:#6b7280;">NPI</td><td style="padding:10px 0;font-weight:600;text-align:right;">{{{{ .Subscriber.Attribs.npi }}}}</td></tr>
|
|
<tr style="border-bottom:1px solid #e5e7eb;"><td style="padding:10px 0;color:#6b7280;">{s['detail_label']}</td><td style="padding:10px 0;font-weight:600;text-align:right;">{{{{ .Subscriber.Attribs.detail }}}}</td></tr>
|
|
<tr><td style="padding:10px 0;color:#6b7280;">Our service fee</td><td style="padding:10px 0;font-weight:700;text-align:right;color:#047857;">{s['price']}</td></tr>
|
|
</table>
|
|
|
|
<!-- CTA -->
|
|
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="margin:22px 0;"><tr><td style="background:#ecfdf5;border:2px solid #10b981;border-radius:10px;padding:18px;text-align:center;">
|
|
<p style="font-size:14px;color:#065f46;margin:0 0 6px;font-weight:600;">{s['cta_copy']}</p>
|
|
<p style="font-size:12px;color:#047857;margin:0 0 14px;">{s['cta_sub']}</p>
|
|
<a href="{cta_url}" style="display:inline-block;padding:14px 40px;background:#10b981;color:#fff;font-weight:700;border-radius:8px;text-decoration:none;font-size:15px;">{s['cta_label']}</a>
|
|
</td></tr></table>
|
|
|
|
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="margin:18px 0;"><tr><td style="background:#f0f4f8;border-radius:8px;padding:16px;font-size:13px;color:#374151;line-height:1.6;">
|
|
<strong>Questions?</strong> Reply to this email or call <strong>{PHONE}</strong>. Performance West is a dedicated healthcare compliance firm — we handle the CMS/NPPES paperwork so you can focus on patients.
|
|
</td></tr></table>
|
|
</td></tr>
|
|
|
|
<!-- Footer -->
|
|
<tr><td style="padding:16px 28px;background:#f8fafc;border-top:1px solid #e5e7eb;font-size:11px;color:#9ca3af;text-align:center;">
|
|
<p style="margin:0;">Performance West Inc. · Cheyenne, WY · <a href="{SITE}" style="color:#6b7280;">performancewest.net</a></p>
|
|
<p style="margin:6px 0 0;">You received this because your provider record is publicly listed in the CMS NPPES registry.</p>
|
|
<p style="margin:6px 0 0;"><a href="{{{{ UnsubscribeURL }}}}" style="color:#6b7280;">Unsubscribe</a></p>
|
|
</td></tr>
|
|
|
|
</table></td></tr></table></center></body></html>"""
|
|
|
|
if test:
|
|
# Fill listmonk tokens with sample data for a standalone test send.
|
|
html = (html
|
|
.replace("{{ .Subscriber.Name }}", SAMPLE["name"])
|
|
.replace("{{ .Subscriber.Attribs.npi }}", SAMPLE["npi"])
|
|
.replace("{{ .Subscriber.Attribs.practice }}", SAMPLE["practice"])
|
|
.replace("{{ .Subscriber.Attribs.detail }}", SAMPLE["detail"])
|
|
.replace("{{ UnsubscribeURL }}", f"{SITE}/unsubscribe?test=1"))
|
|
return s["subject"], html
|
|
|
|
|
|
def cmd_render():
|
|
os.makedirs(OUT_DIR, exist_ok=True)
|
|
for key in SEGMENTS:
|
|
subj, html = render(key)
|
|
path = os.path.join(OUT_DIR, f"hc_{key}.html")
|
|
open(path, "w").write(html)
|
|
print(f" wrote {path} (subject: {subj})")
|
|
|
|
|
|
def cmd_send_test(to_addr: str, host: str, port: int):
|
|
from email.utils import formatdate
|
|
n = 0
|
|
for key in SEGMENTS:
|
|
subj, html = render(key, test=True)
|
|
msg = MIMEMultipart("alternative")
|
|
msg["Subject"] = f"[TEST] {subj}"
|
|
msg["From"] = formataddr((FROM_NAME, FROM_EMAIL))
|
|
msg["To"] = to_addr
|
|
msg["Reply-To"] = REPLY_TO
|
|
msg["Date"] = formatdate(localtime=True)
|
|
msg["Message-ID"] = make_msgid(domain="performancewest.net")
|
|
# Bulk-mail deliverability headers (Gmail/GMX strongly reward these).
|
|
msg["List-Unsubscribe"] = (
|
|
f"<mailto:unsubscribe@performancewest.net?subject=unsubscribe>, "
|
|
f"<{SITE}/unsubscribe?e={to_addr}>")
|
|
msg["List-Unsubscribe-Post"] = "List-Unsubscribe=One-Click"
|
|
msg["List-Id"] = "Performance West Healthcare Compliance <hc.performancewest.net>"
|
|
msg["Precedence"] = "bulk"
|
|
msg["X-Entity-Ref-ID"] = make_msgid(domain="performancewest.net")
|
|
msg.attach(MIMEText("Please view this email in HTML.", "plain"))
|
|
msg.attach(MIMEText(html, "html"))
|
|
with smtplib.SMTP(host, port, timeout=15) as s:
|
|
s.ehlo("hcmta01.performancewest.net")
|
|
s.sendmail(FROM_EMAIL, [to_addr], msg.as_string())
|
|
print(f" sent [{key}] -> {to_addr} ({subj})")
|
|
n += 1
|
|
print(f"done: {n} test emails sent via {host}:{port}")
|
|
|
|
|
|
def main():
|
|
ap = argparse.ArgumentParser()
|
|
ap.add_argument("--render", action="store_true", help="write listmonk HTML to data/hc_campaigns/")
|
|
ap.add_argument("--send-test", metavar="EMAIL", help="send all segments as test to EMAIL")
|
|
ap.add_argument("--smtp-host", default="127.0.0.1")
|
|
ap.add_argument("--smtp-port", type=int, default=2526, help="hc HOT submission port")
|
|
args = ap.parse_args()
|
|
if args.render:
|
|
cmd_render()
|
|
if args.send_test:
|
|
cmd_send_test(args.send_test, args.smtp_host, args.smtp_port)
|
|
if not args.render and not args.send_test:
|
|
ap.print_help()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|