Track clinician licenses, DEA registrations, board certifications and malpractice coverage: NPI checks against the NPPES registry, evidence stored for every verification, monthly OIG exclusion screening, expiry alerts and a clearance rule scheduling can trust, in Go with Encore.

Provider credentialing is the process behind "can this clinician see patients here today": a verified NPI, an active license in the right state, current malpractice coverage and no federal exclusion.
Many organizations still track it in spreadsheets, which works until a license lapses unnoticed. This guide builds the backend in Go, with credentials and expiry, NPI checks, exclusion screening and a clearance rule.
The core idea is primary source verification: a credential counts once it has been checked against the issuing source, not only uploaded. For the NPI, that source is the NPPES NPI Registry API, a free public API that returns the provider's name, status, taxonomies and the license numbers they reported. For licenses it is the state board, for DEA registrations the DEA, and for board certifications the certifying board, most of which offer lookups or paid verification services.
For exclusion screening, the HHS Office of Inspector General publishes the List of Excluded Individuals and Entities as a downloadable file with monthly supplements, and its guidance for state Medicaid agencies says the list must be checked monthly and on new enrollments. Many organizations also screen state Medicaid exclusion lists and the SAM.gov exclusions list.
Every verification should be a row you never update, with the evidence stored next to it, so an audit can see what was checked, when and against what. And clearance is computed from those rows, not stored as a flag someone forgets to flip back.
Encore is a backend framework with built-in infrastructure, so the credentialing database, the private evidence bucket, the expiry alert topic and the daily job are declared in the service, and Encore provisions them in your own AWS or GCP account on deploy.

Run in your terminal to get started locally.
The schema separates what a credential claims from the checks made on it:
-- credentialing/migrations/1_init.up.sql
CREATE TABLE providers (
id BIGSERIAL PRIMARY KEY,
npi TEXT NOT NULL UNIQUE,
first_name TEXT NOT NULL,
last_name TEXT NOT NULL,
dob DATE NOT NULL
);
CREATE TABLE credentials (
id BIGSERIAL PRIMARY KEY,
provider_id BIGINT NOT NULL REFERENCES providers (id),
kind TEXT NOT NULL CHECK (kind IN ('state_license', 'dea', 'board_certification', 'malpractice')),
number TEXT NOT NULL,
issuer TEXT NOT NULL, -- e.g. state board, carrier
expires_on DATE NOT NULL,
document_key TEXT,
verified_at TIMESTAMPTZ
);
-- Append-only: one row per check, never updated.
CREATE TABLE verifications (
id BIGSERIAL PRIMARY KEY,
provider_id BIGINT NOT NULL REFERENCES providers (id),
source TEXT NOT NULL, -- 'nppes', 'oig_leie', 'state_board'
outcome TEXT NOT NULL CHECK (outcome IN ('pass', 'fail', 'match')),
detail TEXT NOT NULL,
evidence_key TEXT,
checked_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE INDEX verifications_provider_idx ON verifications (provider_id, source, checked_at DESC);
CREATE TABLE exclusions (
npi TEXT,
last_name TEXT NOT NULL,
first_name TEXT NOT NULL,
dob DATE,
excl_type TEXT NOT NULL,
excl_date DATE NOT NULL
);
CREATE INDEX exclusions_npi_idx ON exclusions (npi);
CREATE INDEX exclusions_name_idx ON exclusions (last_name, first_name);
The NPI check calls the registry, stores the raw response in a private bucket and writes a verification row that points at it:
// credentialing/npi.go
package credentialing
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
"strings"
"time"
"encore.dev/storage/objects"
"encore.dev/storage/sqldb"
)
var db = sqldb.NewDatabase("credentialing", sqldb.DatabaseConfig{
Migrations: "./migrations",
})
// Private bucket for uploaded documents and verification evidence.
var evidence = objects.NewBucket("credentialing-evidence", objects.BucketConfig{
Versioned: true,
})
type nppesResponse struct {
ResultCount int `json:"result_count"`
Results []struct {
Number string `json:"number"`
Basic struct {
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
Status string `json:"status"`
} `json:"basic"`
} `json:"results"`
}
type VerifyResult struct {
Outcome string `json:"outcome"`
Detail string `json:"detail"`
}
// VerifyNPI checks a provider's NPI against the NPPES registry.
//
//encore:api private method=POST path=/providers/:id/verify-npi
func VerifyNPI(ctx context.Context, id int64) (*VerifyResult, error) {
var npi, lastName string
if err := db.QueryRow(ctx, `SELECT npi, last_name FROM providers WHERE id = $1`, id).Scan(&npi, &lastName); err != nil {
return nil, err
}
q := url.Values{"version": {"2.1"}, "number": {npi}}
req, _ := http.NewRequestWithContext(ctx, http.MethodGet, "https://npiregistry.cms.hhs.gov/api/?"+q.Encode(), nil)
resp, err := http.DefaultClient.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
raw, err := io.ReadAll(io.LimitReader(resp.Body, 1<<20))
if err != nil {
return nil, err
}
key := fmt.Sprintf("evidence/nppes/%d/%s.json", id, time.Now().UTC().Format("20060102T150405Z"))
w := evidence.Upload(ctx, key, objects.WithUploadAttrs(objects.UploadAttrs{ContentType: "application/json"}))
if _, err := w.Write(raw); err != nil {
w.Abort(err)
return nil, err
}
if err := w.Close(); err != nil {
return nil, err
}
var r nppesResponse
if err := json.Unmarshal(raw, &r); err != nil {
return nil, err
}
res := &VerifyResult{Outcome: "pass", Detail: "active NPI, name matches"}
switch {
case r.ResultCount != 1:
res = &VerifyResult{Outcome: "fail", Detail: "NPI not found"}
case r.Results[0].Basic.Status != "A":
res = &VerifyResult{Outcome: "fail", Detail: "NPI not active"}
case !strings.EqualFold(r.Results[0].Basic.LastName, lastName):
res = &VerifyResult{Outcome: "fail", Detail: "name mismatch: registry has " + r.Results[0].Basic.LastName}
}
_, err = db.Exec(ctx, `
INSERT INTO verifications (provider_id, source, outcome, detail, evidence_key)
VALUES ($1, 'nppes', $2, $3, $4)`, id, res.Outcome, res.Detail, key)
return res, err
}
The bucket is versioned, so overwriting an evidence file by mistake keeps the earlier version. Uploaded license PDFs and insurance certificates go into the same bucket through evidence.SignedUploadURL, keyed by credential, and staff who verify a license on the state board's site record a state_board verification with a screenshot as evidence.
Each month, staff upload the current LEIE UPDATED.csv to the bucket and call the import. It replaces the table in one transaction, then records a verification for every provider, with match for anyone found by NPI or by name and date of birth:
// credentialing/screening.go
package credentialing
import (
"context"
"encoding/csv"
"io"
"time"
)
type ImportParams struct {
ObjectKey string `json:"object_key"` // e.g. "leie/2026-11/UPDATED.csv"
}
type ScreenResult struct {
Screened int `json:"screened"`
Matches int `json:"matches"`
}
func leieDate(s string) *time.Time {
t, err := time.Parse("20060102", s)
if err != nil {
return nil
}
return &t
}
//encore:api private method=POST path=/screening/import-leie
func ImportLEIE(ctx context.Context, p *ImportParams) (*ScreenResult, error) {
r := evidence.Download(ctx, p.ObjectKey)
defer r.Close()
cr := csv.NewReader(r)
if _, err := cr.Read(); err != nil { // header row
return nil, err
}
tx, err := db.Begin(ctx)
if err != nil {
return nil, err
}
defer tx.Rollback()
if _, err := tx.Exec(ctx, `DELETE FROM exclusions`); err != nil {
return nil, err
}
for {
rec, err := cr.Read()
if err == io.EOF {
break
}
if err != nil {
return nil, err
}
// Columns: LASTNAME,FIRSTNAME,MIDNAME,BUSNAME,GENERAL,SPECIALTY,UPIN,NPI,DOB,...,EXCLTYPE,EXCLDATE
if rec[0] == "" {
continue // entity, not an individual
}
npi := rec[7]
if npi == "0" {
npi = ""
}
if _, err := tx.Exec(ctx, `
INSERT INTO exclusions (npi, last_name, first_name, dob, excl_type, excl_date)
VALUES (NULLIF($1, ''), upper($2), upper($3), $4, $5, $6)`,
npi, rec[0], rec[1], leieDate(rec[8]), rec[13], leieDate(rec[14])); err != nil {
return nil, err
}
}
var res ScreenResult
err = tx.QueryRow(ctx, `
WITH screened AS (
INSERT INTO verifications (provider_id, source, outcome, detail, evidence_key)
SELECT p.id, 'oig_leie',
CASE WHEN e.excl_type IS NULL THEN 'pass' ELSE 'match' END,
COALESCE('possible match, exclusion type ' || e.excl_type, 'no match'),
$1
FROM providers p
LEFT JOIN LATERAL (
SELECT x.excl_type FROM exclusions x
WHERE x.npi = p.npi
OR (x.last_name = upper(p.last_name) AND x.first_name = upper(p.first_name) AND x.dob = p.dob)
LIMIT 1
) e ON true
RETURNING outcome
)
SELECT count(*), count(*) FILTER (WHERE outcome = 'match') FROM screened`, p.ObjectKey,
).Scan(&res.Screened, &res.Matches)
if err != nil {
return nil, err
}
return &res, tx.Commit()
}
A match is a lead for a person to review, not a decision, since names and birth dates collide. The import file itself stays in the versioned bucket and is referenced from every verification row, so the screening can be reproduced later.
A daily cron job publishes alerts at 60, 30 and 7 days before expiry, and the clearance query reads only current facts:
// credentialing/expiry.go
package credentialing
import (
"context"
"encore.dev/cron"
"encore.dev/pubsub"
)
type CredentialExpiring struct {
ProviderID int64 `json:"provider_id"`
CredentialID int64 `json:"credential_id"`
Kind string `json:"kind"`
DaysLeft int `json:"days_left"`
}
var Expiring = pubsub.NewTopic[*CredentialExpiring]("credential-expiring", pubsub.TopicConfig{
DeliveryGuarantee: pubsub.AtLeastOnce,
})
var _ = cron.NewJob("credential-expiry", cron.JobConfig{
Title: "Alert on expiring credentials",
Schedule: "0 6 * * *",
Endpoint: CheckExpiry,
})
//encore:api private
func CheckExpiry(ctx context.Context) error {
rows, err := db.Query(ctx, `
SELECT id, provider_id, kind, (expires_on - current_date) AS days_left
FROM credentials
WHERE expires_on - current_date IN (60, 30, 7)`)
if err != nil {
return err
}
defer rows.Close()
for rows.Next() {
var e CredentialExpiring
if err := rows.Scan(&e.CredentialID, &e.ProviderID, &e.Kind, &e.DaysLeft); err != nil {
return err
}
if _, err := Expiring.Publish(ctx, &e); err != nil {
return err
}
}
return rows.Err()
}
type Clearance struct {
Cleared bool `json:"cleared"`
Missing []string `json:"missing"`
}
// GetClearance is what scheduling calls before booking a provider.
//
//encore:api private method=GET path=/providers/:id/clearance
func GetClearance(ctx context.Context, id int64) (*Clearance, error) {
c := &Clearance{Missing: []string{}}
rows, err := db.Query(ctx, `
SELECT req.kind FROM (VALUES ('state_license'), ('malpractice')) AS req(kind)
WHERE NOT EXISTS (
SELECT 1 FROM credentials c
WHERE c.provider_id = $1 AND c.kind = req.kind
AND c.verified_at IS NOT NULL AND c.expires_on >= current_date)
UNION ALL
SELECT 'npi' WHERE NOT EXISTS (
SELECT 1 FROM verifications v WHERE v.provider_id = $1 AND v.source = 'nppes' AND v.outcome = 'pass')
UNION ALL
SELECT 'exclusion_screening' WHERE COALESCE((
SELECT v.outcome FROM verifications v
WHERE v.provider_id = $1 AND v.source = 'oig_leie' AND v.checked_at > now() - interval '35 days'
ORDER BY v.checked_at DESC LIMIT 1), 'missing') <> 'pass'`, id)
if err != nil {
return nil, err
}
defer rows.Close()
for rows.Next() {
var kind string
if err := rows.Scan(&kind); err != nil {
return nil, err
}
c.Missing = append(c.Missing, kind)
}
c.Cleared = len(c.Missing) == 0
return c, rows.Err()
}
An expired license or a screening older than 35 days removes clearance on its own, with no status column to keep in sync. A subscriber on credential-expiring can email the provider and the medical staff office, and adding DEA as a requirement for prescribers is one more value in the VALUES list.
encore run starts Postgres, Pub/Sub and a local bucket, so you can create a provider, call VerifyNPI against the live registry and run ImportLEIE on a small sample file. Cron jobs do not run locally, so call CheckExpiry directly while testing. On deploy to your AWS or GCP account, the bucket becomes a private, versioned S3 or Cloud Storage bucket, the database becomes RDS or Cloud SQL, and the daily schedule is managed by the Encore platform, as described in the infrastructure docs. Every endpoint here is private, reachable from your other services but not from the internet.
When a payer adds a requirement, a coding agent can add the credential kind to the migration and the clearance query in one change and test it against the local database, with the bucket and topic already in place.
Best fit: healthcare organizations and health tech teams who want credentials, verification evidence and clearance for scheduling in one service in their own AWS or GCP account.
For each clinician: the NPI, state licenses, DEA registration where they prescribe controlled substances, board certifications and malpractice insurance, each with a number, issuing authority, expiry date, supporting document and verification record. It also needs exclusion screening results and a clear status that says whether the provider can be scheduled.
Call the public NPPES NPI Registry API with the number, for example https://npiregistry.cms.hhs.gov/api/?version=2.1&number=1234567893, check that result_count is 1, that basic.status is A for active and that the name matches the provider, and store the raw response as evidence of the check.
At onboarding and then monthly. The OIG publishes the LEIE as a downloadable file with monthly supplements, and its guidance for state Medicaid agencies says the list must be checked monthly and for new enrollments.
Declare a database with sqldb.NewDatabase, a private bucket for documents and verification evidence with objects.NewBucket, a topic for expiry alerts and a daily cron.NewJob. NPI checks and exclusion screening become endpoints that write append-only verification rows, and one SQL query decides whether a provider is cleared.
Deploy to your cloud on AWS and Google Cloud
without managing infrastructure
Encore lets developers and agents define application infrastructure directly in code, then automatically provisions it from local development to production in your AWS or GCP account.