cd /news/artificial-intelligence/0-bytes-of-patient-pii-sent-to-the-c… Β· home β€Ί topics β€Ί artificial-intelligence β€Ί article
[ARTICLE Β· art-182325] src=dev.to β†— pub= topic=artificial-intelligence verified=true sentiment=↑ positive

0 Bytes of Patient PII Sent to the Cloud: Building a Zero-Trust Telehealth Scribe with Gemini Nano & Firebase

A developer built EchoGuard, a telehealth scribe prototype that runs a local PII redaction layer using Chrome's on-device Gemini Nano via the Firebase AI Logic SDK before any transcript data reaches the cloud. The browser-side shield, paired with a fail-closed deterministic redactor, strips patient names, birthdates, MRNs, insurance IDs and phone numbers, and the UI displays an audit receipt confirming zero bytes of raw PII were sent. Only scrubbed text is passed to Cloud Gemini to generate structured SOAP notes with ICD-10 codes, HL7 FHIR JSON exports, and a two-speaker doctor-and-nurse handoff briefing via Gemini Flash TTS.

recommendation

Redact PII on-device with a fail-closed local model and deterministic fallback before sending any transcript to a cloud LLM, and surface an audit receipt confirming zero raw PII crossed the network.

more in playbook: Securing agents and AI tools
by read4 min views1 publishedDec 5, 2026

Cloud AI can turn a messy telehealth transcript into a clean SOAP note in 5 seconds.

So why aren’t doctors pasting patient notes straight into a cloud LLM?

Because a real clinical transcript has the patient’s full name, date of birth, medical record number (MRN), phone number, insurance ID, and even their mother’s name. Send that raw text to a third-party cloud server and you have an immediate privacy breach.

I built EchoGuard to stop that before a single byte leaves the browser.

Instead of asking clinicians to trust a remote server with raw patient records, EchoGuard enforces a zero-trust boundary locally on the device firstβ€”so 0 bytes of raw PII ever cross the network.

Before diving into the architecture, let’s be clear about what this prototype does and where its boundaries are:

EchoGuard splits the workload across the browser boundary using the Firebase AI Logic SDK (firebase/ai):

[Live Mic / Transcript]
        β”‚
        β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  BROWSER (Zero-PII Boundary)                             β”‚
β”‚  1. Local PII Shield                                     β”‚
β”‚     β€’ Gemini Nano (InferenceMode.ONLY_ON_DEVICE)         β”‚
β”‚     β€’ Fail-closed deterministic local redactor           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚  0 Bytes of Raw PII Crosses Here
        β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  FIREBASE (App Check + Remote Config)                    β”‚
β”‚  2. Cloud SOAP Synthesis (Cloud Gemini)                  β”‚
β”‚     β€’ Structured SOAP Note + ICD-10 + HL7 FHIR JSON      β”‚
β”‚                                                          β”‚
β”‚  3. Multi-Speaker Shift Handoff (Gemini Flash TTS)       β”‚
β”‚     β€’ Parallel Doctor & Nurse synthesis + 24kHz PCM      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

When a clinician dictates via Live Mic or pastes a transcript, nothing touches the network yet. Chrome’s built-in Gemini Nano (InferenceMode.ONLY_ON_DEVICE) pairs with a fail-closed deterministic redactor to scrub patient names, caregiver names (mother, father, guardian), spoken and numeric birthdates, MRNs, insurance IDs, and phone numbers inside the browser.

The UI renders a live audit receipt showing exactly how many entities were stripped locallyβ€”and confirming 0 Bytes PII Sent to Cloud.

/**
 * Redacts residual PII on-device using Gemini Nano via Firebase AI Logic.
 */
export async function redactPIIViaFirebaseNano(
  rawTranscript: string,
  onChunk?: (partialText: string) => void,
): Promise<string> {
  const onDeviceModel = getGenerativeModel(ai, {
    mode: InferenceMode.ONLY_ON_DEVICE,
    onDeviceParams: {
      createOptions: {
        expectedOutputs: [{ type: "text", languages: ["en"] }],
        initialPrompts: [
          {
            role: "system",
            content: [
              {
                type: "text",
                value:
                  "You are a strict PII redaction engine. Return ONLY the original text with any remaining personal identifiers (names, addresses, dates of birth, IDs, phone numbers) replaced by [REDACTED]. Do NOT add explanations, markdown, bullet points, or medical advice.",
              },
            ],
          },
        ],
      },
    },
  });

  // Stream redacted output locally β€” 0 bytes sent to cloud
  // ...
}

Only the scrubbed clinical payload crosses into Cloud Gemini. Because the sensitive identifiers are already replaced with [REDACTED] tokens, the cloud model focuses purely on clinical reasoning: producing a structured SOAP note (Subjective, Objective, Assessment, Plan with ICD-10 codes) and a one-click HL7 FHIR JSON export.

Busy wards run on spoken handoffs, not walls of text. EchoGuard turns the care plan into a two-speaker Doctor & Nurse audio briefing using gemini-2.5-flash-preview-tts, complete with a readable dialogue script and instant .wav download.

Building a hybrid AI app sounds clean on a slide deck. In practice, four things broke during testing:

When I first asked TTS to generate both the Doctor and Nurse in a single request, the voices drifted away from the profiles selected in Settings.

The fix: I built a Split-and-Stitch pipeline. EchoGuard caps the handoff script at 2 turns, synthesizes the Doctor and Nurse lines in parallel using their exact voice profiles, and stitches the raw 24 kHz 16-bit mono PCM buffers together locally with a 350 ms natural .

Replaying a handoff or previewing voices in Settings burned API quota on every single click.

The fix: I replaced Blob URL state with a bounded FIFO Uint8Array PCM cache in memory (so React effect cleanups never revoke cached audio). Replaying a handoff or switching back to a previewed voice now costs 0 API calls.

During live microphone tests, natural speech like "brought in by mother Sarah Lynn, born September 18th 2020" slipped right past standard regex patterns.

The fix: I hardened the deterministic pre-filter with case-sensitive caregiver/family name matching and spoken date-of-birth patternsβ€”while preserving legitimate clinical prose like "Mother reports fever" or "born at 38 weeks".

If a clinician accidentally clicked Live Mic or a sample transcript pill after finishing a note, new text would append onto the previous patient's chart.

The fix: EchoGuard locks down all input controls the moment an encounter completes. To start a new patient chart, the clinician has to explicitly click + New Encounter.

Even when a payload contains zero PII, an open cloud endpoint is still a target for quota abuse. EchoGuard locks down the cloud side using two more Firebase services:

default_cloud_model (gemini-3.1-flash-lite), tts_model, and soap_system_prompt dynamicallyβ€”meaning I can swap Gemini model versions or tighten clinical prompt instructions without redeploying the frontend. Hybrid AI isn’t just about splitting compute between the client and the cloudβ€”it’s about enforcing hard trust boundaries.

Pairing a deterministic local filter with on-device Gemini Nano gives clinicians predictable privacy guarantees regardless of what browser they use, while keeping Cloud Gemini focused on heavy clinical synthesis.

If you want to inspect the redactor rules, the 24 kHz PCM stitcher, or run it locally with Docker, check out the repo: github.com/afiqxeon/echoguard.

── more in #artificial-intelligence 4 stories Β· sorted by recency
── more on @echoguard 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain β€” perfect for shipping the agent you just read about.

$git push zahid main
β†’ Live at https://your-agent.zahid.host βœ“
Get free account β†’ Pricing
from €0/mo Β· no card required
LIVE [news/0-bytes-of-patient-p…] indexed:0 read:4min 2026-12-05 Β· β€”