Overview
Add AWS Comprehend Medical as a Tier 3 PHI engine. It handles complex clinical narrative text (discharge summaries, clinical notes) where regex and Presidio miss entities embedded in natural language.
API
AWS Comprehend Medical DetectPHI:
import boto3
client = boto3.client("comprehendmedical")
result = client.detect_phi(Text="Patient John Smith...")
# Returns entities with Type, BeginOffset, EndOffset, Score
What to build
medguard/guardrails/phi.py — AWSComprehendPHIEngine class
- Implements
PHIEngineProtocol
- Maps AWS entity types to medguard
PHIMatch format
- Requires
pip install medguard[aws] (boto3 already in optional deps)
- Add
engine: "aws" option to PHIConfig
Entity type mapping
| AWS type |
medguard entity_type |
| NAME |
NAME |
| SSN |
SSN |
| DATE |
DOB |
| PHONE |
PHONE |
| EMAIL |
EMAIL |
| ID |
MRN |
| ADDRESS |
ADDRESS |
Files to modify
medguard/guardrails/phi.py — add AWSComprehendPHIEngine
medguard/config.py — add aws to PHIConfig.engine Literal
tests/test_phi.py — add tests with mocked boto3
Acceptance criteria
Overview
Add AWS Comprehend Medical as a Tier 3 PHI engine. It handles complex clinical narrative text (discharge summaries, clinical notes) where regex and Presidio miss entities embedded in natural language.
API
AWS Comprehend Medical DetectPHI:
What to build
medguard/guardrails/phi.py—AWSComprehendPHIEngineclassPHIEngineProtocolPHIMatchformatpip install medguard[aws](boto3 already in optional deps)engine: "aws"option toPHIConfigEntity type mapping
Files to modify
medguard/guardrails/phi.py— addAWSComprehendPHIEnginemedguard/config.py— addawstoPHIConfig.engineLiteraltests/test_phi.py— add tests with mocked boto3Acceptance criteria
AWSComprehendPHIEngine.analyze(text)returns correctPHIMatchlistImportErrorwith helpful message when boto3 not installed