Reversible, encrypted de-identification of clinical notes

Project
ReDACT-HW, university capstone
Team
4 people
My part
Rule-based PHI detector, manual PHI review, the whole frontend, and the rule-based evaluation. I also contributed to the LLM detector.
Tags
  • React
  • TypeScript
  • Python
  • Flask
  • Presidio
  • spaCy
  • Local LLMs
Capstone Project Demo Video

Overview

ReDACT-HW lets clinicians use cloud LLMs on patient notes without exposing anyone's identity. Personal data is detected, replaced and encrypted on the local machine, so only de-identified text ever leaves the trusted environment. An authorised key holder can still recover the original if needed.

The problem

Clinicians want AI to summarise and analyse patient notes, but sending the real notes to cloud LLMs creates big HIPAA and privacy risks. Scrubbing identifiers (PHI) by hand is slow and easy to get wrong, so a lot of healthcare teams simply can't use modern AI tools safely.

Original noteSarah Mitchell (DOB 12/03/1961) was reviewed at Northgate Regional Hospital. Contact: 0412 345 678.
De-identified notePriya Nandakumar (DOB 14/05/1961) was reviewed at St Aldric Community Hospital. Contact: 0498 220 713.

example

My contribution

This was a team of four. The parts I worked on were:

How the system fits together

The system is split into a trusted local environment, where PHI is present, and an open environment, where only de-identified text exists. The trust boundary between them is the core security property.

System architecture and trust boundary Inside the trusted local environment, a clinical note is optionally transcribed by a local vision model, then PHI is detected, then identifiers are encrypted and pseudonymised using a key vault. Only the surrogate text crosses the trust boundary to the open environment, where a cloud LLM processes the de-identified note and produces a result. Trusted / local environment: PHI present Clinical note contains PHI (typed, or handwritten and transcribed locally) Local vision model transcription optional, image never leaves the device Detect PHI rules + NLP + local LLM, plus manual review Encrypt & pseudonymise reversible surrogates Key vault encrypted identifier mapping Trust boundary only surrogate text crosses Open environment: no PHI, cloud LLM safe to use De-identified note safe to share and process Cloud LLM task summarise, extract, code Result re-identify only if authorised
Re-identification flows back the other way: with the correct key, surrogates in a returned note are decrypted using the vault mapping.

Processing a note

The Process a note page works a bit like a checkout – one step at a time, carrying the result of the previous step forward. There's an optional first step that turns a handwritten note into the text file used for the rest.

  1. Upload the clinical note as a plain text file. Nothing leaves the local environment at this point.
  2. Two detectors run on the note: a rule-based one (regex patterns plus an NLP model) and a local LLM. Each finds PHI on its own and labels it against about 30 identifier categories.
  3. Inspect each detector's output. Every result is shown on its own screen with the note highlighted and every span tagged, so you can compare the two side by side.
  4. Manual PHI review. Both lists are merged into one view. The reviewer can add, remove or relabel any span – the whole point is to catch every identifier before anything goes to the LLM.
  5. Preview the surrogate note. Original and surrogated versions are shown next to each other.
  6. Download the de-identified note, now safe to give to a cloud LLM.

What's in the app

Page What it does
Process a note The guided flow above: upload, detect, review, surrogate and download
Re-identify Upload a de-identified note to recover the original from the surrogate values
History Browse processed notes next to their de-identified versions, and generate a summary
Evaluation Measured results for the rule-based detector, the LLM, pseudonymisation and the threat model
Settings Change passwords and create accounts

PHI detection

Rule-based detector

The rule-based service looks for identifiers that have a recognisable structure or a well-known vocabulary. It sits on Microsoft Presidio, which runs independent recognizers over the note and pools everything into one list of typed spans.

Recognizer Covers
AHPRA Health practitioner registration numbers
HPI-I Healthcare Provider Identifier, Individual
HPI-O Healthcare Provider Identifier, Organisation
IHI Individual Healthcare Identifier
Suburb / postcode Built from the full list of Australian suburbs and postcodes

I evaluated this detector on 100+ synthetic notes with planted identifiers, scored at three different strictness levels and split by recognizer type, so you can see what the rules contributed versus the NLP model.

Local LLM detector

The LLM service finds the identifiers that need context – patient, relative and clinician names, hospitals and clinics, and whether a date is a birth date or a clinical one. It runs gemma4:e4b locally through Ollama, so the note never leaves the machine.

Five local models were tried on 15 notes, and the three strongest were run on 100:

Model F1 Decoys wrongly flagged Notes with nothing missed
gemma4:e4b 0.948 0 of 452 27 / 100
llama3.1:8b 0.933 31 15 / 100
qwen2.5:7b 0.898 49 6 / 100

On a held-out set of 20 notes not used while building the prompt, it found 95% of identifiers (recall 0.951) with no false alarms (precision 1.000). It still misses some, which is why its spans are merged with the rule-based detector's and checked in the manual review step.

Manual review

A missed identifier is the critical error. The target is PHI recall of at least 0.98. So after the automated detection there's a review step where a person can add, remove or relabel spans before anything is surrogated. Where the two detectors disagree, a span can carry several labels for the reviewer to sort out.

De-identification, encryption and the key vault

Once the reviewer confirms the spans, each identifier is replaced with a surrogate of the same format. Different kinds of identifier are handled differently, because what makes them reversible decides what has to be stored.

Other components

Design choices

Tech stack

Frontend React, TypeScript, shadcn/ui, Tailwind CSS, Recharts
Backend Python, Flask
PHI detection Presidio, spaCy (en_core_web_lg), custom AU recognizers, local LLM via Ollama
Encryption FF3 format-preserving encryption, cryptography, encrypted key vault
Storage File system
Testing pytest, plus an evaluation harness over synthetic notes