{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "index-01",
  "type": "registry:block",
  "description": "A composite index score with each domain's share and its biomarker Z-scores.",
  "files": [
    {
      "path": "registry/predict/blocks/index-01/page.tsx",
      "content": "\"use client\"\n\nimport { InfoIcon } from \"lucide-react\"\n\nimport {\n  Accordion,\n  AccordionContent,\n  AccordionItem,\n  AccordionTrigger,\n} from \"@workspace/ui/components/accordion\"\nimport { Badge } from \"@workspace/ui/components/badge\"\nimport {\n  Card,\n  CardAction,\n  CardContent,\n  CardDescription,\n  CardHeader,\n  CardTitle,\n} from \"@workspace/ui/components/card\"\nimport {\n  Tooltip,\n  TooltipContent,\n  TooltipProvider,\n  TooltipTrigger,\n} from \"@workspace/ui/components/tooltip\"\n\n// The CBMI worked example. Each domain's Mean |Z| comes from its biomarker\n// Z-scores, Wd is its share of the total, and αd is its priority.\n// Score = αd × Mean |Z| × Wd.\nconst domains = [\n  {\n    name: \"Cardiometabolic Risk\",\n    abbr: \"CMR\",\n    alpha: 6,\n    biomarkers: [\n      { name: \"HbA1c\", z: 7 },\n      { name: \"TC\", z: 3.338 },\n      { name: \"LDL-C\", z: 9.024 },\n      { name: \"HDL-C\", z: -2.43 },\n    ],\n  },\n  {\n    name: \"Inflammatory Risk\",\n    abbr: \"IR\",\n    alpha: 2,\n    biomarkers: [\n      { name: \"hs-CRP\", z: 2.714 },\n      { name: \"NLR\", z: 2.4 },\n      { name: \"IL-6\", z: 3.712 },\n    ],\n  },\n  {\n    name: \"Muscle-Cartilage Degeneration Risk\",\n    abbr: \"MCDR\",\n    alpha: 2,\n    biomarkers: [\n      { name: \"CK-MM\", z: 2.667 },\n      { name: \"Aldolase A\", z: 2.627 },\n      { name: \"IGF-1\", z: -2.107 },\n      { name: \"Myostatin\", z: 4.52 },\n      { name: \"CTX-II\", z: 2.736 },\n    ],\n  },\n  {\n    name: \"Bone Turnover Risk\",\n    abbr: \"BTR\",\n    alpha: 1,\n    biomarkers: [\n      { name: \"PTH\", z: 2.824 },\n      { name: \"Ca/P ratio\", z: 2.5 },\n      { name: \"Vitamin D\", z: -2.263 },\n      { name: \"Osteocalcin\", z: -2.263 },\n      { name: \"PINP\", z: -2.687 },\n    ],\n  },\n  {\n    name: \"Neurovascular Function Risk\",\n    abbr: \"NVFR\",\n    alpha: 1,\n    biomarkers: [\n      { name: \"BDNF\", z: -2.352 },\n      { name: \"VEGF\", z: 3.011 },\n      { name: \"NOx\", z: -2.11 },\n    ],\n  },\n]\n\nconst withMeanZ = domains.map((d) => ({\n  ...d,\n  meanZ: d.biomarkers.reduce((sum, b) => sum + Math.abs(b.z), 0) / d.biomarkers.length,\n}))\nconst totalMeanZ = withMeanZ.reduce((sum, d) => sum + d.meanZ, 0)\nconst scored = withMeanZ.map((d) => {\n  const weight = d.meanZ / totalMeanZ\n  return { ...d, weight, score: d.alpha * d.meanZ * weight }\n})\nconst total = scored.reduce((sum, d) => sum + d.score, 0)\nconst maxScore = Math.max(...scored.map((d) => d.score))\n\nexport default function Page() {\n  return (\n    <TooltipProvider>\n      <div className=\"mx-auto flex w-full max-w-3xl flex-col gap-4 p-4 md:p-8\">\n        <Card>\n          <CardHeader>\n            <CardTitle className=\"text-sm\">Composite Biological Musculoskeletal Index</CardTitle>\n            <CardDescription>Five domains, 21 biomarkers.</CardDescription>\n            <CardAction>\n              <Tooltip>\n                <TooltipTrigger\n                  aria-label=\"How the score works\"\n                  className=\"text-muted-foreground\"\n                >\n                  <InfoIcon className=\"size-4\" />\n                </TooltipTrigger>\n                <TooltipContent className=\"max-w-60\">\n                  Each domain scores αd × Mean |Z| × Wd. The index is their sum.\n                </TooltipContent>\n              </Tooltip>\n            </CardAction>\n          </CardHeader>\n          <CardContent className=\"flex flex-col gap-6\">\n            <div className=\"flex items-end gap-3\">\n              <span className=\"text-5xl font-medium tracking-tight tabular-nums\">\n                {total.toFixed(2)}\n              </span>\n              <Badge variant=\"destructive\" className=\"mb-2\">\n                CBMI\n              </Badge>\n            </div>\n\n            <ul className=\"flex flex-col gap-3\">\n              {scored.map((d) => (\n                <li key={d.abbr} className=\"grid grid-cols-[3.5rem_1fr_3rem] items-center gap-3\">\n                  <span className=\"text-xs font-medium\">{d.abbr}</span>\n                  <div className=\"h-2 overflow-hidden rounded-full bg-muted\">\n                    <div\n                      className=\"h-full rounded-full bg-primary\"\n                      style={{ width: `${(d.score / maxScore) * 100}%` }}\n                    />\n                  </div>\n                  <span className=\"text-right text-xs tabular-nums\">{d.score.toFixed(2)}</span>\n                </li>\n              ))}\n            </ul>\n          </CardContent>\n        </Card>\n\n        <Card>\n          <CardHeader>\n            <CardTitle className=\"text-sm\">Domains</CardTitle>\n            <CardDescription>Open a domain to see its biomarker Z-scores.</CardDescription>\n          </CardHeader>\n          <CardContent>\n            <Accordion defaultValue={[\"CMR\"]}>\n              {scored.map((d) => (\n                <AccordionItem key={d.abbr} value={d.abbr}>\n                  <AccordionTrigger>\n                    <span className=\"flex flex-1 items-center justify-between gap-4 pr-2\">\n                      <span>\n                        {d.name} <span className=\"text-muted-foreground\">({d.abbr})</span>\n                      </span>\n                      <span className=\"text-muted-foreground tabular-nums\">\n                        αd {d.alpha} · Wd {d.weight.toFixed(2)}\n                      </span>\n                    </span>\n                  </AccordionTrigger>\n                  <AccordionContent>\n                    <table className=\"w-full text-xs\">\n                      <thead className=\"text-muted-foreground\">\n                        <tr>\n                          <th className=\"py-1 text-left font-normal\">Biomarker</th>\n                          <th className=\"py-1 text-right font-normal\">Z</th>\n                          <th className=\"py-1 text-right font-normal\">|Z|</th>\n                        </tr>\n                      </thead>\n                      <tbody className=\"tabular-nums\">\n                        {d.biomarkers.map((b) => (\n                          <tr key={b.name} className=\"border-t\">\n                            <td className=\"py-1.5\">{b.name}</td>\n                            <td className=\"py-1.5 text-right\">{b.z.toFixed(2)}</td>\n                            <td className=\"py-1.5 text-right\">{Math.abs(b.z).toFixed(2)}</td>\n                          </tr>\n                        ))}\n                      </tbody>\n                    </table>\n                  </AccordionContent>\n                </AccordionItem>\n              ))}\n            </Accordion>\n          </CardContent>\n        </Card>\n      </div>\n    </TooltipProvider>\n  )\n}\n",
      "type": "registry:page",
      "target": "app/index/page.tsx"
    }
  ],
  "meta": {
    "iframeHeight": "960px"
  },
  "categories": [
    "reports"
  ]
}