Jay Lawrence
All posts

AI agent architecture · Healthcare data · HIPAA compliance

How we structure product data for AI agents with HIPAA in mind

How we separate the product source of truth, referral documents, AI job persistence, corrections, and PHI-safe progress across an agentic healthcare workflow.

Building an agentic workflow for skilled nursing referrals made the database question more specific. We did not need one large store that the product and every agent could access. We needed clear ownership for business facts, documents, job execution, corrections, and every payload crossing those boundaries.

The architectural thesis

Keep business authority in the product and processing capability in the engine.

The workflow can cross systems without turning the AI engine into a second product database.

The core decision

Business authority and AI execution stay separate.

The product backend owns tenancy, users, residents, nurse edits, and the durable audit of those edits. The engine owns a narrower job: process the referral, retain execution state and structured evidence, and return a result for review.

A nurse correction is written to the product first, then mirrored into the engine so the job reflects the reviewed state.

The database that helps an agent finish a job is not necessarily the database that owns the business fact.

The engine proposes. The product commits.

The order is the contract: request out, candidate back, product save first, reviewed mirror second.

The data path

The workflow moves references and reviewed facts—not the whole product model.

The backend uploads a referral packet, creates a job identifier, and gives the engine a claim-check reference with the small amount of facility context required for processing.

One referral crosses five controlled boundaries.

  1. AuthorityProduct DB

    Identity, tenancy, resident, and reviewed truth.

  2. Claim checkBlob storage

    Referral documents and job-scoped artifacts.

  3. CapabilityAI job

    Extraction, assessment, evaluation, and evidence.

  4. DecisionNurse review

    Correct, explain, accept, or remove a result.

  5. AuthoritySave + mirror

    Product first; reviewed row mirrors back to the job.

Documents stay in object storage. The engine receives a validated reference, while the final correction returns through the product’s authorized workflow.

Five data zones

We classify stores by purpose, not only by technology.

Every zone has an owner, a purpose, and a narrow crossing.

  1. Product

    Authoritative product and clinical state.

    Owner
    Backend
    Allowed
    Tenants, residents, reviewed edits
  2. Document

    Referral packets and extraction inputs.

    Owner
    Blob boundary
    Allowed
    Validated job references
  3. Execution

    Job progress, evidence, and structured results.

    Owner
    AI engine
    Allowed
    Bounded job data
  4. Learning

    Reviewed corrections used for retrieval.

    Owner
    Governed memory
    Allowed
    Provenance + masked embedding
  5. Integration

    Contracts connecting product, engine, and UI.

    Owner
    API boundary
    Allowed
    Allowlisted fields only
A result, trace, correction, or embedding can still reveal protected information. Sensitivity follows the content, not the database label.

Model context

Different agent stages need different levels of information.

OCR and extraction must process the referral itself. Downstream assessment stages receive a narrower structured view, with direct identifiers masked and date of birth converted to age where the clinical task permits it.

Context narrows as the workflow becomes more specific.

  1. SensitiveRaw referral

    Approved document and OCR services process the packet.

  2. ExtractionClinical facts

    Structured values are separated from document layout.

  3. ReductionMasked context

    Identifiers and contact patterns are removed; DOB can become age.

  4. Need to knowAgent stage

    Assessment receives only the context required for its task.

  5. GuardrailOutput scan

    Narratives and embedding text are checked again.

Masking reduces exposure; it is not formal de-identification and does not replace vendor agreements, access controls, or risk analysis.

Memory and learning

Job memory and reusable correction memory follow different lifecycles.

The orchestrator’s goal, plan, attempts, and decisions end with the current job. Reviewed corrections may enter a deliberate retrieval path with provenance, masking, embeddings, retention, and review.

A vector column does not make correction data anonymous.

Only reviewed corrections may cross the job boundary.

Execution context ends with the referral. Later jobs retrieve only a reviewed, provenance-linked correction; there is no open-ended cross-job chat.

Audit without replication

Operational visibility should not become another clinical database.

One internal event is shaped into three narrow channels.

  1. Audit record

    Who called which job route and what status returned.

    Owner
    Security log
    Allowed
    Method, path, caller signal, status
  2. Scrubbed trace

    Job-scoped reasoning evidence with common identifiers removed.

    Owner
    Engine trace
    Allowed
    Bounded diagnostic context
  3. Progress event

    Enough state for the interface to explain movement.

    Owner
    Queue
    Allowed
    Status, step, counters, timestamp
Resident names, filenames, document text, raw errors, and debug payloads stay out of the progress channel.

Architecture review

Seven questions keep each boundary honest.

The review starts with ownership and ends with evidence.

DecisionQuestionEvidence
OwnerWhich system owns the fact?Named source of truth
TransferCan a validated reference replace a copied document?Narrow request contract
ContextWhich stage genuinely needs raw clinical text?Stage-specific projection
AuthorityIs this a suggestion, review, or authoritative write?Explicit write direction
LifecycleWhat persists, for how long, and who deletes it?Retention and deletion rule
ObservabilityCan the event explain without copying clinical content?Allowlisted schema
VendorsWhich services receive ePHI?Agreement + configured safeguard
These questions turn a database diagram into a lifecycle that product, engineering, security, and compliance can inspect together.

What separation does not solve

A clean diagram is not the same as a compliant system.

Database separation sits inside a larger safeguard program.

  1. DesignClear data ownership

    Product authority, engine capability, and bounded contracts.

  2. TechnicalAccess and evidence

    Authorization, encryption, audit, integrity, and recovery.

  3. AdministrativeOperating discipline

    Risk analysis, policy, training, vendor management, and incident response.

  4. PhysicalReal-world safeguards

    Devices, workstations, facilities, continuity, and access procedures.

Engineering owns an important part of the system—not the whole of HIPAA compliance.

Encryption does not replace authorization. Masking does not automatically create de-identified data. A business associate agreement does not replace risk analysis. The final design must be validated against the organization’s role, data flows, contracts, and applicable legal guidance.

The principle I keep

Keep authority in the product and capability in the engine.

The product knows the organization, the resident, the reviewer, and the final decision. The engine knows the referral job, its tools, its evidence, and the limited state required to process it reliably. That separation lets an agent be capable without quietly becoming authoritative.

References

Primary guidance behind the framework.