Skip to content

Conversation

@nickls
Copy link
Contributor

@nickls nickls commented Jul 28, 2025

Summary

Adds support for enriched insurance card data extracted by the GeminiDataEnrichmentProcessor in the cardscan-infrastructure backend.

Changes Made

  • Added enriched_results field to CardApiResponse schema to expose AI-extracted data
  • Created new schemas that match GeminiDataEnrichmentProcessor output format:
    • EnrichedAddressResultInner: includes label, type, company_name, address, score
    • EnrichedPhoneNumberResultInner: includes label, type, number, score
    • EnrichedCopayResultInner: includes service, category, value (number), score
  • Removed legacy schemas from details field: AddressResult, PhoneNumberResult, CopayResult
  • Added processed_sides indicator showing which card sides were processed (front_only, both)

Background

The backend GeminiDataEnrichmentProcessor extracts structured data from insurance cards using AI and stores it in CardModel.enrichment_results. This data gets exposed via CardModel.to_summary() as enriched_results but was missing from the OpenAPI specification.

Data Structure Differences

The new enriched schemas have important differences from the legacy OCR-based schemas:

  • Single score (string) vs multiple scores (array)
  • Structured address data with separate company_name and address fields
  • Phone numbers as number field vs value field
  • Numeric copay values vs string values
  • Field name: copays_deductibles vs copays

Testing

  • Verify OpenAPI spec validates correctly
  • Test client generation for all languages
  • Confirm enriched data appears in API responses when feature flag is enabled

🤖 Generated with Claude Code

- Add enriched_results field to CardApiResponse with AI-extracted data structure
- Create EnrichedAddressResultInner, EnrichedPhoneNumberResultInner, EnrichedCopayResultInner schemas
- Remove legacy AddressResult, PhoneNumberResult, CopayResult schemas from details field
- New schemas match GeminiDataEnrichmentProcessor output format with proper field names:
  * addresses: label, type, company_name, address, score
  * phone_numbers: label, type, number, score
  * copays_deductibles: service, category, value (number), score
- Enriched data includes processed_sides indicator (front_only, both)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@nickls nickls merged commit f19859e into main Jul 28, 2025
34 checks passed
@nickls nickls deleted the add-enriched-results-schema branch July 28, 2025 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants