{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/healthtensor/json-schema/healthtensor-patient-findings-response-schema.json",
  "title": "PatientFindingsResponse",
  "description": "Response body for the GET /outpatient/patient-findings endpoint.",
  "x-generated": "2026-12-03",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/healthtensor-openapi.json#/components/schemas/PatientFindingsResponse",
  "properties": {
    "regardPatientId": {
      "type": "string",
      "title": "Regardpatientid",
      "description": "The Regard patient ID"
    },
    "hccGroups": {
      "items": {
        "$ref": "#/$defs/HccGroup"
      },
      "type": "array",
      "title": "Hccgroups",
      "description": "All HCC groups discovered for the patient, with ICD-10 and finding detail"
    }
  },
  "type": "object",
  "required": [
    "regardPatientId",
    "hccGroups"
  ],
  "$defs": {
    "FindingDetail": {
      "properties": {
        "noteId": {
          "type": "string",
          "title": "Noteid",
          "description": "The FHIR note ID where this finding was discovered"
        },
        "quotes": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "title": "Quotes",
          "description": "Exact quote(s) from the note text that justify the ICD-10 code"
        },
        "meatQuotes": {
          "anyOf": [
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "title": "Meatquotes",
          "description": "Exact substring(s) from the note that specifically justify the MEAT score. Null for findings analyzed before this field was introduced."
        },
        "meatScore": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Meatscore",
          "description": "MEAT criteria count (0-4): how many of Monitor, Evaluate, Assess, Treat are documented. Null for findings analyzed before this field was introduced."
        }
      },
      "type": "object",
      "required": [
        "noteId",
        "quotes"
      ],
      "title": "FindingDetail",
      "description": "A single occurrence of an ICD-10 code found in a specific note."
    },
    "HccGroup": {
      "properties": {
        "hccCode": {
          "type": "string",
          "title": "Hcccode",
          "description": "The HCC code (e.g., '19')"
        },
        "hccName": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Hccname",
          "description": "Human-readable HCC category name (e.g., 'Diabetes without Complication'). Null when the HCC description mapping is not available."
        },
        "icd10S": {
          "items": {
            "$ref": "#/$defs/Icd10FindingsGroup"
          },
          "type": "array",
          "title": "Icd10S",
          "description": "Unique ICD-10 codes contributing to this HCC"
        }
      },
      "type": "object",
      "required": [
        "hccCode",
        "icd10S"
      ],
      "title": "HccGroup",
      "description": "An HCC code and all ICD-10 codes that support it across patient notes."
    },
    "Icd10FindingsGroup": {
      "properties": {
        "code": {
          "type": "string",
          "title": "Code",
          "description": "A valid ICD-10 code (e.g., 'E11.9')"
        },
        "description": {
          "type": "string",
          "title": "Description",
          "description": "English description of the condition"
        },
        "findings": {
          "items": {
            "$ref": "#/$defs/FindingDetail"
          },
          "type": "array",
          "title": "Findings",
          "description": "Each time this ICD-10 code was found in a note"
        },
        "confidence": {
          "anyOf": [
            {
              "type": "number",
              "maximum": 1.0,
              "minimum": 0.0
            },
            {
              "type": "null"
            }
          ],
          "title": "Confidence",
          "description": "Confidence score (0.0-1.0) from cross-note reconciliation. Null when reconciliation has not been run for this patient."
        },
        "defaultNoteId": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Defaultnoteid",
          "description": "The note ID to display by default for this ICD-10/HCC group. Selected by highest MEAT score, then most MEAT evidence quotes, then most recent note effective date."
        }
      },
      "type": "object",
      "required": [
        "code",
        "description",
        "findings"
      ],
      "title": "Icd10FindingsGroup",
      "description": "A unique ICD-10 code and all of its finding occurrences across patient notes."
    }
  }
}