{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/backworkhealth-com/json-schema/backworkhealth-com-code-lookup-data-schema.json",
  "title": "CodeLookupData",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/backworkhealth-com-codes-api-openapi.yml#/components/schemas/CodeLookupData",
  "type": "object",
  "properties": {
    "code": {
      "type": "string"
    },
    "code_system": {
      "type": "string",
      "description": "CPT, HCPCS, ICD10CM, ICD10PCS, NDC, or UNKNOWN when the code was not resolved"
    },
    "found": {
      "type": "boolean"
    },
    "description": {
      "type": [
        "string",
        "null"
      ]
    },
    "short_description": {
      "type": [
        "string",
        "null"
      ]
    },
    "category": {
      "type": [
        "string",
        "null"
      ]
    },
    "betos_code": {
      "type": [
        "string",
        "null"
      ]
    },
    "poa_exempt": {
      "type": [
        "boolean",
        "null"
      ]
    },
    "is_active": {
      "type": [
        "boolean",
        "null"
      ]
    },
    "rvu": {
      "anyOf": [
        {
          "$ref": "#/$defs/RvuData"
        },
        {
          "type": "null"
        }
      ]
    },
    "negotiated_rates": {
      "anyOf": [
        {
          "$ref": "#/$defs/NegotiatedRateSummary"
        },
        {
          "type": "null"
        }
      ]
    },
    "policies": {
      "description": "Included when include=policies",
      "type": "array",
      "items": {
        "$ref": "#/$defs/CodePolicyMatch"
      }
    },
    "suggestions": {
      "description": "Fuzzy match suggestions when exact match not found",
      "type": "array",
      "items": {
        "$ref": "#/$defs/CodeSuggestion"
      }
    },
    "ndc_crosswalk": {
      "$ref": "#/$defs/NdcCrosswalk"
    }
  },
  "required": [
    "code",
    "code_system",
    "found",
    "description"
  ],
  "$defs": {
    "CodeGrounding": {
      "type": "string",
      "enum": [
        "grounded",
        "not_grounded",
        "no_source_text",
        "not_checked"
      ],
      "description": "Whether Backwork found this code in the source text it retained for the policy. grounded: found in the retained source text. not_grounded: Backwork's document pipeline read the code, but it is not in the retained source text. no_source_text: Backwork retained no source text to check. not_checked: not checked; always the value for codes inferred from the policy title."
    },
    "CodePolicyMatch": {
      "type": "object",
      "properties": {
        "policy_id": {
          "type": "string"
        },
        "title": {
          "type": "string"
        },
        "policy_type": {
          "type": "string"
        },
        "disposition": {
          "type": "string"
        },
        "source": {
          "$ref": "#/$defs/CodeSource"
        },
        "grounding": {
          "$ref": "#/$defs/CodeGrounding"
        },
        "jurisdiction": {
          "type": [
            "string",
            "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"
          ]
        },
        "effective_date": {
          "type": [
            "string",
            "null"
          ]
        },
        "source_url": {
          "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",
        "disposition",
        "source",
        "grounding",
        "jurisdiction",
        "effective_date",
        "source_url",
        "public_url",
        "source_check"
      ]
    },
    "CodeSource": {
      "type": "string",
      "enum": [
        "document",
        "inferred_title_match"
      ],
      "description": "document: listed in the payer's policy document. inferred_title_match: attached because the policy title names the drug; the document itself does not list the code."
    },
    "CodeSuggestion": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string"
        },
        "code_system": {
          "type": "string"
        },
        "description": {
          "type": [
            "string",
            "null"
          ]
        },
        "score": {
          "type": "number"
        },
        "match_type": {
          "type": "string",
          "enum": [
            "code",
            "description"
          ]
        }
      },
      "required": [
        "code",
        "code_system",
        "description",
        "score",
        "match_type"
      ]
    },
    "NdcCrosswalk": {
      "type": "object",
      "properties": {
        "ndc": {
          "type": "string"
        },
        "hcpcs_code": {
          "type": "string"
        },
        "hcpcs_description": {
          "type": [
            "string",
            "null"
          ]
        },
        "ndc_label": {
          "type": [
            "string",
            "null"
          ]
        },
        "route": {
          "type": [
            "string",
            "null"
          ]
        },
        "billing_units": {
          "type": [
            "string",
            "null"
          ]
        },
        "conversion_factor": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "ndc",
        "hcpcs_code",
        "hcpcs_description",
        "ndc_label",
        "route",
        "billing_units",
        "conversion_factor"
      ],
      "description": "NDC to HCPCS mapping (for NDC lookups)"
    },
    "NegotiatedRateSummary": {
      "type": "object",
      "properties": {
        "min_rate": {
          "type": "string",
          "description": "Lowest negotiated rate across all providers in the snapshot"
        },
        "max_rate": {
          "type": "string",
          "description": "Highest negotiated rate across all providers in the snapshot"
        },
        "avg_rate": {
          "type": "string",
          "description": "Average negotiated rate across all providers in the snapshot"
        },
        "num_rates": {
          "type": "integer",
          "description": "Number of negotiated rate records in the snapshot"
        },
        "payer": {
          "type": "string",
          "description": "Reporting payer entity name"
        },
        "arrangement": {
          "description": "Negotiation arrangement type (ffs, bundle, capitation)",
          "type": [
            "string",
            "null"
          ]
        },
        "source": {
          "type": "string",
          "description": "Upstream dataset the rates were ingested from"
        },
        "payer_scope": {
          "type": "string",
          "description": "Payer coverage of the snapshot. These rates represent a single payer, not the commercial market."
        },
        "as_of": {
          "type": "string",
          "description": "Snapshot vintage (YYYY-MM)"
        },
        "billing_code_set": {
          "type": "string",
          "description": "Code set version the rates were published against"
        },
        "is_current": {
          "type": "boolean",
          "description": "True only for a hash-bound snapshot no more than 35 days old"
        }
      },
      "required": [
        "min_rate",
        "max_rate",
        "avg_rate",
        "num_rates",
        "payer",
        "arrangement",
        "source",
        "payer_scope",
        "as_of",
        "billing_code_set",
        "is_current"
      ],
      "description": "HISTORICAL BENCHMARK - NOT CURRENT PRICING. Commercial negotiated rate summary drawn from a Transparency in Coverage machine-readable file snapshot. Check `as_of`, `payer_scope`, and `is_current` before use; verify current rates directly with the payer. Include \"rates\" in the include parameter to receive this field."
    },
    "RvuData": {
      "type": "object",
      "properties": {
        "work_rvu": {
          "type": [
            "string",
            "null"
          ]
        },
        "pe_rvu_nonfacility": {
          "type": [
            "string",
            "null"
          ]
        },
        "pe_rvu_facility": {
          "type": [
            "string",
            "null"
          ]
        },
        "mp_rvu": {
          "type": [
            "string",
            "null"
          ]
        },
        "total_rvu_nonfacility": {
          "type": [
            "string",
            "null"
          ]
        },
        "total_rvu_facility": {
          "type": [
            "string",
            "null"
          ]
        },
        "non_facility_price": {
          "type": [
            "string",
            "null"
          ]
        },
        "facility_price": {
          "type": [
            "string",
            "null"
          ]
        },
        "conversion_factor": {
          "type": [
            "string",
            "null"
          ]
        },
        "global_days": {
          "type": [
            "string",
            "null"
          ]
        },
        "status_code": {
          "type": [
            "string",
            "null"
          ]
        },
        "year": {
          "type": "integer"
        }
      },
      "required": [
        "work_rvu",
        "pe_rvu_nonfacility",
        "pe_rvu_facility",
        "mp_rvu",
        "total_rvu_nonfacility",
        "total_rvu_facility",
        "non_facility_price",
        "facility_price",
        "conversion_factor",
        "global_days",
        "status_code",
        "year"
      ],
      "description": "Medicare fee-schedule RVUs and prices; included when include=rvu"
    },
    "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."
    }
  }
}