{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "clinician-review",
  "title": "Clinician review",
  "description": "A clinician's sign-off on AI-generated content, built like shadcn's Confirmation: approve, or request changes or reject with a reason, recording who and when.",
  "dependencies": [
    "cn@^0.5.0"
  ],
  "registryDependencies": [
    "badge",
    "button",
    "field",
    "item",
    "textarea"
  ],
  "files": [
    {
      "path": "registry/base-nova/clinician-review/clinician-review.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { Badge } from \"@/components/ui/badge\"\nimport { Button } from \"@/components/ui/button\"\nimport { Field, FieldDescription, FieldLabel } from \"@/components/ui/field\"\nimport {\n  Item,\n  ItemActions,\n  ItemContent,\n  ItemDescription,\n  ItemFooter,\n  ItemTitle,\n} from \"@/components/ui/item\"\nimport { Textarea } from \"@/components/ui/textarea\"\nimport { IconPlaceholder } from \"@/icons/icon-placeholder\"\n\nexport type ReviewStatus =\n  \"pending\" | \"approved\" | \"changes-requested\" | \"rejected\"\n\nexport type ReviewDecision = {\n  status: ReviewStatus\n  /** Who decided, from the `reviewer` prop. */\n  reviewer?: string\n  /** When, an ISO 8601 date-time. */\n  at?: string\n  /** Why, required to request changes or reject. */\n  comment?: string\n}\n\nexport type ClinicianReviewProps = React.ComponentProps<\"div\"> & {\n  /**\n   * The current decision, `{ status, reviewer?, at?, comment? }`, where status\n   * is pending, approved, changes-requested or rejected. Store it with the\n   * content it reviews.\n   */\n  value: ReviewDecision\n  /** Called with each new decision, or with pending after an undo. */\n  onValueChange: (decision: ReviewDecision) => void\n  /** The signed-in clinician, recorded with each decision. */\n  reviewer: string\n  /** What is being reviewed, such as \"Discharge summary\". */\n  subject?: string\n  /** The time recorded with a decision. Defaults to now, as ISO 8601. */\n  now?: () => string\n  /** Defaults to a UTC date and time such as \"Oct 21, 2026, 9:30 AM UTC\". */\n  formatDate?: (date: string) => string\n}\n\nexport const reviewStatusLabels: Record<ReviewStatus, string> = {\n  pending: \"Awaiting review\",\n  approved: \"Approved\",\n  \"changes-requested\": \"Changes requested\",\n  rejected: \"Rejected\",\n}\n\nconst dateFormat = new Intl.DateTimeFormat(\"en-US\", {\n  dateStyle: \"medium\",\n  timeStyle: \"short\",\n  timeZone: \"UTC\",\n})\n\nfunction defaultFormatDate(date: string) {\n  const time = Date.parse(date)\n  return Number.isNaN(time) ? date : `${dateFormat.format(time)} UTC`\n}\n\ntype Pending = \"changes-requested\" | \"rejected\"\n\n// Each status has its own shape, so the badge reads without colour.\nfunction StatusIcon({ status }: { status: ReviewStatus }) {\n  switch (status) {\n    case \"pending\":\n      return (\n        <IconPlaceholder\n          lucide=\"ClockIcon\"\n          tabler=\"IconClock\"\n          hugeicons=\"Clock01Icon\"\n          phosphor=\"ClockIcon\"\n          remixicon=\"RiTimeLine\"\n          aria-hidden=\"true\"\n          data-icon=\"inline-start\"\n        />\n      )\n    case \"approved\":\n      return (\n        <IconPlaceholder\n          lucide=\"CheckIcon\"\n          tabler=\"IconCheck\"\n          hugeicons=\"Tick02Icon\"\n          phosphor=\"CheckIcon\"\n          remixicon=\"RiCheckLine\"\n          aria-hidden=\"true\"\n          data-icon=\"inline-start\"\n        />\n      )\n    case \"changes-requested\":\n      return (\n        <IconPlaceholder\n          lucide=\"CircleAlertIcon\"\n          tabler=\"IconExclamationCircle\"\n          hugeicons=\"AlertCircleIcon\"\n          phosphor=\"WarningCircleIcon\"\n          remixicon=\"RiErrorWarningLine\"\n          aria-hidden=\"true\"\n          data-icon=\"inline-start\"\n        />\n      )\n    case \"rejected\":\n      return (\n        <IconPlaceholder\n          lucide=\"XIcon\"\n          tabler=\"IconX\"\n          hugeicons=\"Cancel01Icon\"\n          phosphor=\"XIcon\"\n          remixicon=\"RiCloseLine\"\n          aria-hidden=\"true\"\n          data-icon=\"inline-start\"\n        />\n      )\n  }\n}\n\n/**\n * A clinician's sign-off on AI-generated content, built like shadcn's\n * Confirmation from an Item and Buttons: approve it, or request changes or\n * reject it with a reason. Each decision records who and when, and can be\n * undone. You store the decision; the component holds no state beyond the\n * reason being typed.\n */\nexport function ClinicianReview({\n  value,\n  onValueChange,\n  reviewer,\n  subject = \"AI-generated content\",\n  now = () => new Date().toISOString(),\n  formatDate = defaultFormatDate,\n  className,\n  ...props\n}: ClinicianReviewProps) {\n  const [asking, setAsking] = React.useState<Pending | null>(null)\n  const [comment, setComment] = React.useState(\"\")\n  const reasonId = React.useId()\n  const reason = React.useRef<HTMLTextAreaElement>(null)\n\n  React.useEffect(() => {\n    if (asking) reason.current?.focus()\n  }, [asking])\n\n  function decide(status: ReviewStatus, text?: string) {\n    onValueChange({ status, reviewer, at: now(), comment: text })\n    setAsking(null)\n    setComment(\"\")\n  }\n\n  const decided = value.status !== \"pending\"\n  return (\n    <Item\n      data-slot=\"clinician-review\"\n      data-status={value.status}\n      variant=\"outline\"\n      className={className}\n      {...props}\n    >\n      {/* The status is a Badge, as lab results and the charts show theirs,\n          and the region announces it with who decided. */}\n      <ItemContent aria-live=\"polite\">\n        <ItemTitle className=\"flex-wrap gap-y-1\">\n          {subject}\n          <Badge variant=\"outline\">\n            <StatusIcon status={value.status} />\n            {reviewStatusLabels[value.status]}\n          </Badge>\n        </ItemTitle>\n        {/* Never clamped: who reviewed it, and when, must read in full. */}\n        <ItemDescription className=\"line-clamp-none\">\n          {decided\n            ? [\n                value.reviewer && `By ${value.reviewer}`,\n                value.at && formatDate(value.at),\n              ]\n                .filter(Boolean)\n                .join(\", \") || \"No reviewer recorded.\"\n            : `Review as ${reviewer} before this is used.`}\n        </ItemDescription>\n        {decided && value.comment && (\n          <blockquote className=\"mt-1 border-l-2 pl-3 text-sm text-muted-foreground\">\n            {value.comment}\n          </blockquote>\n        )}\n      </ItemContent>\n      <ItemActions className=\"flex-wrap\">\n        {decided ? (\n          <Button\n            variant=\"outline\"\n            size=\"sm\"\n            onClick={() => onValueChange({ status: \"pending\" })}\n          >\n            <IconPlaceholder\n              lucide=\"Undo2Icon\"\n              tabler=\"IconArrowBackUp\"\n              hugeicons=\"Undo02Icon\"\n              phosphor=\"ArrowCounterClockwiseIcon\"\n              remixicon=\"RiArrowGoBackLine\"\n              aria-hidden=\"true\"\n              data-icon=\"inline-start\"\n            />\n            Undo\n          </Button>\n        ) : (\n          !asking && (\n            <>\n              <Button\n                size=\"sm\"\n                variant=\"outline\"\n                onClick={() => setAsking(\"rejected\")}\n              >\n                Reject\n              </Button>\n              <Button\n                size=\"sm\"\n                variant=\"outline\"\n                onClick={() => setAsking(\"changes-requested\")}\n              >\n                Request changes\n              </Button>\n              <Button size=\"sm\" onClick={() => decide(\"approved\")}>\n                Approve\n              </Button>\n            </>\n          )\n        )}\n      </ItemActions>\n      {asking && (\n        <ItemFooter className=\"flex-col items-stretch gap-3\">\n          <Field>\n            <FieldLabel htmlFor={reasonId}>\n              {asking === \"rejected\"\n                ? \"Reason for rejecting\"\n                : \"Changes needed\"}\n            </FieldLabel>\n            <Textarea\n              ref={reason}\n              id={reasonId}\n              value={comment}\n              onChange={(event) => setComment(event.target.value)}\n              required\n            />\n            <FieldDescription>Recorded with your decision.</FieldDescription>\n          </Field>\n          <div className=\"flex justify-end gap-2\">\n            <Button\n              size=\"sm\"\n              variant=\"ghost\"\n              onClick={() => {\n                setAsking(null)\n                setComment(\"\")\n              }}\n            >\n              Cancel\n            </Button>\n            <Button\n              size=\"sm\"\n              variant={asking === \"rejected\" ? \"destructive\" : \"default\"}\n              disabled={!comment.trim()}\n              onClick={() => decide(asking, comment.trim())}\n            >\n              {asking === \"rejected\" ? \"Reject\" : \"Request changes\"}\n            </Button>\n          </div>\n        </ItemFooter>\n      )}\n    </Item>\n  )\n}\n",
      "type": "registry:ui"
    }
  ],
  "docs": "Clinician review docs: https://organui.com/docs/ai-elements/clinician-review",
  "categories": [
    "ai"
  ],
  "type": "registry:ui"
}