Skip to content

feat(intelligence): wire analysis endpoint with all components #9

@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

Connect policy matching, evidence extraction, and form generation in the /analyze endpoint.

Context

The current implementation is a stub that returns hardcoded values. This issue wires together all components:

Request → validate → load_policy → extract_evidence → generate_form_data → Response
                           ↓                 ↓                  ↓
                      [#8 policy]      [#6 evidence]      [#7 form gen]

Dependencies

Issue Relationship
#6 Blocked by - needs evidence extraction
#7 Blocked by - needs form generation
#8 Blocked by - needs policy matching

Tasks

Core Wiring

  • Import and call get_policy() based on procedure_code
  • Call extract_evidence(bundle, policy)
  • Call generate_form_data(bundle, evidence, policy)
  • Remove stub response building

Document Processing

  • Call pdf_parser.parse_pdf() for documents
  • Pass extracted text to ClinicalBundle.document_texts

Testing

  • Integration tests with mock clinical data
  • Test error handling for missing policy

Current vs Target

Current (stub):

return PAFormResponse(recommendation="APPROVE", confidence_score=1.0, ...)

Target:

policy = get_policy(request.procedure_code)
evidence = await extract_evidence(bundle, policy)
return await generate_form_data(bundle, evidence, policy)

Files

File Action
apps/intelligence/src/api/analyze.py Modify
apps/intelligence/tests/api/test_analyze.py Modify

Design Reference

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