Skip to content

feat(analyzer): Add Healthcare identifiers recognizer#2159

Open
bhargavikalicheti wants to merge 2 commits into
data-privacy-stack:mainfrom
bhargavikalicheti:feature/us-healthcare-recognizer
Open

feat(analyzer): Add Healthcare identifiers recognizer#2159
bhargavikalicheti wants to merge 2 commits into
data-privacy-stack:mainfrom
bhargavikalicheti:feature/us-healthcare-recognizer

Conversation

@bhargavikalicheti

Copy link
Copy Markdown

Change Description

Adds conservative, context-aware US healthcare identifier recognizers to Presidio Analyzer.

New disabled-by-default recognizers:

  • US_HEALTH_INSURANCE_MEMBER_ID
  • US_PRIOR_AUTHORIZATION_NUMBER
  • US_CLAIM_NUMBER
  • US_PRESCRIPTION_NUMBER
  • US_REFERRAL_NUMBER
  • US_PROVIDER_TAX_ID

These recognizers require both a plausible identifier pattern and nearby healthcare/insurance workflow context to reduce false positives. They also include negative-context checks for similar-looking non-healthcare IDs such as order numbers, tracking numbers, case numbers and invoice numbers where applicable.

Issue reference

Fixes Feature Request: Healthcare Recognizer for Common Healthcare Identifiers (Member ID, Claims, Prior Authorization, etc.)
#2136

Checklist

  • I have reviewed the contribution guidelines
  • I agree to follow this project's Code of Conduct
  • I confirm that I have the right to submit this contribution and that it does not knowingly contain proprietary or confidential code.
  • My code includes unit tests
  • All unit tests and lint checks pass locally
  • My PR contains documentation updates / additions if required

@bhargavikalicheti

Copy link
Copy Markdown
Author

Hi @SharonHart @omri374 , No rush - gentle reminder on PR whenever you get a chance. Thank you!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a set of conservative, disabled-by-default US healthcare identifier recognizers to Presidio Analyzer, aiming to detect common healthcare administrative IDs only when appropriate workflow context is present (to reduce false positives in general alphanumeric/ID-like text).

Changes:

  • Introduces new US healthcare admin ID recognizers (claim, prior auth, prescription, referral, provider tax ID) plus a health insurance member ID recognizer, all requiring nearby context.
  • Wires the new recognizers into predefined recognizer exports and default registry YAML (disabled by default).
  • Adds unit tests, supported-entities documentation entries, and changelog notes for the new entities/recognizers.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
presidio-analyzer/tests/test_us_healthcare_admin_recognizers.py New tests for healthcare admin ID recognizers (positive/negative context + metadata).
presidio-analyzer/tests/test_us_health_insurance_member_id_recognizer.py New tests for health insurance member ID recognizer detection behavior and metadata.
presidio-analyzer/presidio_analyzer/predefined_recognizers/country_specific/us/us_healthcare_admin_recognizers.py Adds context-required pattern recognizer base + concrete admin ID recognizers.
presidio-analyzer/presidio_analyzer/predefined_recognizers/country_specific/us/us_health_insurance_member_id_recognizer.py Adds context-required member/subscriber ID recognizer with negative-context pruning.
presidio-analyzer/presidio_analyzer/predefined_recognizers/country_specific/us/init.py Exports the new US healthcare recognizers from the US package.
presidio-analyzer/presidio_analyzer/predefined_recognizers/init.py Exposes the new recognizers via the top-level predefined_recognizers import surface.
presidio-analyzer/presidio_analyzer/conf/default_recognizers.yaml Registers the recognizers as predefined + disabled-by-default with country_code: us.
docs/supported_entities.md Documents the new supported entity types and brief descriptions.
CHANGELOG.md Notes new analyzer recognizers under Unreleased.

Comment on lines +46 to +50
def __has_required_context(self, text: str, result: RecognizerResult) -> bool:
window_text = self.__get_context_window(text, result).lower()
if any(context in window_text for context in self.NEGATIVE_CONTEXT):
return False
return any(context in window_text for context in self.context)
Comment on lines +96 to +100
def __has_required_context(self, text: str, result: RecognizerResult) -> bool:
window_text = self.__get_context_window(text, result).lower()
if any(context in window_text for context in self.NEGATIVE_CONTEXT):
return False
return any(context in window_text for context in self.context)

@omri374 omri374 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Please add references to be able to trace where the regex pattern is coming from, and see the comment around context management.

COUNTRY_CODE = "us"

PATTERNS = [
Pattern(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a reference to the sources of the logic/patterns

from presidio_analyzer import Pattern, PatternRecognizer, RecognizerResult


class _ContextRequiredPatternRecognizer(PatternRecognizer):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not handle this through the threshold mechanism? We recently added recognizer and entity specific thresholds, so filtering entities if they didn't meet the bar without context can be handled this way. Moreover, in some cases we do want to identify these entities without context (e.g. in the presidio-structured package, where we count how many out of the records in a column were identified as X)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants