"""Shared test fixtures for claim-validator."""

from __future__ import annotations

from typing import Any

import pytest

from claim_validator.models.claim import ClaimData, ClaimLineData, DiagnosisCode


def build_claim_unchecked(**kwargs: Any) -> ClaimData:
    """Build a ClaimData without Pydantic validators (for testing invalid data).

    Nested ``diagnosis_codes`` and ``lines`` dicts are converted to their
    respective model instances via ``model_construct`` so attribute access
    works, but no field/model validators fire.
    """
    if "diagnosis_codes" in kwargs:
        kwargs["diagnosis_codes"] = [
            DiagnosisCode.model_construct(**dx) if isinstance(dx, dict) else dx
            for dx in kwargs["diagnosis_codes"]
        ]
    if "lines" in kwargs:
        kwargs["lines"] = [
            ClaimLineData.model_construct(**ln) if isinstance(ln, dict) else ln
            for ln in kwargs["lines"]
        ]
    return ClaimData.model_construct(**kwargs)


@pytest.fixture
def valid_claim_dict() -> dict[str, Any]:
    """Minimal valid claim dictionary for testing."""
    return {
        "billing_provider_npi": "1234567893",
        "subscriber_id": "XYZ123456",
        "diagnosis_codes": [
            {"code": "J06.9", "pointer": 1},
        ],
        "lines": [
            {
                "procedure_code": "99213",
                "diagnosis_pointers": [1],
                "charge_amount": 150.00,
            },
        ],
    }
