AGENSPHERE/ JOURNAL
← JOURNAL
J-050NOTE4 MIN READ

A HIPAA-compliant LLM app is mostly about where PHI goes

HIPAA-compliant LLM applications are possible, but no model is compliant on its own. Compliance comes from a signed BAA with every vendor that touches PHI, the minimum necessary data in each prompt, access controls, audit logs and a plan for breaches. The engineering, step by step.

IN SHORT
  • A HIPAA-compliant LLM application is one where every system that creates, receives, stores or transmits PHI is covered by HIPAA safeguards, and every vendor that touches PHI has signed a business associate agreement (BAA).
  • No model is HIPAA compliant by itself. What matters is the specific service, its configuration (for example data retention settings) and whether your BAA covers it.
  • Engineer for the minimum necessary standard: send each prompt only the PHI the task needs, de-identify where you can, and keep PHI out of logs, caches and evaluation sets unless they are protected too.
  • Add access controls, audit trails of every model call and a breach response plan, and test them before launch.

Healthcare teams want what every other industry wants from language models: faster documentation, better answers from their own knowledge, fewer hours on paperwork. The question US healthcare buyers ask first is whether a HIPAA-compliant LLM application is possible. It is. But no model is HIPAA compliant on its own. Compliance is a property of the whole system: who handles protected health information (PHI), under what agreement, and with which safeguards.

This is an engineering guide, not legal advice. Work with your compliance officer and counsel.

01What makes an LLM application HIPAA compliant?

HIPAA applies to covered entities (health plans, healthcare clearinghouses and most providers) and to their business associates, the vendors that handle PHI on their behalf. For an LLM application, that means:

  • Every vendor that touches PHI signs a business associate agreement (BAA): the model provider, the cloud host, the vector database, the logging and monitoring tools.
  • The Security Rule's safeguards apply to every system that holds PHI: administrative (policies, training, risk analysis), physical and technical (access control, audit controls, integrity, transmission security).
  • The minimum necessary standard applies: use and disclose only the PHI a task needs.
  • The Breach Notification Rule applies if PHI is exposed.

02Can you use ChatGPT or other LLMs with PHI?

Not a consumer chat app, and not any API by default. Several major model providers and cloud platforms offer BAAs for specific AI services, sometimes only with particular settings such as zero data retention. Before any PHI reaches a model, confirm three things in writing: that a BAA is in place, which exact service and endpoint it covers, and which configuration it requires. Then enforce that configuration in code, so nobody can route PHI to an uncovered endpoint by changing a setting (see avoid LLM vendor lock-in for how a routing layer makes this one place to control).

The model is one vendor among several. Every copy of PHI needs the same protection, wherever it lands.

03Where does PHI end up in an LLM system?

Usually in more places than the architecture diagram shows:

LocationExampleWhat to do
PromptsA clinical note sent for summarizationBAA-covered endpoint; minimum necessary fields
Retrieval indexEmbedded chunks of patient recordsEncrypt, restrict access, filter by permission
Logs and tracesFull prompts kept for debuggingRedact, or store under the same controls as the EHR
CachesStored responses keyed on promptsSame controls, short retention
Evaluation setsReal cases used to test qualityDe-identify, or protect as PHI
Third-party toolsMonitoring, error tracking, analyticsBAA, or keep PHI out entirely

Logs and error trackers are the most common gap. A system can use a covered model endpoint and still leak PHI into a monitoring tool that never signed a BAA (see trace and cost every model call).

04How do you apply the minimum necessary standard to prompts?

Decide per task which fields the model needs, and build the prompt from those fields only. Where the task does not need identity, de-identify first:

phi/prompt.py
TASKS = {
    "discharge_summary": {"fields": ["diagnoses", "medications", "procedures", "follow_up"], "identify": False},
    "patient_message_reply": {"fields": ["question", "care_team", "appointment"], "identify": True},
}

def build_prompt(record, task):
    spec = TASKS[task]
    data = {k: record[k] for k in spec["fields"]}       # minimum necessary, enforced in code
    if not spec["identify"]:
        data, mapping = deidentify(data)                 # names, dates, MRNs -> placeholders
    audit.log(task=task, user=current_user(), patient=record["id"], fields=spec["fields"], endpoint=PHI_ENDPOINT)
    return render(task, data)

HIPAA defines two ways to de-identify data: removing a specified list of identifiers (Safe Harbor) or a documented expert determination. Placeholder substitution in prompts reduces risk but is not automatically de-identification under either method, so treat it as minimization unless your compliance team has signed off.

05What technical safeguards does the system need?

  • Access control: role-based access to the application, and retrieval filtered by what each user may see (see filter by permission before you rank).
  • Audit controls: a record of who asked what, which PHI was used, which model processed it and what came back (see AI audit trail).
  • Integrity: validated outputs before anything is written back to a record (see validate structured outputs at the boundary).
  • Transmission security: encryption in transit everywhere, and encryption at rest for indexes, logs and caches.
  • Human review for anything that affects care, with the model's sources shown.

06How do you start a healthcare AI project safely?

Begin with a risk analysis of the proposed data flows, pick a first use case with low clinical risk and easy verification (documentation drafting for clinician review is a common one), and build with synthetic or de-identified data until the BAAs and controls are in place. If you already have an LLM feature in production, an AI Audit maps every place PHI goes and what protects it.

07Where to go next

For building on your own clinical knowledge, see RAG development. For the general version of this problem, read LLM data compliance: where your data goes.

Is your AI live, but fragile, slow or expensive?DESCRIBE YOUR SYSTEM →