# curated.kitchen_order_items

## Purpose

This table is the kitchen-facing line-item read model. Each row represents one order item that the kitchen may need to prepare, display, route, or analyze.

It supports item-level monitoring such as prep-time outliers, forgotten items, recall flow, and station bottleneck analysis.

## Schema contract

The deployed SQL under `backend/Kds.Ai.Warehouse/Sql/Bootstrap/Tenant/Curated/` is the source of truth for the current column names, types, and nullability.

## Column groups

- Business properties describe the business entity, event, fact, or reference record represented by the table.
- Technical and ETL properties describe warehouse lineage, surrogate keys, source reconciliation, tenant scoping, slowly changing dimension controls, and ingestion metadata.

## Business properties

| Column | Type | Nullable | Business Meaning | Notes |
|---|---|---|---|---|
| `guid` | `VARCHAR(36)` | No | Unique identifier of the kitchen order item row. |  |
| `order_guid` | `VARCHAR(36)` | No | Reference to the parent kitchen order. |  |
| `name` | `VARCHAR(199)` | No | Kitchen-visible item name. |  |
| `category` | `VARCHAR(100)` | Yes | Logical product or kitchen category for the item. |  |
| `device_id` | `INTEGER` | Yes | Device or station identifier associated with the item. |  |
| `is_priority` | `SMALLINT` | No | Priority flag used by kitchen workflow and anomaly detection. |  |
| `item_bump_guid` | `VARCHAR(36)` | Yes | Reference to the source bump or completion event for the item. |  |
| `create_time` | `INTEGER` | No | Canonical creation timestamp for the item row. |  |
| `is_deleted` | `SMALLINT` | No | Soft-delete flag for downstream filtering. |  |
| `preparation_time` | `INTEGER` | Yes | Calculated or sourced preparation duration for the item. |  |
| `quantity` | `INTEGER` | No | Ordered quantity for the item line. |  |
| `recall_time` | `INTEGER` | Yes | Timestamp when the item was recalled for rework or re-display. |  |
| `external_id` | `VARCHAR(199)` | No | External source identifier for the item. |  |
| `pre_modifier` | `VARCHAR(65535)` | Yes | Free-form modifier text that should be shown before the item name. |  |
| `update_time` | `INTEGER` | No | Canonical last update timestamp for the item row. |  |
| `printed_status` | `SMALLINT` | No | Print-state flag used by KDS or chit workflows. |  |
| `create_local_time` | `INTEGER` | Yes | Local-time mirror of item creation time. |  |
| `ready_since_local_time` | `INTEGER` | Yes | Local timestamp from which the item has been ready. |  |
| `count` | `INTEGER` | Yes | Legacy count field from the source contract. |  |
| `condiments_count` | `INTEGER` | No | Number of attached condiments or subcomponents. |  |
| `transfer_from_device_id` | `INTEGER` | Yes | Device from which the item was transferred. |  |
| `transfer_time` | `INTEGER` | Yes | Timestamp when the item was transferred. |  |
| `untransfer_time` | `INTEGER` | Yes | Timestamp when a prior transfer was reversed. |  |
| `beeped` | `SMALLINT` | No | Flag indicating whether the item triggered an alert or beep. |  |
| `build_card` | `VARCHAR(65535)` | Yes | Build instructions or item assembly card content. |  |
| `device_name` | `VARCHAR(255)` | Yes | Readable name of the device associated with the item. |  |
| `station_name` | `VARCHAR(255)` | Yes | Readable kitchen station name associated with the item. |  |
| `business_date` | `DATE` | Yes | Business date associated with the kitchen item. |  |
| `create_time_utc` | `TIMESTAMP` | Yes | UTC timestamp when the kitchen item was created in canonical warehouse time. |  |
| `ready_state_name` | `VARCHAR(100)` | Yes | Readable current readiness or fulfillment state of the kitchen item. |  |
| `recall_reason` | `VARCHAR(255)` | Yes | Readable reason for item recall or rework when available from the source. |  |
| `item_status_name` | `VARCHAR(100)` | Yes | Readable canonical lifecycle status of the kitchen order item. |  |

## Technical and ETL properties

| Column | Type | Nullable | Technical Meaning | Notes |
|---|---|---|---|---|
| `kitchen_order_item_key` | `BIGINT` | Yes | Stable warehouse key for the kitchen order item entity. |  |
| `source_system` | `VARCHAR(100)` | Yes | Canonical name of the source platform that produced the kitchen item row. |  |
| `source_item_id` | `VARCHAR(199)` | Yes | Original kitchen item identifier from the source platform. |  |
| `tenant_key` | `BIGINT` | Yes | Stable warehouse key for the tenant, brand, or client that owns the kitchen item. |  |
| `tenant_name` | `VARCHAR(255)` | Yes | Readable tenant, brand, or client name associated with the kitchen item. |  |
| `_etl_batch_id` | `VARCHAR(256)` | Yes | ETL batch lineage identifier. |  |
| `_etl_source_type` | `VARCHAR(100)` | Yes | Source adapter type used by ETL. |  |
| `_etl_ingested_at` | `TIMESTAMP` | No | Warehouse ingestion timestamp for the curated row. | Required ingestion audit timestamp. |
