{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/hmcts/json-schema/hmcts-case-view-schema.json",
  "title": "CaseView",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/hmcts-caseworkers-api-openapi.yml#/components/schemas/CaseView",
  "type": "object",
  "properties": {
    "case_id": {
      "type": "string",
      "description": "Unique ID of the Case"
    },
    "case_type": {
      "$ref": "#/$defs/CaseViewType"
    },
    "state": {
      "$ref": "#/$defs/ProfileCaseState"
    },
    "channels": {
      "type": "array",
      "description": "The channels this tab is targetted at",
      "items": {
        "type": "string"
      }
    },
    "tabs": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/CaseViewTab"
      }
    },
    "triggers": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/CaseViewTrigger"
      }
    },
    "events": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/CaseViewEvent"
      }
    }
  },
  "required": [
    "case_id",
    "case_type",
    "state",
    "tabs"
  ],
  "$defs": {
    "CaseViewEvent": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer",
          "format": "int64"
        },
        "timestamp": {
          "type": "string",
          "format": "date-time"
        },
        "user_id": {
          "type": "integer",
          "format": "int64"
        },
        "user_first_name": {
          "type": "string"
        },
        "user_last_name": {
          "type": "string"
        },
        "event_id": {
          "type": "string"
        },
        "event_name": {
          "type": "string"
        },
        "summary": {
          "type": "string"
        },
        "comment": {
          "type": "string"
        }
      }
    },
    "CaseViewField": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "The id of the case field"
        },
        "label": {
          "type": "string"
        },
        "hint_text": {
          "type": "string"
        },
        "field_type": {
          "$ref": "#/$defs/FieldType"
        },
        "hidden": {
          "type": "boolean"
        },
        "validation_expr": {
          "type": "string"
        },
        "security_label": {
          "type": "string",
          "description": "Gov security level of the data (official, top secret etc)"
        },
        "order": {
          "type": "integer",
          "format": "int32"
        },
        "value": {
          "type": "object",
          "description": "Value of the field, type and structure depends on the field type\n"
        }
      },
      "required": [
        "id",
        "label",
        "field_type"
      ]
    },
    "CaseViewJurisdiction": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "description": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "name"
      ]
    },
    "CaseViewTab": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "label": {
          "type": "string"
        },
        "order": {
          "type": "integer",
          "format": "int32"
        },
        "fields": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/CaseViewField"
          }
        }
      },
      "required": [
        "id",
        "label",
        "fields"
      ]
    },
    "CaseViewTrigger": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "order": {
          "type": "number",
          "format": "int32"
        }
      },
      "required": [
        "id",
        "name"
      ]
    },
    "CaseViewType": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "Unique identifier for a Case Type."
        },
        "name": {
          "type": "string",
          "description": "Display name of the Case Type."
        },
        "description": {
          "type": "string"
        },
        "jurisdiction": {
          "$ref": "#/$defs/CaseViewJurisdiction"
        }
      },
      "required": [
        "id",
        "name",
        "jurisdiction"
      ]
    },
    "FieldType": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "Same as `type` for simple types, or custom type name for complex types\n"
        },
        "type": {
          "$ref": "#/$defs/FieldTypeEnum"
        },
        "min": {
          "type": "integer",
          "format": "int32",
          "description": "Minimum number or string length, when applicable"
        },
        "max": {
          "type": "integer",
          "format": "int32",
          "description": "Maximum number or string length, when applicable"
        },
        "regular_expression": {
          "type": "string",
          "description": "Regular expression to conform to, applicable to string"
        },
        "fixed_list_items": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/FixedListItem"
          },
          "description": "Applicable to `FixedList` type"
        },
        "complex_fields": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/CaseViewField"
          },
          "description": "Applicable to `ComplexType` type"
        }
      },
      "required": [
        "id",
        "type"
      ]
    },
    "FieldTypeEnum": {
      "type": "string",
      "description": "Supported values of field types' type",
      "enum": [
        "Text",
        "Number",
        "YesOrNo",
        "Date",
        "Email",
        "PhoneUK",
        "FixedList",
        "MoneyGBP",
        "TextArea",
        "RichTextArea",
        "ComplexType",
        "Collection",
        "MultiSelectList"
      ]
    },
    "FixedListItem": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "description": "Value of the list item, to be saved in case data"
        },
        "label": {
          "type": "string",
          "description": "Label of the list item, for display only"
        }
      },
      "required": [
        "label"
      ]
    },
    "ProfileCaseState": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "description": {
          "type": "string"
        }
      }
    }
  }
}