healthcare: cite REAL NPPES last_updated date in 'outdated' email

The NPPES 'may be out of date' email previously asserted staleness with no
per-record evidence (softened earlier to a generic 'periodic review required').
NPPES is fully public and every record carries basic.last_updated, so we now
cite the actual government date the provider can verify on the registry.

- enrich_nppes_last_updated.py: joins real basic.last_updated /
  enumeration_date / deactivated onto the institutional list via a cached,
  resumable per-NPI crawl (no batch endpoint exists). Adds nppes_last_updated,
  nppes_enumeration, nppes_years_stale, nppes_deactivated.
- cron: new 'nppes_stale' selector mails ONLY records >= 3yrs stale (env
  HC_NPPES_STALE_MIN_YEARS) and excludes deactivated NPIs; empty date => no
  match, so we never claim staleness without the government date to back it.
- template: headline + official-record card now show the real last_updated
  date and ~N-years-ago, sourced to npiregistry.cms.hhs.gov.
- attribs + test SAMPLE expose the new fields; verified render + plaintext.
This commit is contained in:
justin 2026-06-20 15:21:15 -05:00
parent d8e3e40dda
commit 9e155d214c
4 changed files with 279 additions and 5 deletions

View file

@ -13,8 +13,8 @@
<!-- 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;">Outdated NPPES data can hold up your payments</h2>
<p style="font-size:14px;line-height:1.7;margin:0 0 18px;">CMS requires every provider to keep their NPPES registry record current and to periodically attest to it. Records for <strong>{{ .Subscriber.Attribs.practice }}</strong> (NPI {{ .Subscriber.Attribs.npi }}) and most practices drift out of date over time &mdash; it is worth a 60-second check.</p>
<h2 style="font-size:19px;margin:0 0 14px;color:#0f172a;line-height:1.3;">Your NPPES record hasn&rsquo;t been updated since {{ .Subscriber.Attribs.nppes_last_updated }}</h2>
<p style="font-size:14px;line-height:1.7;margin:0 0 18px;">The public NPPES NPI Registry shows the record for <strong>{{ .Subscriber.Attribs.practice }}</strong> (NPI {{ .Subscriber.Attribs.npi }}) was <strong>last updated on {{ .Subscriber.Attribs.nppes_last_updated }}</strong> &mdash; roughly <strong>{{ .Subscriber.Attribs.nppes_years_stale }} years ago</strong>. CMS requires providers to keep their NPPES record current and to attest to it periodically, and a record that old has almost certainly drifted from your real address, taxonomy, or contacts. You can confirm the date yourself below &mdash; it&rsquo;s exactly what payers and CMS see.</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;">Why it matters</h3>
@ -32,9 +32,9 @@
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="font-size:13px;">
<tr style="border-bottom:1px solid #e5e7eb;"><td style="padding:9px 0;color:#64748b;">NPI</td><td style="padding:9px 0;font-weight:700;text-align:right;color:#0f172a;">{{ .Subscriber.Attribs.npi }}</td></tr>
<tr style="border-bottom:1px solid #e5e7eb;"><td style="padding:9px 0;color:#64748b;">Registered to</td><td style="padding:9px 0;font-weight:600;text-align:right;color:#0f172a;">{{ .Subscriber.Attribs.practice }}</td></tr>
<tr><td style="padding:9px 0;color:#64748b;">Attestation</td><td style="padding:9px 0;font-weight:700;text-align:right;color:#b45309;">PERIODIC REVIEW REQUIRED</td></tr>
<tr><td style="padding:9px 0;color:#64748b;">Last updated</td><td style="padding:9px 0;font-weight:700;text-align:right;color:#b45309;">{{ .Subscriber.Attribs.nppes_last_updated }} &middot; ~{{ .Subscriber.Attribs.nppes_years_stale }} yrs ago</td></tr>
</table>
<p style="margin:10px 0 0;font-size:11px;color:#94a3b8;line-height:1.5;">Source: NPPES NPI Registry (npiregistry.cms.hhs.gov). CMS requires periodic NPPES attestation &mdash; review your current record on the official registry below.</p>
<p style="margin:10px 0 0;font-size:11px;color:#94a3b8;line-height:1.5;">Source: NPPES NPI Registry (npiregistry.cms.hhs.gov), public &ldquo;Last Updated&rdquo; field for this NPI. CMS requires providers to keep NPPES current and attest periodically &mdash; review your record on the official registry below.</p>
</td></tr>
</table>
</td></tr>