#!/usr/bin/env python3 """Healthcare (NPI/Medicare) marketing-email SEGMENT REGISTRY + test tooling. SINGLE SOURCE OF TRUTH for the healthcare campaign segments. Each segment maps a compliance problem to a real PW service, its order page, price, the listmonk list/campaign it warms, and the canonical HTML template under data/hc_campaigns/. The HTML bodies themselves are the hand-tuned, deployed templates in data/hc_campaigns/hc_.html (teal header, per-segment "verify it yourself" trust block, official-record card on revalidation, etc.). This module does NOT regenerate them -- it READS them, so the files stay the one source of truth and can't drift from a parallel generator. (An earlier version of this script kept a divergent inline generator; that was removed.) Consumers: * build_healthcare_campaigns_cron.py imports SEGMENTS to warm every segment. * `--send-test ` 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 on real sends (filled from subscriber attribs by listmonk; filled from SAMPLE here for test 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) {{ .Subscriber.Attribs.reval_due_date }} / .days_overdue (revalidation card) {{ 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 registry ─────────────────────────────────────────────────── # Metadata only. The email body lives in OUT_DIR/