feat(analyzer): Add Healthcare identifiers recognizer#2159
feat(analyzer): Add Healthcare identifiers recognizer#2159bhargavikalicheti wants to merge 2 commits into
Conversation
|
Hi @SharonHart @omri374 , No rush - gentle reminder on PR whenever you get a chance. Thank you! |
There was a problem hiding this comment.
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. |
| 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) |
| 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
left a comment
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
Please add a reference to the sources of the logic/patterns
| from presidio_analyzer import Pattern, PatternRecognizer, RecognizerResult | ||
|
|
||
|
|
||
| class _ContextRequiredPatternRecognizer(PatternRecognizer): |
There was a problem hiding this comment.
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)
Change Description
Adds conservative, context-aware US healthcare identifier recognizers to Presidio Analyzer.
New disabled-by-default recognizers:
US_HEALTH_INSURANCE_MEMBER_IDUS_PRIOR_AUTHORIZATION_NUMBERUS_CLAIM_NUMBERUS_PRESCRIPTION_NUMBERUS_REFERRAL_NUMBERUS_PROVIDER_TAX_IDThese 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