0PricingLogin
AI Prompt Engineering · Lesson

Medical and Clinical Prompting

Clinical note summarization, ICD coding prompts, HIPAA-safe patterns.

Medical Prompting Constraints

Medical AI prompting operates under strict constraints: HIPAA compliance, patient safety guardrails, clinical accuracy, and mandatory 'consult a doctor' disclaimers. Unlike general-purpose prompting, errors here can cause patient harm.

HIPAA-Safe Prompt Patterns

HIPAA-safe prompting means: no PHI (Protected Health Information) in prompts sent to third-party APIs without a signed BAA, de-identification before transmission, and no storage of patient-identifiable outputs in non-compliant systems.

import re

# De-identification before sending to LLM API
# (HIPAA Safe Harbor method: remove 18 identifiers)
def deidentify(text):
    # Remove common name patterns (simplified example)
    text = re.sub(r'\b(?:Patient|patient):\s*[A-Z][a-z]+ [A-Z][a-z]+', 
                  'Patient: [REDACTED]', text)
    # Remove date of birth
    text = re.sub(r'\bDOB:\s*\d{2}/\d{2}/\d{4}', 'DOB: [REDACTED]', text)
    # Remove SSN
    text = re.sub(r'\b\d{3}-\d{2}-\d{4}\b', '[SSN REDACTED]', text)
    # Remove phone numbers
    text = re.sub(r'\b\d{3}[-.]\d{3}[-.]\d{4}\b', '[PHONE REDACTED]', text)
    # Remove MRN (Medical Record Number)
    text = re.sub(r'\bMRN:\s*\d+', 'MRN: [REDACTED]', text)
    return text

sample = 'Patient: John Smith, DOB: 03/15/1980, MRN: 1234567'
print(deidentify(sample))
# Output: Patient: [REDACTED], DOB: [REDACTED], MRN: [REDACTED]

All lessons in this course

  1. Legal Domain Prompt Patterns
  2. Medical and Clinical Prompting
  3. Financial and Quantitative Prompts
  4. Domain Glossary and Ontology Injection
← Back to AI Prompt Engineering