liveBook · Manning

HIPAA

As explained in Building Reliable AI Systems

The Health Insurance Portability and Accountability Act is a United States federal law that includes requirements for protecting health information.

HIPAA is a U.S. federal law that sets requirements for protecting patient health information. It applies to health-care providers, health plans, clearinghouses, and companies handling protected information on their behalf. LLM systems processing health-care data may therefore need to meet HIPAA requirements. section 11.5.3

HIPAA’s safe-harbor method requires removing 18 types of identifiers from health information.

  • Identifiers include names, addresses, dates other than year, phone numbers, email addresses, medical-record numbers, account numbers, and unique identifying characteristics. section 11.5.3
  • People older than 89 must be aggregated into a single age category. section 11.5.3
  • HIPAA compliance for LLMs also raises unresolved questions about training, inference, and data retention; some organizations require explicit consent and avoid training on health data. section 11.5.3
class HIPAADeIdentifier:
    # Requires: import re; from typing import Dict
    def __init__(self):

        self.safe_harbor_patterns = {   #1
            'names': r'\b[A-Z][a-z]+\s+[A-Z][a-z]+\b',
            'dates': r'\b\d{1,2}/\d{1,2}/\d{4}\b',
            'phone': r'\b\d{3}-\d{3}-\d{4}\b',
            'email': r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b',
            'mrn': r'\bMRN:?\s*\d{6,10}\b',
            'address': r'\b\d+\s+[A-Za-z\s]+(?:Street|St|Avenue|Ave)\b'
        }


        self.age_over_89 = 
            r'\b(?:9[0-9]|[1-9]\d{2,})\s*(?:years?\s*old|y/?o)\b'    #2

    def de_identify_medical_text(self, text: str) -> Dict:

        de_identified = text    #3
        removed_elements = []    #3

        for identifier_type, pattern in self.safe_harbor_patterns.items():    #4
            matches = re.findall(pattern, de_identified, re.IGNORECASE)
            if matches:
                removed_elements.append(f"{identifier_type}: {len(matches)}")
                de_identified = re.sub(
                    pattern, 
                    f'[{identifier_type.upper()}_REMOVED]', 
                    de_identified, 
                    flags=re.IGNORECASE
                )

        if re.search(self.age_over_89, de_identified, re.IGNORECASE):    #5
            de_identified = re.sub(self.age_over_89, 
                '[AGE_>89_REMOVED]', de_identified)
            removed_elements.append("ages_over_89: 1")

        return {
            'de_identified_text': de_identified,
            'removed_elements': removed_elements,
            'safe_harbor_compliant': True
        }

See a regex-based text de-identification sketch covering examples such as names, dates, phone numbers, email addresses, medical-record numbers, addresses, and ages over 89. These patterns illustrate an implementation approach, not all 18 identifier categories. section 11.5.3

How Building Reliable AI Systems covers it

How deep it goes
Defines covered entities and safe-harbor identifiers, then notes that LLM rules for training, inference, and retention remain evolving.
Examples
Uses regex patterns for common identifiers and an age-over-89 rule to illustrate medical-text de-identification.
What you can do after
Apply example regex patterns to identify common personal identifiers in medical text, while recognizing that the sketch does not cover every safe-harbor identifier.
How it connects
Connects de-identification and protected health information with LLM training, inference, and data retention.

Also explained in

Compare how 4 books explain HIPAA →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building Reliable AI Systems. The section links point to the parts of the book it draws on.