Inferensys

Prompt

Healthcare PHI De-identification Prompt Template

A practical prompt playbook for using the Healthcare PHI De-identification Prompt Template in production AI workflows to detect and redact protected health information before outputs enter logs, databases, or user-facing surfaces.
Data scientist building training data pipeline on laptop, data preprocessing visible, technical workspace.
PROMPT PLAYBOOK

When to Use This Prompt

A post-generation safety net for de-identifying model outputs against the HIPAA Safe Harbor standard before they leave a controlled environment.

This prompt is a repair and validation tool, not a content generator. It is designed for healthcare compliance teams and security engineers who already have a model output—such as a clinical note, a patient summary, or a care coordination message—and need to strip it of protected health information (PHI) before it can be logged, stored, or shared. The prompt instructs the model to scan the provided text, identify PHI across all 18 HIPAA Safe Harbor identifier categories, and redact each instance with a consistent, non-reversible placeholder token. The output is a structured JSON payload containing both the de-identified text and a detailed audit log of every redaction decision, making the process explainable to auditors and downstream reviewers.

Use this prompt when the model output is already generated and you need a programmatic, auditable de-identification step. It is most effective when paired with a deterministic regex post-processor that handles high-precision identifiers like Medical Record Numbers (MRNs) and standardized dates before the text reaches the model. The prompt itself excels at contextual disambiguation—for example, distinguishing a patient's name from a clinician's name or a provider ID from a generic number. Do not use this prompt as your only line of defense for real-time streaming outputs, for de-identifying structured JSON payloads field-by-field, or for generating new clinical content. It is a repair step for free-text outputs that may contain PHI.

The prompt requires human review for any redaction flagged as low confidence. It is not a substitute for a formal de-identification pipeline, but it is a practical, auditable safety net when a model output must be sanitized quickly and the cost of a PHI leak is high. Before implementing, ensure you have a clear definition of your environment's PHI categories, a test set of known PHI examples to measure recall, and a process for logging and reviewing the audit trail this prompt produces.

PRACTICAL GUARDRAILS

Use Case Fit

Where this prompt works, where it fails, and the operational preconditions required before putting it into a production pipeline handling protected health information.

01

Good Fit: Post-Generation Safety Net

Use when: model outputs (summaries, notes, transcripts) are about to enter a downstream system, log, or user-facing surface. Guardrail: run this prompt as a final filter after generation but before storage or display. It is not a replacement for input-side redaction or access controls.

02

Bad Fit: Real-Time Clinical Decision Support

Avoid when: latency must be sub-second and the output directly informs patient care. Guardrail: de-identification prompts add variable latency. For real-time systems, use deterministic regex-based redaction first and reserve this prompt for offline batch verification.

03

Required Inputs: Structured or Unstructured Text with PHI Risk

What to watch: the prompt expects a complete text block that may contain PHI. Guardrail: always pass the full model output, not a truncated snippet. Partial inputs cause the model to miss PHI at truncation boundaries. Include a character-level checksum or sequence ID for traceability.

04

Operational Risk: Safe Harbor Method Gaps

What to watch: the prompt uses the HIPAA Safe Harbor method (18 identifiers), but models can miss non-obvious PHI like provider initials combined with dates, or rare geographic subdivisions smaller than a state. Guardrail: always run a deterministic post-check for known MRN patterns, ZIP codes, and dates. Log every redaction decision with a confidence flag for audit.

05

Operational Risk: Re-identification Through Context

What to watch: redacting individual identifiers is not enough if the remaining text contains a unique combination of facts (e.g., rare diagnosis + specific admission date + unusual procedure). Guardrail: after de-identification, run a second pass that flags outputs with high re-identification risk based on k-anonymity heuristics. Escalate flagged outputs for human review before release.

06

Operational Risk: Model Drift and PHI Leakage Over Time

What to watch: model behavior changes across versions can cause previously reliable de-identification prompts to start leaking PHI. Guardrail: maintain a golden dataset of de-identified outputs with known PHI. Run regression tests on every model update and prompt change. Gate deployment on zero PHI leakage against the golden set.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A production-ready prompt for detecting and redacting Protected Health Information (PHI) using the Safe Harbor method, with verification checks and re-identification risk notes.

This prompt template is designed to be placed in your system instructions or sent as a user message for post-generation PHI scrubbing. It instructs the model to act as a de-identification engine, applying the HIPAA Safe Harbor method to locate and redact 18 specific identifiers from unstructured text. The prompt is structured to produce a consistent JSON output that includes the redacted text, a change log, and a re-identification risk assessment, making it auditable and integrable into a compliance pipeline.

markdown
You are a de-identification engine operating under the HIPAA Privacy Rule. Your task is to receive unstructured text and apply the Safe Harbor method to redact all 18 Protected Health Information (PHI) identifiers.

## INPUT
[INPUT]

## CONSTRAINTS
- Redact the following 18 identifiers if present: names; geographic subdivisions smaller than a state; all elements of dates (except year) related to an individual; telephone numbers; fax numbers; email addresses; social security numbers; medical record numbers; health plan beneficiary numbers; account numbers; certificate/license numbers; vehicle identifiers and serial numbers; device identifiers and serial numbers; web URLs; IP addresses; biometric identifiers; full-face photographs and comparable images; any other unique identifying number, characteristic, or code.
- Replace redacted text with a placeholder describing the PHI category in square brackets, e.g., [PATIENT_NAME], [MRN], [DATE].
- Do not alter any text that is not PHI.
- Preserve the original structure, line breaks, and non-PHI punctuation.
- If no PHI is found, return the original text unchanged.

## OUTPUT_SCHEMA
Return a single valid JSON object with the following keys:
- "redacted_text": The fully redacted string.
- "phi_detected": A boolean indicating if any PHI was found.
- "redaction_log": An array of objects, each describing a redaction with keys "original_value", "redacted_placeholder", and "phi_category".
- "reidentification_risk": A string assessment: "LOW", "MEDIUM", or "HIGH", based on the remaining context and the specificity of redacted values.
- "risk_note": A brief string explaining the re-identification risk assessment.

## EXAMPLES
Input: "Patient John Doe, MRN 12345, was admitted on 01/15/2023."
Output: {
  "redacted_text": "Patient [PATIENT_NAME], MRN [MRN], was admitted on [DATE].",
  "phi_detected": true,
  "redaction_log": [
    {"original_value": "John Doe", "redacted_placeholder": "[PATIENT_NAME]", "phi_category": "Name"},
    {"original_value": "12345", "redacted_placeholder": "[MRN]", "phi_category": "Medical Record Number"},
    {"original_value": "01/15/2023", "redacted_placeholder": "[DATE]", "phi_category": "Date"}
  ],
  "reidentification_risk": "LOW",
  "risk_note": "All direct identifiers have been redacted. Remaining context is generic."
}

## RISK_LEVEL
[HIGH]

To adapt this template, replace the [INPUT] placeholder with the text you need to scrub. The [RISK_LEVEL] placeholder should be set to "HIGH" for production healthcare workflows, which signals the model to apply maximum scrutiny. For lower-stakes testing, you can set it to "MEDIUM" or "LOW" to observe how the model's strictness changes. The output schema is designed for direct ingestion by a downstream validator; you should implement a post-processing check that ensures the redacted_text does not contain any of the original_value strings from the redaction_log, as this is a common failure mode where the model identifies PHI but fails to replace it in the text. Always log the full JSON output for audit trails, and route any output with a "HIGH" re-identification risk for human review before it leaves the system.

IMPLEMENTATION TABLE

Prompt Variables

Inputs the Healthcare PHI De-identification prompt needs to work reliably. Validate each before sending to the model. All placeholders must be resolved or explicitly set to null before the prompt is assembled.

PlaceholderPurposeExampleValidation Notes

[CLINICAL_TEXT]

The raw clinical note, discharge summary, or medical document to de-identify

Patient John Doe, MRN 12345, was admitted on 01/15/2024 with chest pain.

Must be a non-empty string. Check for null, empty, or whitespace-only input. Truncate at 100k characters to prevent context overflow.

[SAFE_HARBOR_CATEGORIES]

The specific HIPAA Safe Harbor identifiers to redact

["names", "MRN", "dates", "provider_ids", "phone_numbers"]

Must be a valid JSON array of strings. Validate against allowed category enum: names, MRN, dates, provider_ids, phone_numbers, emails, SSN, account_numbers, certificate_numbers, device_ids, URLs, IPs, biometric, photos. Reject unknown categories.

[REDACTION_STRATEGY]

How to replace detected PHI in the output

mask

Must be one of: mask, placeholder, remove, or tag. mask replaces with [REDACTED], placeholder replaces with [PHI_TYPE], remove deletes entirely, tag wraps in <phi type="TYPE">original</phi>. Default to mask if null.

[OUTPUT_FORMAT]

The required structure for the de-identified output

json

Must be one of: json, text, or annotated. json returns structured payload with original and redacted fields. text returns only redacted text. annotated returns text with inline PHI tags. Default to json if null.

[VERIFICATION_ENABLED]

Whether to run a secondary verification pass on the output

Must be a boolean. If true, the prompt includes a verification step that re-scans the redacted output for residual PHI patterns. Set false for latency-sensitive streaming use cases.

[ALLOW_LIST]

Terms that match PHI patterns but should not be redacted

["Test Hospital", "Sample Clinic", "999-99-9999"]

Must be a JSON array of strings or null. Each entry is a case-insensitive exact match exemption. Validate array length does not exceed 50 entries to avoid prompt bloat.

[RE_IDENTIFICATION_RISK_NOTE]

Whether to append a re-identification risk assessment to the output

Must be a boolean. If true, the output includes a risk_note field explaining residual re-identification risks from context, rare names, or indirect identifiers. Required for compliance review workflows.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Healthcare PHI De-identification prompt into a production application or compliance pipeline.

This prompt is not a standalone safety net. It must be embedded inside a deterministic application harness that controls input, validates output, logs decisions, and enforces human review for any ambiguous or high-risk case. The harness should treat the model as one component in a defense-in-depth strategy: upstream filtering, the de-identification prompt itself, downstream schema validation, and a final audit log are all required before any output reaches a database, log, or user-facing surface.

Input preparation starts with a strict allowlist. Before the prompt receives [INPUT_TEXT], the harness should strip any known PHI using deterministic regex patterns for MRNs, SSNs, and standard date formats. The prompt then handles the ambiguous remainder. Model choice matters: prefer a model with strong instruction-following and low refusal rates on security tasks. Set temperature=0 and disable sampling to maximize output determinism. Output validation must parse the JSON response and verify that every field in the original text is accounted for in the redactions array. If the model returns malformed JSON, retry once with a repair prompt; if it fails again, escalate the entire record to human review. Logging must capture the original text hash, the redacted output, the model's confidence scores, and the reviewer decision for every record—never log the raw PHI itself.

Human review integration is mandatory for any record where the model's re_identification_risk score exceeds low or where the redactions array contains confidence below 0.95. Build a review queue that presents the original text side-by-side with the proposed redactions, highlighting low-confidence decisions. Reviewers should be able to approve, modify, or reject each redaction. The harness must block downstream consumption until review is complete. Retry logic should be limited: one retry for format errors, zero retries for content decisions. If the model hallucinates a redaction that does not exist in the source text, the harness must flag it as a false positive and revert it. Testing requires a golden dataset of 200+ clinical text samples with known PHI positions, including edge cases like hyphenated names, abbreviated dates, and provider IDs that resemble MRNs. Run this prompt against the dataset weekly and track precision, recall, and false positive rate. Any regression in recall below 0.98 must block deployment.

What to avoid: Do not send raw PHI to external model APIs without a BAA in place. Do not rely solely on this prompt for HIPAA compliance—it is a technical control, not a legal one. Do not skip the audit log. Do not assume the model will catch every PHI instance; the harness must combine deterministic rules, this prompt, and human review into a single pipeline. If your use case involves real-time streaming outputs, buffer chunks until you have complete sentences before running de-identification, and implement a circuit breaker that blocks output if the pipeline latency exceeds 500ms.

IMPLEMENTATION TABLE

Expected Output Contract

Fields, types, and validation rules for the Safe Harbor de-identification JSON response. Use this contract to validate model output before it enters downstream systems or logs.

Field or ElementType or FormatRequiredValidation Rule

deidentified_text

string

Must not contain any PHI entity from the detected_entities list. Length must match input text length within 5% tolerance after redaction marker substitution.

detected_entities

array of objects

Each object must have entity_type, original_value, redacted_value, confidence, and safe_harbor_category fields. Array must not be empty if PHI was found.

detected_entities[].entity_type

string (enum)

Must match one of: NAME, DATE, PHONE, EMAIL, SSN, MRN, ADDRESS, ZIP, URL, IP, PROVIDER_ID, ACCOUNT_NUMBER, DEVICE_ID, BIO_METRIC, OTHER. No hallucinated types allowed.

detected_entities[].original_value

string

Must be an exact substring match in the original input text. Verify with indexOf check. Null or empty string not allowed.

detected_entities[].redacted_value

string

Must use Safe Harbor marker format: [REDACTED-{CATEGORY}] where CATEGORY is the safe_harbor_category value. Example: [REDACTED-NAME].

detected_entities[].confidence

number (0.0-1.0)

Must be a float between 0.0 and 1.0 inclusive. Values below 0.7 must trigger human_review_required flag. Parse as float and check range.

detected_entities[].safe_harbor_category

string (enum)

Must match one of 18 HIPAA Safe Harbor categories: NAME, GEOGRAPHIC_SUBDIVISION, DATE, PHONE, FAX, EMAIL, SSN, MRN, HEALTH_PLAN_BENEFICIARY, ACCOUNT_NUMBER, CERTIFICATE_LICENSE, VEHICLE_ID, DEVICE_ID, URL, IP, BIOMETRIC, PHOTOGRAPH, OTHER. No invented categories.

human_review_required

boolean

Must be true if any detected_entity has confidence < 0.7 or if reidentification_risk is MEDIUM or HIGH. Must be false only when all entities have confidence >= 0.95 and risk is LOW.

reidentification_risk

string (enum)

Must be LOW, MEDIUM, or HIGH. LOW requires all 18 Safe Harbor categories addressed. MEDIUM if dates remain in year-only format. HIGH if any direct identifier remains unredacted.

redaction_summary

object

Must contain total_entities_found, categories_affected, and low_confidence_count fields. total_entities_found must equal detected_entities array length. low_confidence_count must match count of entities with confidence < 0.7.

PRACTICAL GUARDRAILS

Common Failure Modes

What breaks first when de-identifying PHI in production and how to guard against it.

01

Safe Harbor Method Blind Spots

What to watch: The model misses PHI categories required by the Safe Harbor method—especially ages over 89, geographic subdivisions smaller than a state, and ZIP codes with populations under 20,000. These are easy to overlook because they don't match common PII patterns. Guardrail: Include the full 18 Safe Harbor identifiers in the prompt as a checklist and run a post-processing validator that cross-references each category against the output.

02

Contextual Re-identification Risk

What to watch: The model redacts individual identifiers but leaves combinations of quasi-identifiers (e.g., rare diagnosis + admission date + ZIP code) that together can re-identify a patient. This is the most common HIPAA violation in de-identified datasets. Guardrail: Add a secondary verification step that checks for unique or near-unique combinations of remaining fields and flags records with k-anonymity below a configurable threshold.

03

Inconsistent Redaction Across Batches

What to watch: The same PHI instance is redacted in one output but missed in another when processing multiple records or streaming responses. This happens when the model's attention drifts across long contexts or when batch processing lacks state. Guardrail: Use deterministic pre-processing for known PHI patterns before the model sees the text, and run a checksum-based deduplication check across batch outputs to catch inconsistent redactions.

04

Over-Redaction of Clinical Information

What to watch: The model aggressively redacts clinical terms, lab values, or medication names that are not PHI, rendering the output clinically useless. This is common when the prompt over-indexes on caution without distinguishing clinical data from identifiers. Guardrail: Provide explicit allowlists for clinical terminology, lab result formats, and medication names in the prompt, and test against a golden set of clinical records where redaction boundaries are pre-labeled.

05

Date Shift and Age Leakage

What to watch: The model redacts exact dates but leaves relative date expressions ("3 days post-op") or ages that, combined with admission dates, allow re-identification. Date shifting without consistency across related records also breaks temporal relationships needed for clinical review. Guardrail: Implement a consistent date-shifting strategy with a fixed offset per patient record, and validate that all date-derived fields (age, length of stay, follow-up intervals) remain internally consistent after de-identification.

06

Free-Text Narrative PHI Survival

What to watch: PHI embedded in clinical narratives, physician notes, or discharge summaries survives redaction because the model treats structured fields and free-text differently. Provider names, family member details, and incidental mentions are the most common survivors. Guardrail: Run a dedicated free-text PHI scan after structured field redaction, using a separate prompt focused exclusively on narrative PHI detection with examples of incidental and embedded identifiers.

IMPLEMENTATION TABLE

Evaluation Rubric

Run these checks against a golden dataset of 50 clinical texts with known PHI positions to validate the de-identification prompt before production deployment.

CriterionPass StandardFailure SignalTest Method

Safe Harbor PHI Recall

= 0.98 recall across all 18 Safe Harbor identifiers on the golden set

Any patient name, MRN, date (outside year-only), phone, fax, email, SSN, medical record number, health plan beneficiary number, account number, certificate/license number, vehicle identifier, device identifier, URL, IP address, biometric identifier, or full-face photo equivalent string remains unredacted

Automated span comparison against known PHI annotations; count true positives, false negatives

Safe Harbor PHI Precision

= 0.95 precision on redacted spans

More than 5% of redacted spans are not actual PHI (e.g., redacting generic clinical terms, measurement values, or common words)

Manual review of 50 randomly sampled redacted spans from the test run; classify each as true positive or false positive

Date Handling Accuracy

Dates with year-only preserved; dates with month+day redacted to year-only; no date elements missed

A date containing month or day remains unredacted, or a year-only date is incorrectly redacted

Regex extraction of all date-like strings from output; compare against expected Safe Harbor date rules

Structured Field Preservation

All non-PHI structured fields (lab values, vitals, medication dosages, procedure codes) remain unchanged

A lab result, vital sign, medication name, or procedure code is altered or redacted

Field-by-field diff between input and output for known non-PHI fields in the golden set

Redaction Consistency

Same PHI entity redacted identically across all occurrences in a single document

A patient name appears as [REDACTED] in one sentence but remains visible in another within the same output

Entity-level deduplication check: extract all redacted spans, verify each unique PHI entity has consistent treatment

Output Format Integrity

Output maintains original document structure (sections, paragraphs, line breaks); only PHI spans are replaced

Output is truncated, reordered, or restructured compared to input; markdown or formatting is corrupted

Structural diff: compare paragraph count, section headers, and line count between input and output

Re-identification Risk Score

No output allows re-identification when combined with public records (per expert determination standard)

A combination of remaining quasi-identifiers (ZIP+age+gender) could uniquely identify an individual in a known population

Apply k-anonymity check on remaining quasi-identifiers; flag outputs where k < 5 for any combination

Edge Case: De-identified Examples

Known de-identified examples in the golden set pass through unchanged (no false positive redaction)

A pre-existing [REDACTED] placeholder or synthetic PHI example is double-redacted or altered

Include 10 pre-deidentified documents in the golden set; verify output matches input exactly

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a small set of Safe Harbor identifiers. Start with names, dates, and MRNs before expanding to all 18 categories. Run against synthetic PHI records first.

code
[SYSTEM]
You are a PHI de-identification assistant. Redact only the following Safe Harbor identifiers from [INPUT_TEXT]:
- Patient names
- Dates (admission, discharge, birth)
- Medical record numbers (MRNs)

Replace each with [REDACTED]. Return the redacted text and a list of changes.

Watch for

  • Missing date formats (e.g., "the 5th of May" vs "05/05/2024")
  • MRNs embedded in free text without labels
  • Over-redaction of non-PHI dates like publication years
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.