{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/backworkhealth-com/json-schema/backworkhealth-com-criteria-search-result-schema.json",
  "title": "CriteriaSearchResult",
  "x-generated": "2026-11-02",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/backworkhealth-com-v1-openapi.json#/components/schemas/CriteriaSearchResult",
  "type": "object",
  "properties": {
    "criteria_id": {
      "type": "string",
      "description": "Criteria block identifier within its policy"
    },
    "policy_id": {
      "type": "string",
      "description": "Policy ID repeated at the top level for easy result scanning."
    },
    "policy_title": {
      "type": "string",
      "description": "Policy title repeated at the top level for easy result scanning."
    },
    "policy_type": {
      "type": "string"
    },
    "jurisdiction": {
      "type": [
        "string",
        "null"
      ]
    },
    "effective_date": {
      "anyOf": [
        {
          "type": "string",
          "format": "date"
        },
        {
          "type": "null"
        }
      ]
    },
    "section": {
      "type": "string",
      "description": "Criteria section: indications, limitations, documentation, frequency, or other"
    },
    "text": {
      "type": "string",
      "description": "Criteria text, truncated for licensing"
    },
    "tags": {
      "anyOf": [
        {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        {
          "type": "null"
        }
      ]
    },
    "requires_manual_review": {
      "type": [
        "boolean",
        "null"
      ]
    },
    "confidence_score": {
      "description": "Extraction confidence as a decimal string (e.g. \"0.92\")",
      "type": [
        "string",
        "null"
      ]
    },
    "policy": {
      "type": "object",
      "properties": {
        "policy_id": {
          "type": "string"
        },
        "title": {
          "type": "string"
        },
        "policy_type": {
          "type": "string"
        },
        "jurisdiction": {
          "type": [
            "string",
            "null"
          ]
        },
        "effective_date": {
          "anyOf": [
            {
              "type": "string",
              "format": "date"
            },
            {
              "type": "null"
            }
          ]
        },
        "applicability_scope": {
          "type": "string",
          "enum": [
            "shared_markets",
            "document_scoped"
          ]
        },
        "applicability_markets": {
          "description": "Markets whose publisher indexes list this exact document",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "applicability_evidence": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "document_sha256": {
                  "type": "string",
                  "pattern": "^[0-9a-f]{64}$"
                },
                "market_index_listings": {
                  "maxItems": 16,
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "market": {
                        "type": "string",
                        "pattern": "^[A-Z]{2}$"
                      },
                      "index_url": {
                        "type": "string",
                        "maxLength": 2048,
                        "pattern": "^https:\\/\\/"
                      }
                    },
                    "required": [
                      "market",
                      "index_url"
                    ]
                  }
                },
                "document_statements": {
                  "maxItems": 16,
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "enum": [
                          "non_medicare_disclaimer",
                          "commercial_policy_header",
                          "member_type_branch"
                        ]
                      },
                      "quote": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 4000
                      },
                      "page": {
                        "type": "integer",
                        "exclusiveMinimum": 0
                      }
                    },
                    "required": [
                      "kind",
                      "quote",
                      "page"
                    ]
                  }
                }
              },
              "required": [
                "document_sha256",
                "market_index_listings",
                "document_statements"
              ]
            },
            {
              "type": "null"
            }
          ]
        },
        "applicability_note": {
          "description": "Explanation when shared or unscoped evidence does not establish a member's plan applicability",
          "type": [
            "string",
            "null"
          ]
        },
        "public_url": {
          "anyOf": [
            {
              "type": "string",
              "format": "uri"
            },
            {
              "type": "null"
            }
          ],
          "description": "Backwork's public page for this policy, or null when it has none. Active Medicare LCDs, Articles and NCDs: `https://backworkhealth.com/policy/{policy_id}`. Active commercial policies: `https://backworkhealth.com/policy/payer/{payer_slug}/{policy_id}`. A retired commercial policy points to its active successor's page when one is known."
        },
        "source_check": {
          "anyOf": [
            {
              "$ref": "#/$defs/SourceCheck"
            },
            {
              "type": "null"
            }
          ],
          "description": "Source provenance for this policy; null only when the policy is no longer on record."
        }
      },
      "required": [
        "policy_id",
        "title",
        "policy_type",
        "jurisdiction",
        "effective_date",
        "public_url",
        "source_check"
      ]
    },
    "applicability_scope": {
      "type": "string",
      "enum": [
        "shared_markets",
        "document_scoped"
      ]
    },
    "applicability_markets": {
      "description": "Markets whose publisher indexes list this exact document",
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "applicability_evidence": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "document_sha256": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "market_index_listings": {
              "maxItems": 16,
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "market": {
                    "type": "string",
                    "pattern": "^[A-Z]{2}$"
                  },
                  "index_url": {
                    "type": "string",
                    "maxLength": 2048,
                    "pattern": "^https:\\/\\/"
                  }
                },
                "required": [
                  "market",
                  "index_url"
                ]
              }
            },
            "document_statements": {
              "maxItems": 16,
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "non_medicare_disclaimer",
                      "commercial_policy_header",
                      "member_type_branch"
                    ]
                  },
                  "quote": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 4000
                  },
                  "page": {
                    "type": "integer",
                    "exclusiveMinimum": 0
                  }
                },
                "required": [
                  "kind",
                  "quote",
                  "page"
                ]
              }
            }
          },
          "required": [
            "document_sha256",
            "market_index_listings",
            "document_statements"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "applicability_note": {
      "description": "Explanation when shared or unscoped evidence does not establish a member's plan applicability",
      "type": [
        "string",
        "null"
      ]
    }
  },
  "required": [
    "criteria_id",
    "policy_id",
    "policy_title",
    "policy_type",
    "jurisdiction",
    "effective_date",
    "section",
    "text",
    "tags",
    "requires_manual_review",
    "confidence_score",
    "policy"
  ],
  "$defs": {
    "SourceAccuracy": {
      "type": "object",
      "properties": {
        "field": {
          "type": "string",
          "enum": [
            "overall",
            "title",
            "effective_date",
            "codes",
            "link"
          ],
          "description": "What the audit measured: `overall` for the policy record as a whole, or one field of it (`title`, `effective_date`, `codes`, `link`)."
        },
        "sampled_at": {
          "type": "string",
          "format": "date-time",
          "description": "When the audit drew its sample."
        },
        "sample_size": {
          "type": "integer",
          "exclusiveMinimum": 0,
          "description": "How many of this source's policy records the audit sampled."
        },
        "accuracy": {
          "type": "number",
          "minimum": 0,
          "maximum": 1,
          "description": "Share of the sampled records whose `field` matched the source document, from 0 to 1: the records that matched divided by `sample_size`."
        },
        "ci_low": {
          "type": "number",
          "minimum": 0,
          "maximum": 1,
          "description": "Lower bound of the 95% Wilson score confidence interval for `accuracy`."
        },
        "ci_high": {
          "type": "number",
          "minimum": 0,
          "maximum": 1,
          "description": "Upper bound of the 95% Wilson score confidence interval for `accuracy`."
        },
        "method": {
          "type": "string",
          "description": "How the audit decided whether a sampled record matched its source, as Backwork names the method."
        }
      },
      "required": [
        "field",
        "sampled_at",
        "sample_size",
        "accuracy",
        "ci_low",
        "ci_high",
        "method"
      ],
      "description": "The most recent audit of one field for the policy's source. It measures a sample of the source's policy records, not this policy alone."
    },
    "SourceCheck": {
      "type": "object",
      "properties": {
        "source_url": {
          "type": "string",
          "description": "The URL Backwork fetches this policy from."
        },
        "last_fetched_at": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time"
            },
            {
              "type": "null"
            }
          ],
          "description": "When Backwork last fetched the policy from `source_url`; null when no fetch time is recorded. The payer may have changed the document since."
        },
        "content_sha256": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            {
              "type": "null"
            }
          ],
          "description": "SHA-256 of the content Backwork fetched, as 64 lowercase hex characters; null when the loader did not record one. Compare it across responses to see whether the fetched content changed."
        },
        "source_accuracy": {
          "anyOf": [
            {
              "type": "array",
              "items": {
                "$ref": "#/$defs/SourceAccuracy"
              }
            },
            {
              "type": "null"
            }
          ],
          "description": "The latest audit for each field Backwork has audited for this policy's source, `overall` first. null when the policy has no recorded source or its source has no audit yet."
        }
      },
      "required": [
        "source_url",
        "last_fetched_at",
        "content_sha256",
        "source_accuracy"
      ],
      "description": "Where and when Backwork last fetched this policy, a hash of the fetched content, and the sampled accuracy that audits measured for its source."
    }
  }
}