phi-redaction
Skill33 starsChanged 4 months agoMITView on GitHub
Conservative PHI redaction patterns for FHIR resources. Use when: (1) Redacting patient health information from FHIR resources before AI agent access, (2) Implementing de-identification for clinical data pipelines, (3) Understanding what fields are stripped, masked, or truncated in FHIR resources, (4) Building read paths that automatically protect patient privacy.
In this repository13 other files it gives its agents.
- check-sourcesSkill
- curatrSkill
- fasten-connectSkill
- fhir-r6-guardrailsSkill
- fhir-upstream-proxySkill
- getting-startedSkill
- healthbankoneSkill
- healthex-export-redactedSkill
- healthex-exportSkill
- hermesSkill
- hypertension-coordinatorSkill
- personal-health-recordsSkill
- share-health-qrSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 25
All redaction is applied at read time, not at storage time.
- Distinctive: line 58
All contained resources are redacted recursively
- Distinctive: line 76
Always deep-copy before redacting (never modify the stored resource)
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
PHI Redaction for FHIR Resources
Standard redaction profile for Protected Health Information (PHI) applied on all read paths in the FHIR MCP guardrail stack. This is a technical minimization preview, not a legal Safe Harbor determination.
When to Use This Skill
- You need to understand how PHI is stripped from FHIR resources
- You are building a pipeline that must redact clinical data before AI access
- You need to implement or audit de-identification logic for FHIR
Redaction Rules
All redaction is applied at read time, not at storage time.
Names (HumanName)
- Family name: Kept as-is
- Given names: Truncated to first initial + period (e.g., "John" -> "J.")
- Text: Removed
Identifiers
- Value: Removed (e.g.,
{"system": "…/us-ssn", "value": "123-45-6789"}->{"system": "…/us-ssn"}) - System and type: Kept for reference
Addresses
- Line and text: Removed
- City, state, country: Kept (for demographic analysis)
Telecom (Phone, Email)
- Value: Replaced with
[Redacted] - System and use: Kept
Birth Date
- Truncated to year only (e.g., "1985-03-15" -> "1985")
Photos
- Removed entirely from the resource
Text Narratives
- Replaced with:
<div xmlns="http://www.w3.org/1999/xhtml">[Redacted]</div> - Status set to
empty
Notes and Comments
- Replaced with
[Redacted]
Contained Resources
- All contained resources are redacted recursively
Implementation Pattern (Python)
import json
def apply_redaction(resource):
"""Deep-copy the resource and redact PHI fields."""
redacted = json.loads(json.dumps(resource))
_redact_fields(redacted)
for contained in redacted.get('contained', []):
if isinstance(contained, dict):
_redact_fields(contained)
return redactedKey implementation notes:
- Always deep-copy before redacting (never modify the stored resource)
- Redact contained resources recursively
- Apply on ALL read paths: direct reads, search results, context envelopes, upstream proxy responses
De-identification Preview Coverage
This redaction profile minimizes these common identifier classes:
- Names (partial)
- Geographic data smaller than state (addresses stripped)
- Dates (birth date truncated to year)
- Telephone/fax numbers (redacted)
- Email addresses (redacted)
- Medical record numbers, Social Security numbers, account numbers — any
identifier.value(removed)
Not covered by this profile (would need additional implementation):
- An identifier typed into a free-text field the profile does not strip (no pattern scan runs over arbitrary strings)
- IP addresses, device identifiers (not redacted from extension fields)
- Biometric identifiers
- Full-face photographs (removed if in
photofield, not scanned in attachments)
Integration with MCP Tools
The redaction is applied automatically by the guardrail stack. MCP tools like
fhir.read, fhir.search, fhir.lastn, and context.get all return
redacted data. No additional action is needed by the agent.
The $deidentify operation provides an explicit conservative preview on demand.
Expert review is still required before export or disclosure.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

