{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://schemas.kodemed.ch/_common/CaseData.schema.json",
  "title": "KodeMed Case Data fields (composable)",
  "description": "Canonical field set for case data on every wire transport — HIS REST submission body, webhook payload, WebSocket message, COM GetResults return. Flow schemas include this fragment via `allOf` rather than re-declaring the fields inline, so a typo or type drift in one flow is mechanically impossible (#640). The matching XML payload (`data`) is validated server-side against the SPIGES XSD (`Documentation/spiges/SPIGES-1.5.xsd`) or the BFS variant the CodingClient SPIGES/BFS opener supports.",
  "type": "object",
  "properties": {
    "data": {
      "type": "string",
      "minLength": 1,
      "maxLength": 5242880,
      "description": "Raw case-data XML payload (one or more `<Fall>` elements). 5 MB upper bound matches the server-side @Size limit on KodeMed.Server's CodingSessionRequest.data. Travels as a UTF-8 string — base-64 encoding is NOT used."
    },
    "format": {
      "type": "string",
      "enum": ["spiges", "bfs", "custom"],
      "description": "Discriminator for the dialect carried in `data`. `spiges` (default) follows SPIGES-1.5.xsd. `bfs` is the Bundesamt für Statistik variant the CodingClient SPIGES/BFS opener can read. `custom` signals a DLL-plugin-resolved partner-specific format — the actual parser is selected server-side by `customPluginId` on the session service path. Must match the canonical Server-side enum `CodingSessionService.VALID_FORMATS`."
    },
    "dataHash": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128,
      "description": "Optional content hash (e.g. SHA-256 hex) of `data`. Server uses it for idempotency / quick equality checks; not required."
    },
    "schemaVersion": {
      "type": "string",
      "description": "Optional declaration of the XSD version the producer targeted (e.g. `SPIGES-1.5`, `BFS-2026`). Server uses this for graceful migration when multiple XSD versions coexist; missing = latest known."
    }
  }
}
