Skip to content

AWS Comprehend Medical PHI engine (Tier 3) #7

Description

@sarvanithin

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

  • AWSComprehendPHIEngine.analyze(text) returns correct PHIMatch list
  • Graceful ImportError with helpful message when boto3 not installed
  • boto3 mocked in tests (no real AWS calls)
  • All existing PHI tests still pass

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions