{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://any.health/contracts/coverage.state/1/response.schema.json",
  "title": "Coverage State draft family response",
  "description": "Draft response shape published for design discussion. No executable binding or compatibility promise is represented.",
  "x-any-maturity": "draft",
  "x-any-scope": "family",
  "type": "object",
  "required": ["contract", "operation", "request_id", "status", "effective_at", "observed_at", "result", "evidence", "provenance", "issues"],
  "properties": {
    "contract": { "const": "any/coverage.state@1" },
    "operation": { "const": "coverage.resolve" },
    "request_id": { "type": "string", "minLength": 1 },
    "status": { "enum": ["resolved", "partial", "unresolved", "failed"] },
    "effective_at": { "type": "string", "format": "date-time" },
    "observed_at": { "type": "string", "format": "date-time" },
    "result": {
      "type": "object",
      "required": ["subject", "relationships", "coverages", "benefits", "accumulators", "network_routes", "determinations"],
      "properties": {
        "subject": {
          "type": "object",
          "required": ["person_ref", "member_refs"],
          "properties": {
            "person_ref": { "type": "string" },
            "member_refs": { "type": "array", "items": { "type": "string" } }
          },
          "additionalProperties": true
        },
        "relationships": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["subject_ref", "related_ref", "role"],
            "properties": {
              "relationship_ref": { "type": "string" },
              "subject_ref": { "type": "string" },
              "related_ref": { "type": "string" },
              "role": { "enum": ["self", "subscriber", "dependent", "spouse", "child", "employee", "other"] },
              "effective_period": { "type": "object" }
            },
            "additionalProperties": true
          }
        },
        "coverages": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["coverage_ref", "member_ref", "coordination_role", "administrative_status", "funding"],
            "properties": {
              "coverage_ref": { "type": "string" },
              "member_ref": { "type": "string" },
              "subscriber_ref": { "type": ["string", "null"] },
              "coordination_role": { "enum": ["primary", "secondary", "supplemental", "unknown"] },
              "administrative_status": { "enum": ["active", "inactive", "pending", "terminated", "unknown", "conflicting"] },
              "effective_period": { "type": "object" },
              "plan_ref": { "type": ["string", "null"] },
              "group_ref": { "type": ["string", "null"] },
              "plan_sponsor_ref": { "type": ["string", "null"] },
              "administrator_ref": { "type": ["string", "null"] },
              "payer_ref": { "type": ["string", "null"] },
              "funding": { "enum": ["self_funded", "fully_insured", "other", "unknown"] },
              "network_refs": { "type": "array", "items": { "type": "string" } }
            },
            "additionalProperties": true
          }
        },
        "benefits": { "type": "array", "items": { "type": "object" } },
        "accumulators": { "type": "array", "items": { "type": "object" } },
        "network_routes": { "type": "array", "items": { "type": "object" } },
        "determinations": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["type", "state", "evidence_refs"],
            "properties": {
              "type": { "enum": ["eligibility", "benefit", "network_route", "cost_context", "member_service", "payment_review_context", "gap_analysis"] },
              "state": { "enum": ["known", "unknown", "conflicting", "not_applicable"] },
              "value": { "type": ["object", "null"] },
              "evidence_refs": { "type": "array", "items": { "type": "string" } },
              "reason_codes": { "type": "array", "items": { "type": "string" } }
            },
            "additionalProperties": true
          }
        }
      },
      "additionalProperties": true
    },
    "evidence": { "type": "array", "items": { "type": "object" } },
    "provenance": { "type": "array", "items": { "type": "object" } },
    "issues": { "type": "array", "items": { "type": "object" } }
  },
  "additionalProperties": true
}
