Skip to content

feat(intelligence): implement policy matching for demo procedure #8

@rsalus

Description

@rsalus

Note for implementers: The design outlined here is a guideline, not a strict specification. Feel free to pivot from the suggested approach if you discover a better solution during implementation. Update the issue with your rationale when deviating significantly.

Summary

Match procedures to payer policies and load criteria for evidence extraction.

Context

  • Existing code: apps/intelligence/src/policies/example_policy.py defines the expected policy structure
  • Analyze endpoint: has hardcoded SUPPORTED_PROCEDURE_CODES but no policy loading
  • Gap: No mechanism to match (procedure_code, payer_id) to a specific policy

Dependencies

Issue Relationship
#5 Blocked by - need procedure/payer selection
#6, #7 Unblocks - policy criteria feed into LLM prompts

Policy Structure

{
    "policy_id": "string",
    "procedure_codes": ["CPT codes"],
    "criteria": [
        {
            "id": "criterion_id",
            "description": "Human-readable description",
            "evidence_patterns": ["regex patterns"],
            "required": bool
        }
    ],
    "form_field_mappings": {
        "pdf_field_name": "data_field_identifier"
    }
}

Tasks

Phase 1: Policy Module Infrastructure

  • Create PolicyRegistry class
  • Implement get_policy(procedure_code, payer_id) -> Policy | None
  • Add Policy Pydantic model

Phase 2: Integrate with Analyze Endpoint

  • Add optional payer_id to AnalyzeRequest
  • Replace hardcoded procedure codes with registry lookup
  • Pass loaded policy to evidence extraction

Phase 3: Demo Policy (after #5)

  • Create concrete policy for selected procedure/payer
  • Add unit tests

Files

File Action
apps/intelligence/src/policies/registry.py Create
apps/intelligence/src/policies/models.py Create
apps/intelligence/src/api/analyze.py Modify

Design References

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions