Spaces:
Running
Running
File size: 139,715 Bytes
9fa900d 3363380 9fa900d 3363380 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 | <!DOCTYPE html>
<html lang="th">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>VitalMetrics Pro - ระบบวิเคราะห์สุขภาพขั้นสูง</title>
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js"></script>
<script src="https://unpkg.com/feather-icons"></script>
<style>
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');
* {
font-family: 'Inter', sans-serif;
}
.gradient-emerald {
background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}
.gradient-yellow {
background: linear-gradient(135deg, #eab308 0%, #ca8a04 100%);
}
.glass-effect {
background: rgba(255, 255, 255, 0.95);
backdrop-filter: blur(10px);
border: 1px solid rgba(0, 0, 0, 0.05);
}
.metric-card {
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.metric-card:hover {
transform: translateY(-2px);
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}
.trend-up {
color: #10b981;
}
.trend-down {
color: #ef4444;
}
.trend-neutral {
color: #6b7280;
}
.status-badge {
animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.8; }
}
.chart-container {
position: relative;
height: 250px;
width: 100%;
}
.loader {
border: 3px solid #f3f3f3;
border-top: 3px solid #10b981;
border-radius: 50%;
width: 40px;
height: 40px;
animation: spin 1s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
body {
background: linear-gradient(to bottom, #f0fdf4, #ffffff);
min-height: 100vh;
}
.tab-active {
border-bottom: 3px solid #10b981;
color: #10b981;
}
.search-input:focus {
box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}
</style>
</head>
<body>
<!-- Header Navigation -->
<header class="glass-effect sticky top-0 z-50 border-b border-gray-100">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex items-center justify-between h-16">
<div class="flex items-center">
<i data-feather="activity" class="w-8 h-8 text-emerald-600 mr-2"></i>
<h1 class="text-xl font-bold text-gray-900">VitalMetrics Pro</h1>
</div>
<div class="flex items-center space-x-4">
<span class="text-sm text-gray-500">Demo Mode</span>
<div class="w-2 h-2 bg-emerald-500 rounded-full animate-pulse"></div>
</div>
</div>
</div>
</header>
<!-- Main Content -->
<main class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-6">
<!-- Tab Navigation -->
<div class="flex space-x-1 mb-6 overflow-x-auto">
<button onclick="switchTab('overview')" class="tab-btn px-4 py-2 text-sm font-medium whitespace-nowrap tab-active">ภาพรวม</button>
<button onclick="switchTab('metrics')" class="tab-btn px-4 py-2 text-sm font-medium whitespace-nowrap">เมตริก (120+)</button>
<button onclick="switchTab('journal')" class="tab-btn px-4 py-2 text-sm font-medium whitespace-nowrap">บันทึกประจำวัน</button>
<button onclick="switchTab('marketplace')" class="tab-btn px-4 py-2 text-sm font-medium whitespace-nowrap">Marketplace</button>
<button onclick="switchTab('profile')" class="tab-btn px-4 py-2 text-sm font-medium whitespace-nowrap">โปรไฟล์</button>
</div>
<!-- Overview Tab -->
<div id="overview-tab" class="tab-content">
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 mb-6">
<!-- Health Score Card -->
<div class="metric-card bg-white rounded-xl p-6 shadow-sm">
<div class="flex items-center justify-between mb-2">
<span class="text-sm text-gray-500">Health Score</span>
<i data-feather="heart" class="w-4 h-4 text-emerald-500"></i>
</div>
<div class="text-3xl font-bold text-gray-900">92</div>
<div class="flex items-center mt-2">
<i data-feather="trending-up" class="w-4 h-4 trend-up mr-1"></i>
<span class="text-xs trend-up">+5 จากสัปดาห์ที่แล้ว</span>
</div>
</div>
<!-- Recovery Score -->
<div class="metric-card bg-white rounded-xl p-6 shadow-sm">
<div class="flex items-center justify-between mb-2">
<span class="text-sm text-gray-500">Recovery</span>
<i data-feather="battery-charging" class="w-4 h-4 text-yellow-500"></i>
</div>
<div class="text-3xl font-bold text-gray-900">78%</div>
<div class="flex items-center mt-2">
<i data-feather="trending-down" class="w-4 h-4 trend-down mr-1"></i>
<span class="text-xs trend-down">-3 จากเมื่อวาน</span>
</div>
</div>
<!-- Sleep Score -->
<div class="metric-card bg-white rounded-xl p-6 shadow-sm">
<div class="flex items-center justify-between mb-2">
<span class="text-sm text-gray-500">Sleep Score</span>
<i data-feather="moon" class="w-4 h-4 text-blue-500"></i>
</div>
<div class="text-3xl font-bold text-gray-900">85</div>
<div class="flex items-center mt-2">
<i data-feather="trending-up" class="w-4 h-4 trend-up mr-1"></i>
<span class="text-xs trend-up">+7 จากเมื่อวาน</span>
</div>
</div>
<!-- Strain Score -->
<div class="metric-card bg-white rounded-xl p-6 shadow-sm">
<div class="flex items-center justify-between mb-2">
<span class="text-sm text-gray-500">Strain</span>
<i data-feather="zap" class="w-4 h-4 text-orange-500"></i>
</div>
<div class="text-3xl font-bold text-gray-900">12.5</div>
<div class="flex items-center mt-2">
<i data-feather="trending-up" class="w-4 h-4 trend-up mr-1"></i>
<span class="text-xs trend-up">กำลังดีขึ้น</span>
</div>
</div>
</div>
<!-- Charts Section -->
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
<div class="bg-white rounded-xl p-6 shadow-sm">
<h3 class="text-lg font-semibold text-gray-900 mb-4">Health Trend (30 วัน)</h3>
<div class="chart-container">
<canvas id="healthTrendChart"></canvas>
</div>
</div>
<div class="bg-white rounded-xl p-6 shadow-sm">
<h3 class="text-lg font-semibold text-gray-900 mb-4">Sleep & Recovery</h3>
<div class="chart-container">
<canvas id="sleepRecoveryChart"></canvas>
</div>
</div>
</div>
<!-- AI Insights -->
<div class="mt-6 bg-gradient-to-r from-emerald-50 to-yellow-50 rounded-xl p-6 border border-emerald-100">
<div class="flex items-center mb-3">
<i data-feather="cpu" class="w-5 h-5 text-emerald-600 mr-2"></i>
<h3 class="text-lg font-semibold text-gray-900">AI Insights</h3>
</div>
<div class="space-y-2">
<p class="text-sm text-gray-700">🔍 คุณกำลังได้รับการนอนหลับที่ดีขึ้น แต่สัดส่วน REM sleep ยังต่ำกว่าเป้าหมาย</p>
<p class="text-sm text-gray-700">💪 HRV ของคุณดีขึ้น 15% หลังจากเพิ่มการเดินเข้าไปในกิจวัตรประจำวัน</p>
<p class="text-sm text-gray-700">⚡ แนะนำให้ลดสัดส่วนการฝึกความเข้มสูงเหลือ 20% ของทั้งหมด</p>
</div>
</div>
</div>
<!-- Metrics Tab -->
<div id="metrics-tab" class="tab-content hidden">
<!-- Search and Filter -->
<div class="bg-white rounded-xl p-4 mb-6 shadow-sm">
<div class="flex flex-col lg:flex-row gap-4">
<div class="flex-1">
<input type="text" id="searchInput" placeholder="ค้นหาเมตริก..."
class="search-input w-full px-4 py-2 border border-gray-200 rounded-lg focus:outline-none focus:border-emerald-500">
</div>
<div class="flex gap-2 flex-wrap">
<button onclick="filterMetrics('all')" class="filter-btn px-3 py-1 text-sm rounded-full bg-emerald-100 text-emerald-700">ทั้งหมด</button>
<button onclick="filterMetrics('smartband')" class="filter-btn px-3 py-1 text-sm rounded-full bg-gray-100 text-gray-700">สมาร์ทแบนด์</button>
<button onclick="filterMetrics('myscale')" class="filter-btn px-3 py-1 text-sm rounded-full bg-gray-100 text-gray-700">MyScale</button>
<button onclick="filterMetrics('blood')" class="filter-btn px-3 py-1 text-sm rounded-full bg-gray-100 text-gray-700">การตรวจเลือด</button>
<button onclick="filterMetrics('nutrition')" class="filter-btn px-3 py-1 text-sm rounded-full bg-gray-100 text-gray-700">โภชนาการ</button>
<button onclick="filterMetrics('manual')" class="filter-btn px-3 py-1 text-sm rounded-full bg-gray-100 text-gray-700">บันทึก</button>
<button onclick="filterMetrics('system')" class="filter-btn px-3 py-1 text-sm rounded-full bg-gray-100 text-gray-700">ระบบ</button>
</div>
</div>
</div>
<!-- Metrics List -->
<div id="metricsList" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
<!-- Metrics will be populated here -->
</div>
</div>
<!-- Metric Detail View -->
<div id="metric-detail" class="hidden">
<button onclick="backToMetrics()" class="mb-4 flex items-center text-emerald-600 hover:text-emerald-700">
<i data-feather="arrow-left" class="w-4 h-4 mr-2"></i>
กลับไปหน้าเมตริก
</button>
<div class="bg-white rounded-xl p-6 shadow-sm mb-6">
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
<!-- Snapshot -->
<div class="lg:col-span-1">
<h2 id="metric-name" class="text-2xl font-bold text-gray-900 mb-4">--</h2>
<div class="space-y-4">
<div>
<span class="text-sm text-gray-500">ค่าล่าสุด</span>
<div class="text-3xl font-bold text-gray-900" id="metric-value">--</div>
</div>
<div>
<span class="text-sm text-gray-500">สถานะ</span>
<div class="mt-1">
<span id="metric-status" class="status-badge px-3 py-1 rounded-full text-sm">--</span>
</div>
</div>
<div>
<span class="text-sm text-gray-500">อัปเดตล่าสุด</span>
<div class="text-sm text-gray-900" id="metric-date">--</div>
</div>
</div>
</div>
<!-- Chart -->
<div class="lg:col-span-2">
<div class="chart-container">
<canvas id="metricDetailChart"></canvas>
</div>
</div>
</div>
<!-- Trend Table -->
<div class="mt-6 pt-6 border-t border-gray-100">
<h3 class="text-lg font-semibold text-gray-900 mb-4">แนวโน้ม</h3>
<div class="grid grid-cols-3 gap-4">
<div class="text-center p-3 bg-gray-50 rounded-lg">
<div class="text-sm text-gray-500">3 วัน</div>
<div class="text-xl font-semibold" id="trend-3d">--</div>
</div>
<div class="text-center p-3 bg-gray-50 rounded-lg">
<div class="text-sm text-gray-500">7 วัน</div>
<div class="text-xl font-semibold" id="trend-7d">--</div>
</div>
<div class="text-center p-3 bg-gray-50 rounded-lg">
<div class="text-sm text-gray-500">30 วัน</div>
<div class="text-xl font-semibold" id="trend-30d">--</div>
</div>
</div>
</div>
<!-- Projection -->
<div class="mt-6 pt-6 border-t border-gray-100">
<h3 class="text-lg font-semibold text-gray-900 mb-4">คาดการณ์ 30 วันข้างหน้า</h3>
<div class="bg-emerald-50 border border-emerald-200 rounded-lg p-4">
<div class="flex items-center justify-between">
<div>
<span class="text-sm text-gray-600">ค่าที่คาดว่าจะได้</span>
<div class="text-2xl font-bold text-emerald-700" id="projection-value">--</div>
</div>
<div class="text-right">
<span class="text-sm text-gray-600">ความเชื่อมั่น</span>
<div class="text-xl font-semibold text-emerald-600">85%</div>
</div>
</div>
</div>
</div>
<!-- AI Insights -->
<div class="mt-6 pt-6 border-t border-gray-100">
<h3 class="text-lg font-semibold text-gray-900 mb-4">AI Insights</h3>
<div class="bg-gradient-to-r from-emerald-50 to-yellow-50 rounded-lg p-4 border border-emerald-100">
<p id="ai-insight" class="text-sm text-gray-700">--</p>
</div>
</div>
<!-- Actions -->
<div class="mt-6 pt-6 border-t border-gray-100">
<h3 class="text-lg font-semibold text-gray-900 mb-4">การดำเนินการที่แนะนำ</h3>
<div class="grid grid-cols-1 md:grid-cols-3 gap-3">
<button onclick="showActionModal('habit')" class="px-4 py-2 bg-emerald-500 text-white rounded-lg hover:bg-emerald-600 transition">
<i data-feather="check-square" class="w-4 h-4 inline mr-2"></i>
สร้างนิสัยใหม่
</button>
<button onclick="showActionModal('nutrition')" class="px-4 py-2 bg-yellow-500 text-white rounded-lg hover:bg-yellow-600 transition">
<i data-feather="coffee" class="w-4 h-4 inline mr-2"></i>
ปรับโภชนาการ
</button>
<button onclick="showActionModal('exercise')" class="px-4 py-2 bg-blue-500 text-white rounded-lg hover:bg-blue-600 transition">
<i data-feather="activity" class="w-4 h-4 inline mr-2"></i>
แผนการออกกำลังกาย
</button>
</div>
</div>
</div>
</div>
<!-- Other Tabs (Placeholder) -->
<div id="journal-tab" class="tab-content hidden">
<div class="bg-white rounded-xl p-8 shadow-sm text-center">
<i data-feather="book-open" class="w-12 h-12 text-gray-400 mx-auto mb-4"></i>
<h3 class="text-lg font-semibold text-gray-900">บันทึกประจำวัน</h3>
<p class="text-gray-500 mt-2">บันทึกอารมณ์ พลังงาน และกิจกรรมประจำวัน</p>
</div>
</div>
<div id="marketplace-tab" class="tab-content hidden">
<div class="bg-white rounded-xl p-8 shadow-sm text-center">
<i data-feather="shopping-bag" class="w-12 h-12 text-gray-400 mx-auto mb-4"></i>
<h3 class="text-lg font-semibold text-gray-900">Marketplace</h3>
<p class="text-gray-500 mt-2">ผลิตภัณฑ์และบริการที่แนะนำตามข้อมูลของคุณ</p>
</div>
</div>
<div id="profile-tab" class="tab-content hidden">
<div class="bg-white rounded-xl p-8 shadow-sm text-center">
<i data-feather="user" class="w-12 h-12 text-gray-400 mx-auto mb-4"></i>
<h3 class="text-lg font-semibold text-gray-900">โปรไฟล์</h3>
<p class="text-gray-500 mt-2">ข้อมูลส่วนตัวและการตั้งค่า</p>
</div>
</div>
</main>
<!-- Action Modal -->
<div id="actionModal" class="fixed inset-0 bg-black bg-opacity-50 hidden z-50 flex items-center justify-center p-4">
<div class="bg-white rounded-xl max-w-md w-full p-6">
<div class="flex justify-between items-center mb-4">
<h3 class="text-lg font-semibold text-gray-900" id="modalTitle">การดำเนินการ</h3>
<button onclick="closeActionModal()" class="text-gray-400 hover:text-gray-600">
<i data-feather="x" class="w-5 h-5"></i>
</button>
</div>
<div id="modalContent" class="text-sm text-gray-700">
<!-- Dynamic content -->
</div>
<div class="mt-4 flex gap-3">
<button onclick="closeActionModal()" class="flex-1 px-4 py-2 border border-gray-300 rounded-lg hover:bg-gray-50">ปิด</button>
<button onclick="confirmAction()" class="flex-1 px-4 py-2 bg-emerald-500 text-white rounded-lg hover:bg-emerald-600">ยืนยัน</button>
</div>
</div>
</div>
<script>
// METRICS CATALOG - 120+ METRICS
const METRICS_CATALOG = {
"schema_version": "1.2-demo",
"data_sources": [
{
"source_id": "smartband",
"name_en": "Smartband / Wearable",
"name_th": "สมาร์ทแบนด์ / อุปกรณ์สวมใส่",
"description": "ข้อมูลจากอุปกรณ์สวมใส่อัจฉริยะ",
"primary_metrics": [
{"metric_id": "timestamp", "name_en": "Timestamp", "name_th": "เวลา", "description": "เวลาที่บันทึก", "ai_notes": "จุดเวลาสำคัญ", "type": "datetime", "unit": "", "granularity": "timeseries", "nullable": false, "category": "wearable_base", "health_risks_targeted": [], "expected_benefits": ["การติดตาม"], "habit_concern": [], "marketplace_hooks": []},
{"metric_id": "heart_rate", "name_en": "Heart Rate", "name_th": "อัตราการเต้นหัวใจ", "description": "อัตราการเต้นหัวใจขณะนั้น", "ai_notes": "ตัวชี้วัดสุขภาพหัวใจ", "type": "number", "unit": "bpm", "granularity": "timeseries", "nullable": true, "category": "wearable_hr", "health_risks_targeted": ["โรคหัวใจ", "ความเครียด"], "expected_benefits": ["การตรวจสอบสุขภาพ"], "habit_concern": ["H001"], "marketplace_hooks": ["coq10", "magnesium"]},
{"metric_id": "resting_heart_rate", "name_en": "Resting Heart Rate", "name_th": "อัตราการเต้นหัวใจขณะพัก", "description": "อัตราการเต้นหัวใจเมื่อพัก", "ai_notes": "ส่วนสำคัญของฟิตเนส", "type": "number", "unit": "bpm", "granularity": "daily", "nullable": true, "category": "wearable_hr", "health_risks_targeted": ["ฟิตเนส"], "expected_benefits": ["การวัดความฟิต"], "habit_concern": ["H002"], "marketplace_hooks": ["cardio_program"]},
{"metric_id": "max_heart_rate", "name_en": "Max Heart Rate", "name_th": "อัตราการเต้นหัวใจสูงสุด", "description": "อัตราการเต้นหัวใจสูงสุด", "ai_notes": "ความสามารถของหัวใจ", "type": "number", "unit": "bpm", "granularity": "event", "nullable": true, "category": "wearable_hr", "health_risks_targeted": ["ประสิทธิภาพ"], "expected_benefits": ["วัดประสิทธิภาพ"], "habit_concern": ["H003"], "marketplace_hooks": ["hiit_program"]},
{"metric_id": "hrv_rmssd", "name_en": "HRV RMSSD", "name_th": "ความผันแปรของอัตราหัวใจ RMSSD", "description": "ค่า RMSSD ของ HRV", "ai_notes": "ตัวชี้วัดการฟื้นตัว", "type": "number", "unit": "ms", "granularity": "daily", "nullable": true, "category": "wearable_hrv", "health_risks_targeted": ["ความเครียด", "การฟื้นตัว"], "expected_benefits": ["การวัดการฟื้นตัว"], "habit_concern": ["H004"], "marketplace_hooks": ["meditation", "sleep_stack"]},
{"metric_id": "hrv_sdnn", "name_en": "HRV SDNN", "name_th": "ความผันแปรของอัตราหัวใจ SDNN", "description": "ค่า SDNN ของ HRV", "ai_notes": "สุขภาพระบบประสาท", "type": "number", "unit": "ms", "granularity": "daily", "nullable": true, "category": "wearable_hrv", "health_risks_targeted": ["สุขภาพระบบประสาท"], "expected_benefits": ["การตรวจสอบสุขภาพ"], "habit_concern": ["H005"], "marketplace_hooks": ["stress_management"]},
{"metric_id": "respiratory_rate", "name_en": "Respiratory Rate", "name_th": "อัตราการหายใจ", "description": "จำนวนครั้งต่อนาที", "ai_notes": "การทำงานของระบบหายใจ", "type": "number", "unit": "breaths/min", "granularity": "timeseries", "nullable": true, "category": "wearable_resp", "health_risks_targeted": ["ระบบหายใจ"], "expected_benefits": ["ตรวจสอบสุขภาพ"], "habit_concern": ["H006"], "marketplace_hooks": ["breathing_exercises"]},
{"metric_id": "blood_oxygen", "name_en": "Blood Oxygen", "name_th": "ออกซิเจนในเลือด", "description": "ระดับออกซิเจนในเลือด", "ai_notes": "การทำงานของปอด", "type": "number", "unit": "percent", "granularity": "timeseries", "nullable": true, "category": "wearable_o2", "health_risks_targeted": ["ปอด", "การหายใจ"], "expected_benefits": ["ตรวจสอบปอด"], "habit_concern": ["H007"], "marketplace_hooks": ["oxygen_therapy"]},
{"metric_id": "skin_temperature", "name_en": "Skin Temperature", "name_th": "อุณหภูมิผิวหนัง", "description": "อุณหภูมิที่ผิวหนัง", "ai_notes": "อุณหภูมิร่างกาย", "type": "number", "unit": "celsius", "granularity": "timeseries", "nullable": true, "category": "wearable_temp", "health_risks_targeted": ["ไข้", "อุณหภูมิ"], "expected_benefits": ["ตรวจไข้"], "habit_concern": ["H008"], "marketplace_hooks": ["thermometer"]},
{"metric_id": "temperature_deviation", "name_en": "Temperature Deviation", "name_th": "ค่าเบี่ยงเบนอุณหภูมิ", "description": "ค่าเบี่ยงเบนจากปกติ", "ai_notes": "การตรวจจับไข้", "type": "number", "unit": "celsius", "granularity": "daily", "nullable": true, "category": "wearable_temp", "health_risks_targeted": ["การติดเชื้อ"], "expected_benefits": ["ตรวจสอบไข้"], "habit_concern": ["H009"], "marketplace_hooks": ["immune_support"]},
{"metric_id": "sleep_score", "name_en": "Sleep Score", "name_th": "คะแนนการนอนหลับ", "description": "คะแนนคุณภาพการนอน", "ai_notes": "สรุปคุณภาพการนอน", "type": "number", "unit": "points", "granularity": "daily", "nullable": true, "category": "wearable_sleep", "health_risks_targeted": ["การนอนหลับ"], "expected_benefits": ["ปรับปรุงการนอน"], "habit_concern": ["H010"], "marketplace_hooks": ["sleep_stack", "magnesium"]},
{"metric_id": "sleep_start", "name_en": "Sleep Start", "name_th": "เวลาเริ่มนอน", "description": "เวลาที่เข้านอน", "ai_notes": "กำหนดการนอน", "type": "datetime", "unit": "", "granularity": "daily", "nullable": true, "category": "wearable_sleep", "health_risks_targeted": ["การนอน"], "expected_benefits": ["จัดการเวลานอน"], "habit_concern": ["H011"], "marketplace_hooks": ["sleep_schedule"]},
{"metric_id": "sleep_end", "name_en": "Sleep End", "name_th": "เวลาตื่น", "description": "เวลาที่ตื่นนอน", "ai_notes": "ความสม่ำเสมอ", "type": "datetime", "unit": "", "granularity": "daily", "nullable": true, "category": "wearable_sleep", "health_risks_targeted": ["การนอน"], "expected_benefits": ["จัดการเวลาตื่น"], "habit_concern": ["H012"], "marketplace_hooks": ["alarm_system"]},
{"metric_id": "sleep_duration", "name_en": "Sleep Duration", "name_th": "ระยะเวลาการนอน", "description": "ระยะเวลานอนหลับทั้งหมด", "ai_notes": "ปริมาณการนอน", "type": "number", "unit": "hours", "granularity": "daily", "nullable": true, "category": "wearable_sleep", "health_risks_targeted": ["การนอน"], "expected_benefits": ["พอดีการนอน"], "habit_concern": ["H013"], "marketplace_hooks": ["sleep_tracker"]},
{"metric_id": "sleep_efficiency", "name_en": "Sleep Efficiency", "name_th": "ประสิทธิภาพการนอน", "description": "เปอร์เซ็นต์การนอนหลับจริง", "ai_notes": "คุณภาพการนอน", "type": "number", "unit": "percent", "granularity": "daily", "nullable": true, "category": "wearable_sleep", "health_risks_targeted": ["คุณภาพนอน"], "expected_benefits": ["ปรับปรุงคุณภาพ"], "habit_concern": ["H014"], "marketplace_hooks": ["sleep_hygiene"]},
{"metric_id": "sleep_latency", "name_en": "Sleep Latency", "name_th": "ระยะเวลาก่อนหลับ", "description": "เวลาจากเข้าเตียงถึงหลับ", "ai_notes": "ความง่ายในการนอน", "type": "number", "unit": "minutes", "granularity": "daily", "nullable": true, "category": "wearable_sleep", "health_risks_targeted": ["การนอน"], "expected_benefits": ["การหลับเร็ว"], "habit_concern": ["H015"], "marketplace_hooks": ["melatonin"]},
{"metric_id": "wake_after_sleep_onset", "name_en": "Wake After Sleep Onset", "name_th": "ตื่นหลังเข้านอน", "description": "เวลาที่ตื่นในระหว่างนอน", "ai_notes": "การตื่นขึ้นมา", "type": "number", "unit": "minutes", "granularity": "daily", "nullable": true, "category": "wearable_sleep", "health_risks_targeted": ["การนอนต่อเนื่อง"], "expected_benefits": ["ลดการตื่น"], "habit_concern": ["H016"], "marketplace_hooks": ["deep_sleep_support"]},
{"metric_id": "sleep_stage_awake", "name_en": "Sleep Stage Awake", "name_th": "ระยะตื่นในขณะนอน", "description": "เวลาที่ตื่นระหว่างนอน", "ai_notes": "การตื่นระหว่างคืน", "type": "number", "unit": "minutes", "granularity": "daily", "nullable": true, "category": "wearable_sleep", "health_risks_targeted": ["การนอน"], "expected_benefits": ["การนอนต่อเนื่อง"], "habit_concern": ["H017"], "marketplace_hooks": ["sleep_continuity"]},
{"metric_id": "sleep_stage_light", "name_en": "Sleep Stage Light", "name_th": "การนอนลึกเล็กน้อย", "description": "ระยะเวลานอนลึกเล็กน้อย", "ai_notes": "Light sleep", "type": "number", "unit": "minutes", "granularity": "daily", "nullable": true, "category": "wearable_sleep", "health_risks_targeted": ["การนอน"], "expected_benefits": ["สมดุลการนอน"], "habit_concern": ["H018"], "marketplace_hooks": ["sleep_balance"]},
{"metric_id": "sleep_stage_deep", "name_en": "Sleep Stage Deep", "name_th": "การนอนลึก", "description": "ระยะเวลานอนลึก", "ai_notes": "Deep sleep", "type": "number", "unit": "minutes", "granularity": "daily", "nullable": true, "category": "wearable_sleep", "health_risks_targeted": ["การฟื้นฟู"], "expected_benefits": ["การฟื้นฟูร่างกาย"], "habit_concern": ["H019"], "marketplace_hooks": ["deep_sleep_enhancer"]},
{"metric_id": "sleep_stage_rem", "name_en": "Sleep Stage REM", "name_th": "การนอน REM", "description": "ระยะเวลานอน REM", "ai_notes": "REM sleep", "type": "number", "unit": "minutes", "granularity": "daily", "nullable": true, "category": "wearable_sleep", "health_risks_targeted": ["การฟื้นฟูสมอง"], "expected_benefits": ["การฟื้นฟูสมอง"], "habit_concern": ["H020"], "marketplace_hooks": ["rem_support"]},
{"metric_id": "recovery_score", "name_en": "Recovery Score", "name_th": "คะแนนการฟื้นตัว", "description": "คะแนนการฟื้นตัวรายวัน", "ai_notes": "การฟื้นตัวโดยรวม", "type": "number", "unit": "points", "granularity": "daily", "nullable": true, "category": "wearable_recovery", "health_risks_targeted": ["การฟื้นตัว"], "expected_benefits": ["การฟื้นตัวที่ดี"], "habit_concern": ["H021"], "marketplace_hooks": ["recovery_supplements"]},
{"metric_id": "strain_score", "name_en": "Strain Score", "name_th": "คะแนนความเหนื่อย", "description": "ระดับความเหนื่อยของร่างกาย", "ai_notes": "ความเหนื่อยสะสม", "type": "number", "unit": "points", "granularity": "daily", "nullable": true, "category": "wearable_strain", "health_risks_targeted": ["การใช้งานร่างกาย"], "expected_benefits": ["จัดการความเหนื่อย"], "habit_concern": ["H022"], "marketplace_hooks": ["energy_management"]},
{"metric_id": "stress_score", "name_en": "Stress Score", "name_th": "คะแนนความเครียด", "description": "ระดับความเครียด", "ai_notes": "ความเครียดรายวัน", "type": "number", "unit": "points", "granularity": "daily", "nullable": true, "category": "wearable_stress", "health_risks_targeted": ["ความเครียด"], "expected_benefits": ["จัดการความเครียด"], "habit_concern": ["H023"], "marketplace_hooks": ["stress_relief"]},
{"metric_id": "stress_load", "name_en": "Stress Load", "name_th": "ปริมาณความเครียด", "description": "ปริมาณความเครียดสะสม", "ai_notes": "ความเครียดสะสม", "type": "number", "unit": "points", "granularity": "daily", "nullable": true, "category": "wearable_stress", "health_risks_targeted": ["ความเครียดเรื้อรัง"], "expected_benefits": ["ลดความเครียด"], "habit_concern": ["H024"], "marketplace_hooks": ["adaptogens"]},
{"metric_id": "steps", "name_en": "Steps", "name_th": "จำนวนก้าวเดิน", "description": "จำนวนก้าวเดินทั้งหมด", "ai_notes": "การเคลื่อนไหว", "type": "number", "unit": "steps", "granularity": "daily", "nullable": true, "category": "wearable_activity", "health_risks_targeted": ["การออกกำลังกาย"], "expected_benefits": ["การเคลื่อนไหว"], "habit_concern": ["H025"], "marketplace_hooks": ["step_counter"]},
{"metric_id": "distance", "name_en": "Distance", "name_th": "ระยะทาง", "description": "ระยะทางที่เดิน", "ai_notes": "ระยะทางรายวัน", "type": "number", "unit": "km", "granularity": "daily", "nullable": true, "category": "wearable_activity", "health_risks_targeted": ["การเคลื่อนไหว"], "expected_benefits": ["การวัดระยะทาง"], "habit_concern": ["H026"], "marketplace_hooks": ["gps_tracker"]},
{"metric_id": "active_minutes", "name_en": "Active Minutes", "name_th": "นาทีที่เคลื่อนไหว", "description": "เวลาที่เคลื่อนไหวร่างกาย", "ai_notes": "การเคลื่อนไหว", "type": "number", "unit": "minutes", "granularity": "daily", "nullable": true, "category": "wearable_activity", "health_risks_targeted": ["การออกกำลังกาย"], "expected_benefits": ["การเคลื่อนไหว"], "habit_concern": ["H027"], "marketplace_hooks": ["activity_tracker"]},
{"metric_id": "calories_active", "name_en": "Active Calories", "name_th": "แคลอรี่จากการเคลื่อนไหว", "description": "แคลอรี่ที่เผาผลาญ", "ai_notes": "การเผาผลาญ", "type": "number", "unit": "kcal", "granularity": "daily", "nullable": true, "category": "wearable_activity", "health_risks_targeted": ["การเผาผลาญ"], "expected_benefits": ["การจัดการน้ำหนัก"], "habit_concern": ["H028"], "marketplace_hooks": ["calorie_tracker"]},
{"metric_id": "calories_total", "name_en": "Total Calories", "name_th": "แคลอรี่ทั้งหมด", "description": "แคลอรี่ทั้งหมดที่เผา", "ai_notes": "การเผาผลาญรวม", "type": "number", "unit": "kcal", "granularity": "daily", "nullable": true, "category": "wearable_activity", "health_risks_targeted": ["การเผาผลาญ"], "expected_benefits": ["การจัดการน้ำหนัก"], "habit_concern": ["H029"], "marketplace_hooks": ["metabolism_boost"]},
{"metric_id": "sedentary_time", "name_en": "Sedentary Time", "name_th": "เวลานั่งนิ่ง", "description": "เวลาที่ไม่เคลื่อนไหว", "ai_notes": "พฤติกรรมนั่ง", "type": "number", "unit": "minutes", "granularity": "daily", "nullable": true, "category": "wearable_activity", "health_risks_targeted": ["พฤติกรรมนั่ง"], "expected_benefits": ["ลดเวลานั่ง"], "habit_concern": ["H030"], "marketplace_hooks": ["standing_desk"]},
{"metric_id": "workout_sessions", "name_en": "Workout Sessions", "name_th": "จำนวนการออกกำลังกาย", "description": "ครั้งที่ออกกำลังกาย", "ai_notes": "ความสม่ำเสมอ", "type": "number", "unit": "sessions", "granularity": "daily", "nullable": true, "category": "wearable_workout", "health_risks_targeted": ["การออกกำลังกาย"], "expected_benefits": ["สร้างนิสัยออกกำลังกาย"], "habit_concern": ["H031"], "marketplace_hooks": ["workout_plans"]},
{"metric_id": "workout_type", "name_en": "Workout Type", "name_th": "ประเภทการออกกำลังกาย", "description": "ประเภทของการฝึก", "ai_notes": "ความหลากหลาย", "type": "string", "unit": "", "granularity": "event", "nullable": true, "category": "wearable_workout", "health_risks_targeted": ["การฝึก"], "expected_benefits": ["ความสมดุล"], "habit_concern": ["H032"], "marketplace_hooks": ["diverse_workouts"]},
{"metric_id": "workout_duration", "name_en": "Workout Duration", "name_th": "ระยะเวลาออกกำลังกาย", "description": "เวลาที่ออกกำลังกาย", "ai_notes": "ระยะเวลาฝึก", "type": "number", "unit": "minutes", "granularity": "event", "nullable": true, "category": "wearable_workout", "health_risks_targeted": ["การออกกำลังกาย"], "expected_benefits": ["การวัดปริมาณ"], "habit_concern": ["H033"], "marketplace_hooks": ["training_timer"]},
{"metric_id": "workout_avg_hr", "name_en": "Workout Avg HR", "name_th": "อัตราหัวใจเฉลี่ยระหว่างออกกำลังกาย", "description": "HR เฉลี่ยในการออกกำลังกาย", "ai_notes": "ความเข้ม", "type": "number", "unit": "bpm", "granularity": "event", "nullable": true, "category": "wearable_workout", "health_risks_targeted": ["ความเข้ม"], "expected_benefits": ["ควบคุมความเข้ม"], "habit_concern": ["H034"], "marketplace_hooks": ["hr_monitor"]},
{"metric_id": "workout_max_hr", "name_en": "Workout Max HR", "name_th": "อัตราหัวใจสูงสุดระหว่างออกกำลังกาย", "description": "HR สูงสุดในการออกกำลังกาย", "ai_notes": "ขีดจำกัด", "type": "number", "unit": "bpm", "granularity": "event", "nullable": true, "category": "wearable_workout", "health_risks_targeted": ["ความเข้ม"], "expected_benefits": ["ความปลอดภัย"], "habit_concern": ["H035"], "marketplace_hooks": ["safety_limits"]},
{"metric_id": "workout_calories", "name_en": "Workout Calories", "name_th": "แคลอรี่จากการออกกำลังกาย", "description": "แคลอรี่ที่เผาในการออกกำลังกาย", "ai_notes": "การเผาผลาญ", "type": "number", "unit": "kcal", "granularity": "event", "nullable": true, "category": "wearable_workout", "health_risks_targeted": ["การเผาผลาญ"], "expected_benefits": ["การจัดการน้ำหนัก"], "habit_concern": ["H036"], "marketplace_hooks": ["calorie_tracker"]},
{"metric_id": "hr_zone_1_min", "name_en": "HR Zone 1 Minutes", "name_th": "นาทีในโซน HR 1", "description": "เวลาในโซนอัตราหัวใจ 1", "ai_notes": "การฝึกโซน 1", "type": "number", "unit": "minutes", "granularity": "daily", "nullable": true, "category": "wearable_zones", "health_risks_targeted": ["การฝึก"], "expected_benefits": ["การฝึกพื้นฐาน"], "habit_concern": ["H037"], "marketplace_hooks": ["zone_training"]},
{"metric_id": "hr_zone_2_min", "name_en": "HR Zone 2 Minutes", "name_th": "นาทีในโซน HR 2", "description": "เวลาในโซนอัตราหัวใจ 2", "ai_notes": "การฝึกโซน 2", "type": "number", "unit": "minutes", "granularity": "daily", "nullable": true, "category": "wearable_zones", "health_risks_targeted": ["การฝึก"], "expected_benefits": ["การสร้างพื้นฐาน"], "habit_concern": ["H038"], "marketplace_hooks": ["base_training"]},
{"metric_id": "hr_zone_3_min", "name_en": "HR Zone 3 Minutes", "name_th": "นาทีในโซน HR 3", "description": "เวลาในโซนอัตราหัวใจ 3", "ai_notes": "การฝึกโซน 3", "type": "number", "unit": "minutes", "granularity": "daily", "nullable": true, "category": "wearable_zones", "health_risks_targeted": ["การฝึก"], "expected_benefits": ["การฝึกกลาง"], "habit_concern": ["H039"], "marketplace_hooks": ["moderate_training"]},
{"metric_id": "hr_zone_4_min", "name_en": "HR Zone 4 Minutes", "name_th": "นาทีในโซน HR 4", "description": "เวลาในโซนอัตราหัวใจ 4", "ai_notes": "การฝึกโซน 4", "type": "number", "unit": "minutes", "granularity": "daily", "nullable": true, "category": "wearable_zones", "health_risks_targeted": ["การฝึก"], "expected_benefits": ["การฝึกเข้ม"], "habit_concern": ["H040"], "marketplace_hooks": ["intense_training"]},
{"metric_id": "hr_zone_5_min", "name_en": "HR Zone 5 Minutes", "name_th": "นาทีในโซน HR 5", "description": "เวลาในโซนอัตราหัวใจ 5", "ai_notes": "การฝึกโซน 5", "type": "number", "unit": "minutes", "granularity": "daily", "nullable": true, "category": "wearable_zones", "health_risks_targeted": ["การฝึก"], "expected_benefits": ["การฝึกสูงสุด"], "habit_concern": ["H041"], "marketplace_hooks": ["max_training"]},
{"metric_id": "vo2max", "name_en": "VO2 Max", "name_th": "ค่า VO2 Max", "description": "ปริมาณออกซิเจนสูงสุด", "ai_notes": "ความฟิตสูงสุด", "type": "number", "unit": "ml/kg/min", "granularity": "weekly", "nullable": true, "category": "wearable_fitness", "health_risks_targeted": ["ความฟิต"], "expected_benefits": ["วัดความฟิต"], "habit_concern": ["H042"], "marketplace_hooks": ["fitness_test"]},
{"metric_id": "training_load", "name_en": "Training Load", "name_th": "ปริมาณการฝึก", "description": "ปริมาณการฝึกสะสม", "ai_notes": "การโหลดการฝึก", "type": "number", "unit": "points", "granularity": "daily", "nullable": true, "category": "wearable_fitness", "health_risks_targeted": ["การฝึก"], "expected_benefits": ["จัดการการฝึก"], "habit_concern": ["H043"], "marketplace_hooks": ["load_management"]},
{"metric_id": "step_cadence", "name_en": "Step Cadence", "name_th": "ความเร็วก้าวเดิน", "description": "ก้าวต่อนาที", "ai_notes": "ความเร็วการเดิน", "type": "number", "unit": "steps/min", "granularity": "event", "nullable": true, "category": "wearable_activity", "health_risks_targeted": ["การเดิน"], "expected_benefits": ["ปรับปรุงการเดิน"], "habit_concern": ["H044"], "marketplace_hooks": ["cadence_coach"]},
{"metric_id": "avg_pace", "name_en": "Average Pace", "name_th": "ความเร็วเฉลี่ย", "description": "ความเร็วในการวิ่ง", "ai_notes": "Pace การวิ่ง", "type": "number", "unit": "min/km", "granularity": "event", "nullable": true, "category": "wearable_activity", "health_risks_targeted": ["การวิ่ง"], "expected_benefits": ["ปรับปรุงความเร็ว"], "habit_concern": ["H045"], "marketplace_hooks": ["pace_tracker"]},
{"metric_id": "workout_distance_km", "name_en": "Workout Distance", "name_th": "ระยะทางการออกกำลังกาย", "description": "ระยะทางที่วิ่ง/ปั่น", "ai_notes": "ระยะทางฝึก", "type": "number", "unit": "km", "granularity": "event", "nullable": true, "category": "wearable_workout", "health_risks_targeted": ["การวิ่ง/ปั่น"], "expected_benefits": ["วัดระยะทาง"], "habit_concern": ["H046"], "marketplace_hooks": ["distance_tracker"]}
]
},
{
"source_id": "myscale",
"name_en": "MyScale / Body Composition",
"name_th": "MyScale / ส่วนประกอบร่างกาย",
"description": "การวัดส่วนประกอบร่างกาย",
"primary_metrics": [
{"metric_id": "timestamp", "name_en": "Timestamp", "name_th": "เวลา", "description": "เวลาที่ชั่ง", "ai_notes": "จุดเวลาวัด", "type": "datetime", "unit": "", "granularity": "event", "nullable": false, "category": "body_base", "health_risks_targeted": [], "expected_benefits": ["การติดตาม"], "habit_concern": [], "marketplace_hooks": []},
{"metric_id": "weight", "name_en": "Weight", "name_th": "น้ำหนัก", "description": "น้ำหนักร่างกาย", "ai_notes": "น้ำหนักรายวัน", "type": "number", "unit": "kg", "granularity": "daily", "nullable": true, "category": "body_weight", "health_risks_targeted": ["น้ำหนักเกิน"], "expected_benefits": ["จัดการน้ำหนัก"], "habit_concern": ["M001"], "marketplace_hooks": ["weight_management", "protein_powder"]},
{"metric_id": "body_age", "name_en": "Body Age", "name_th": "อายุร่างกาย", "description": "อายุทางชีวภาพ", "ai_notes": "สุขภาพร่างกาย", "type": "number", "unit": "years", "granularity": "weekly", "nullable": true, "category": "body_health", "health_risks_targeted": ["สุขภาพทั่วไป"], "expected_benefits": ["การปรับปรุงสุขภาพ"], "habit_concern": ["M002"], "marketplace_hooks": ["anti_aging"]},
{"metric_id": "body_water_percent", "name_en": "Body Water Percent", "name_th": "เปอร์เซ็นต์น้ำในร่างกาย", "description": "สัดส่วนน้ำในร่างกาย", "ai_notes": "ความชุ่มชื้น", "type": "number", "unit": "percent", "granularity": "weekly", "nullable": true, "category": "body_composition", "health_risks_targeted": ["การขาดน้ำ"], "expected_benefits": ["สุขภาพดี"], "habit_concern": ["M003"], "marketplace_hooks": ["hydration"]},
{"metric_id": "body_water_mass", "name_en": "Body Water Mass", "name_th": "มวลน้ำในร่างกาย", "description": "ปริมาณน้ำทั้งหมด", "ai_notes": "ปริมาณน้ำ", "type": "number", "unit": "kg", "granularity": "weekly", "nullable": true, "category": "body_composition", "health_risks_targeted": ["สมดุลของเหลว"], "expected_benefits": ["สมดุลร่างกาย"], "habit_concern": ["M004"], "marketplace_hooks": ["electrolytes"]},
{"metric_id": "protein_mass", "name_en": "Protein Mass", "name_th": "มวลโปรตีน", "description": "ปริมาณโปรตีนในร่างกาย", "ai_notes": "มวลกล้ามเนื้อ", "type": "number", "unit": "kg", "granularity": "weekly", "nullable": true, "category": "body_composition", "health_risks_targeted": ["สร้างกล้ามเนื้อ"], "expected_benefits": ["กล้ามเนื้อแข็งแกร่ง"], "habit_concern": ["M005"], "marketplace_hooks": ["protein_supplements", "bcaa"]},
{"metric_id": "protein_percent", "name_en": "Protein Percent", "name_th": "เปอร์เซ็นต์โปรตีน", "description": "สัดส่วนโปรตีน", "ai_notes": "สัดส่วนโปรตีน", "type": "number", "unit": "percent", "granularity": "weekly", "nullable": true, "category": "body_composition", "health_risks_targeted": ["สร้างกล้ามเนื้อ"], "expected_benefits": ["สมดุลโภชนาการ"], "habit_concern": ["M006"], "marketplace_hooks": ["protein_foods"]},
{"metric_id": "fat_mass", "name_en": "Fat Mass", "name_th": "มวลไขมัน", "description": "ปริมาณไขมันทั้งหมด", "ai_notes": "ปริมาณไขมัน", "type": "number", "unit": "kg", "granularity": "weekly", "nullable": true, "category": "body_fat", "health_risks_targeted": ["ไขมันสูง"], "expected_benefits": ["ลดไขมัน"], "habit_concern": ["M007"], "marketplace_hooks": ["fat_burner", "diet_plan"]},
{"metric_id": "body_fat_percent", "name_en": "Body Fat Percent", "name_th": "เปอร์เซ็นต์ไขมันในร่างกาย", "description": "สัดส่วนไขมัน", "ai_notes": "สัดส่วนไขมัน", "type": "number", "unit": "percent", "granularity": "weekly", "nullable": true, "category": "body_fat", "health_risks_targeted": ["ไขมันสูง"], "expected_benefits": ["สรีระที่ดี"], "habit_concern": ["M008"], "marketplace_hooks": ["body_composition_tracker"]},
{"metric_id": "bone_mass", "name_en": "Bone Mass", "name_th": "มวลกระดูก", "description": "มวลกระดูกทั้งหมด", "ai_notes": "ความแข็งแกร่งกระดูก", "type": "number", "unit": "kg", "granularity": "monthly", "nullable": true, "category": "body_bone", "health_risks_targeted": ["กระดูกพรุน"], "expected_benefits": ["กระดูกแข็งแกร่ง"], "habit_concern": ["M009"], "marketplace_hooks": ["calcium", "vitamin_d3"]},
{"metric_id": "muscle_mass", "name_en": "Muscle Mass", "name_th": "มวลกล้ามเนื้อ", "description": "มวลกล้ามเนื้อทั้งหมด", "ai_notes": "ปริมาณกล้ามเนื้อ", "type": "number", "unit": "kg", "granularity": "weekly", "nullable": true, "category": "body_muscle", "health_risks_targeted": ["กล้ามเนื้อน้อย"], "expected_benefits": ["กล้ามเนื้อแข็งแกร่ง"], "habit_concern": ["M010"], "marketplace_hooks": ["muscle_builder", "creatine"]},
{"metric_id": "muscle_rate", "name_en": "Muscle Rate", "name_th": "อัตราส่วนกล้ามเนื้อ", "description": "สัดส่วนกล้ามเนื้อ", "ai_notes": "ความสมดุลกล้ามเนื้อ", "type": "number", "unit": "percent", "granularity": "weekly", "nullable": true, "category": "body_muscle", "health_risks_targeted": ["สร้างกล้ามเนื้อ"], "expected_benefits": ["สรีระที่ดี"], "habit_concern": ["M011"], "marketplace_hooks": ["strength_training"]},
{"metric_id": "subcutaneous_fat_percent", "name_en": "Subcutaneous Fat Percent", "name_th": "เปอร์เซ็นต์ไขมันใต้ผิวหนัง", "description": "ไขมันใต้ผิวหนัง", "ai_notes": "ไขมันชั้นผิว", "type": "number", "unit": "percent", "granularity": "weekly", "nullable": true, "category": "body_fat", "health_risks_targeted": ["ไขมันสะสม"], "expected_benefits": ["ลดไขมันผิวหนัง"], "habit_concern": ["M012"], "marketplace_hooks": ["fat_loss_program"]},
{"metric_id": "ideal_body_weight", "name_en": "Ideal Body Weight", "name_th": "น้ำหนักเหมาะสม", "description": "น้ำหนักเป้าหมาย", "ai_notes": "น้ำหนักที่เหมาะสม", "type": "number", "unit": "kg", "granularity": "monthly", "nullable": true, "category": "body_weight", "health_risks_targeted": ["น้ำหนัก"], "expected_benefits": ["เป้าหมายสุขภาพ"], "habit_concern": ["M013"], "marketplace_hooks": ["weight_goal_tracker"]},
{"metric_id": "bmi", "name_en": "BMI", "name_th": "ดัชนีมวลกาย", "description": "Body Mass Index", "ai_notes": "ดัชนีมวลกาย", "type": "number", "unit": "kg/m2", "granularity": "weekly", "nullable": true, "category": "body_weight", "health_risks_targeted": ["น้ำหนักเกิน"], "expected_benefits": ["สุขภาพดี"], "habit_concern": ["M014"], "marketplace_hooks": ["bmi_calculator"]},
{"metric_id": "visceral_fat_level", "name_en": "Visceral Fat Level", "name_th": "ระดับไขมันอวัยวะ", "description": "ไขมันรอบอวัยวะ", "ai_notes": "ไขมันอันตราย", "type": "number", "unit": "level", "granularity": "weekly", "nullable": true, "category": "body_fat", "health_risks_targeted": ["โรคเรื้อรัง"], "expected_benefits": ["ลดความเสี่ยง"], "habit_concern": ["M015"], "marketplace_hooks": ["visceral_fat_reducer"]},
{"metric_id": "obesity_level", "name_en": "Obesity Level", "name_th": "ระดับความอ้วน", "description": "ระดับความอ้วน", "ai_notes": "ประเมินความอ้วน", "type": "string", "unit": "", "granularity": "weekly", "nullable": true, "category": "body_weight", "health_risks_targeted": ["ความอ้วน"], "expected_benefits": ["จัดการน้ำหนัก"], "habit_concern": ["M016"], "marketplace_hooks": ["obesity_program"]},
{"metric_id": "skeletal_muscle_mass", "name_en": "Skeletal Muscle Mass", "name_th": "มวลกล้ามเนื้อโครงร่าง", "description": "กล้ามเนื้อโครงร่าง", "ai_notes": "กล้ามเนื้อหลัก", "type": "number", "unit": "kg", "granularity": "weekly", "nullable": true, "category": "body_muscle", "health_risks_targeted": ["สร้างกล้ามเนื้อ"], "expected_benefits": ["กำลัง"], "habit_concern": ["M017"], "marketplace_hooks": ["strength_program"]},
{"metric_id": "bmr", "name_en": "BMR", "name_th": "อัตราการเผาผลาญขณะพัก", "description": "Basal Metabolic Rate", "ai_notes": "การเผาผลาญพื้นฐาน", "type": "number", "unit": "kcal", "granularity": "monthly", "nullable": true, "category": "body_metabolism", "health_risks_targeted": ["เผาผลาญ"], "expected_benefits": ["จัดการพลังงาน"], "habit_concern": ["M018"], "marketplace_hooks": ["metabolism_booster"]},
{"metric_id": "left_leg_fat", "name_en": "Left Leg Fat", "name_th": "ไขมันขาซ้าย", "description": "ไขมันที่ขาซ้าย", "ai_notes": "สมดุลขา", "type": "number", "unit": "kg", "granularity": "weekly", "nullable": true, "category": "body_segmental", "health_risks_targeted": ["สมดุลร่างกาย"], "expected_benefits": ["สมดุล"], "habit_concern": ["M019"], "marketplace_hooks": ["leg_training"]},
{"metric_id": "right_leg_fat", "name_en": "Right Leg Fat", "name_th": "ไขมันขาขวา", "description": "ไขมันที่ขาขวา", "ai_notes": "สมดุลขา", "type": "number", "unit": "kg", "granularity": "weekly", "nullable": true, "category": "body_segmental", "health_risks_targeted": ["สมดุลร่างกาย"], "expected_benefits": ["สมดุล"], "habit_concern": ["M020"], "marketplace_hooks": ["leg_training"]},
{"metric_id": "left_arm_fat", "name_en": "Left Arm Fat", "name_th": "ไขมันแขนซ้าย", "description": "ไขมันที่แขนซ้าย", "ai_notes": "สมดุลแขน", "type": "number", "unit": "kg", "granularity": "weekly", "nullable": true, "category": "body_segmental", "health_risks_targeted": ["สมดุลร่างกาย"], "expected_benefits": ["สมดุล"], "habit_concern": ["M021"], "marketplace_hooks": ["arm_training"]},
{"metric_id": "right_arm_fat", "name_en": "Right Arm Fat", "name_th": "ไขมันแขนขวา", "description": "ไขมันที่แขนขวา", "ai_notes": "สมดุลแขน", "type": "number", "unit": "kg", "granularity": "weekly", "nullable": true, "category": "body_segmental", "health_risks_targeted": ["สมดุลร่างกาย"], "expected_benefits": ["สมดุล"], "habit_concern": ["M022"], "marketplace_hooks": ["arm_training"]},
{"metric_id": "left_leg_muscle", "name_en": "Left Leg Muscle", "name_th": "กล้ามเนื้อขาซ้าย", "description": "กล้ามเนื้อที่ขาซ้าย", "ai_notes": "กำลังขา", "type": "number", "unit": "kg", "granularity": "weekly", "nullable": true, "category": "body_segmental", "health_risks_targeted": ["สร้างกล้ามเนื้อ"], "expected_benefits": ["กำลังขา"], "habit_concern": ["M023"], "marketplace_hooks": ["leg_exercises"]},
{"metric_id": "right_leg_muscle", "name_en": "Right Leg Muscle", "name_th": "กล้ามเนื้อขาขวา", "description": "กล้ามเนื้อที่ขาขวา", "ai_notes": "กำลังขา", "type": "number", "unit": "kg", "granularity": "weekly", "nullable": true, "category": "body_segmental", "health_risks_targeted": ["สร้างกล้ามเนื้อ"], "expected_benefits": ["กำลังขา"], "habit_concern": ["M024"], "marketplace_hooks": ["leg_exercises"]},
{"metric_id": "left_arm_muscle", "name_en": "Left Arm Muscle", "name_th": "กล้ามเนื้อแขนซ้าย", "description": "กล้ามเนื้อที่แขนซ้าย", "ai_notes": "กำลังแขน", "type": "number", "unit": "kg", "granularity": "weekly", "nullable": true, "category": "body_segmental", "health_risks_targeted": ["สร้างกล้ามเนื้อ"], "expected_benefits": ["กำลังแขน"], "habit_concern": ["M025"], "marketplace_hooks": ["arm_exercises"]},
{"metric_id": "right_arm_muscle", "name_en": "Right Arm Muscle", "name_th": "กล้ามเนื้อแขนขวา", "description": "กล้ามเนื้อที่แขนขวา", "ai_notes": "กำลังแขน", "type": "number", "unit": "kg", "granularity": "weekly", "nullable": true, "category": "body_segmental", "health_risks_targeted": ["สร้างกล้ามเนื้อ"], "expected_benefits": ["กำลังแขน"], "habit_concern": ["M026"], "marketplace_hooks": ["arm_exercises"]},
{"metric_id": "trunk_fat", "name_en": "Trunk Fat", "name_th": "ไขมันลำตัว", "description": "ไขมันส่วนลำตัว", "ai_notes": "ไขมันลำตัว", "type": "number", "unit": "kg", "granularity": "weekly", "nullable": true, "category": "body_segmental", "health_risks_targeted": ["ไขมันลำตัว"], "expected_benefits": ["ลดไขมันลำตัว"], "habit_concern": ["M027"], "marketplace_hooks": ["core_training"]},
{"metric_id": "trunk_muscle", "name_en": "Trunk Muscle", "name_th": "กล้ามเนื้อลำตัว", "description": "กล้ามเนื้อส่วนลำตัว", "ai_notes": "กล้ามเนื้อลำตัว", "type": "number", "unit": "kg", "granularity": "weekly", "nullable": true, "category": "body_segmental", "health_risks_targeted": ["กล้ามเนื้อลำตัว"], "expected_benefits": ["กำลังลำตัว"], "habit_concern": ["M028"], "marketplace_hooks": ["core_exercises"]},
{"metric_id": "body_type", "name_en": "Body Type", "name_th": "รูปร่างร่างกาย", "description": "ประเภทรูปร่าง", "ai_notes": "แบบร่างกาย", "type": "string", "unit": "", "granularity": "monthly", "nullable": true, "category": "body_type", "health_risks_targeted": ["รูปร่าง"], "expected_benefits": ["เข้าใจร่างกาย"], "habit_concern": ["M029"], "marketplace_hooks": ["body_type_program"]},
{"metric_id": "fat_free_body_weight", "name_en": "Fat Free Body Weight", "name_th": "น้ำหนักไม่รวมไขมัน", "description": "น้ำหนักที่ไม่ใช่ไขมัน", "ai_notes": "มวลไขมันต่ำ", "type": "number", "unit": "kg", "granularity": "weekly", "nullable": true, "category": "body_composition", "health_risks_targeted": ["สร้างกล้ามเนื้อ"], "expected_benefits": ["สร้างมวลกล้ามเนื้อ"], "habit_concern": ["M030"], "marketplace_hooks": ["lean_mass_builder"]},
{"metric_id": "segmental", "name_en": "Segmental Analysis", "name_th": "การวิเคราะห์ตามส่วน", "description": "ข้อมูลตามส่วนต่างๆ", "ai_notes": "วิเคราะห์ตามส่วน", "type": "object", "unit": "", "granularity": "weekly", "nullable": true, "category": "body_segmental", "health_risks_targeted": ["สมดุลร่างกาย"], "expected_benefits": ["สมดุล"], "habit_concern": ["M031"], "marketplace_hooks": ["segmental_tracker"]}
]
},
{
"source_id": "blood",
"name_en": "Blood / Lab Biomarkers",
"name_th": "การตรวจเลือด / ชีวมาตร",
"description": "การตรวจชีวมาตรจากเลือด",
"primary_metrics": [
{"metric_id": "test_date", "name_en": "Test Date", "name_th": "วันที่ตรวจ", "description": "วันที่ตรวจเลือด", "ai_notes": "จุดเวลาตรวจ", "type": "date", "unit": "", "granularity": "event", "nullable": false, "category": "lab_meta", "health_risks_targeted": [], "expected_benefits": ["การติดตาม"], "habit_concern": [], "marketplace_hooks": []},
{"metric_id": "wbc", "name_en": "White Blood Cells", "name_th": "เม็ดเลือดขาว", "description": "จำนวนเม็ดเลือดขาว", "ai_notes": "ระบบภูมิคุ้มกัน", "type": "number", "unit": "10^3/µL", "granularity": "event", "nullable": true, "category": "blood_cbc", "health_risks_targeted": ["การติดเชื้อ"], "expected_benefits": ["ตรวจสอบภูมิคุ้มกัน"], "habit_concern": ["B001"], "marketplace_hooks": ["immune_support"]},
{"metric_id": "rbc", "name_en": "Red Blood Cells", "name_th": "เม็ดเลือดแดง", "description": "จำนวนเม็ดเลือดแดง", "ai_notes": "การขนส่งออกซิเจน", "type": "number", "unit": "10^6/µL", "granularity": "event", "nullable": true, "category": "blood_cbc", "health_risks_targeted": ["โลหิตจาง"], "expected_benefits": ["ตรวจสอบโลหิต"], "habit_concern": ["B002"], "marketplace_hooks": ["iron_supplements"]},
{"metric_id": "hb", "name_en": "Hemoglobin", "name_th": "ฮีโมโกลบิน", "description": "ระดับฮีโมโกลบิน", "ai_notes": "การขนส่งออกซิเจน", "type": "number", "unit": "g/dL", "granularity": "event", "nullable": true, "category": "blood_cbc", "health_risks_targeted": ["โลหิตจาง"], "expected_benefits": ["ตรวจสอบโลหิต"], "habit_concern": ["B003"], "marketplace_hooks": ["iron", "b12"]},
{"metric_id": "hct", "name_en": "Hematocrit", "name_th": "ฮีแม�อคริต", "description": "สัดส่วนเม็ดเลือดแดง", "ai_notes": "ความเข้มข้นเลือด", "type": "number", "unit": "percent", "granularity": "event", "nullable": true, "category": "blood_cbc", "health_risks_targeted": ["โลหิต"], "expected_benefits": ["ตรวจสอบโลหิต"], "habit_concern": ["B004"], "marketplace_hooks": ["blood_health"]},
{"metric_id": "mcv", "name_en": "Mean Corpuscular Volume", "name_th": "ปริมาตรเฉลี่ยเม็ดเลือดแดง", "description": "ขนาดเฉลี่ยเม็ดเลือดแดง", "ai_notes": "ขนาดเม็ดเลือด", "type": "number", "unit": "fL", "granularity": "event", "nullable": true, "category": "blood_cbc", "health_risks_targeted": ["โลหิต"], "expected_benefits": ["ตรวจสอบโลหิต"], "habit_concern": ["B005"], "marketplace_hooks": ["b12", "folate"]},
{"metric_id": "mch", "name_en": "Mean Corpuscular Hemoglobin", "name_th": "ฮีโมโกลบินเฉลี่ยเม็ดเลือดแดง", "description": "ฮีโมโกลบินเฉลี่ย", "ai_notes": "ฮีโมโกลบินเฉลี่ย", "type": "number", "unit": "pg", "granularity": "event", "nullable": true, "category": "blood_cbc", "health_risks_targeted": ["โลหิต"], "expected_benefits": ["ตรวจสอบโลหิต"], "habit_concern": ["B006"], "marketplace_hooks": ["iron"]},
{"metric_id": "mchc", "name_en": "Mean Corpuscular Hb Concentration", "name_th": "ความเข้มข้นฮีโมโกลบินเฉลี่ย", "description": "ความเข้มข้นเฉลี่ย", "ai_notes": "ความเข้มข้น Hb", "type": "number", "unit": "g/dL", "granularity": "event", "nullable": true, "category": "blood_cbc", "health_risks_targeted": ["โลหิต"], "expected_benefits": ["ตรวจสอบโลหิต"], "habit_concern": ["B007"], "marketplace_hooks": ["iron"]},
{"metric_id": "rdw", "name_en": "Red Cell Distribution Width", "name_th": "ความแปรผันของขนาดเม็ดเลือดแดง", "description": "ความแปรผันขนาด", "ai_notes": "ความสม่ำเสมอ", "type": "number", "unit": "percent", "granularity": "event", "nullable": true, "category": "blood_cbc", "health_risks_targeted": ["โลหิต"], "expected_benefits": ["ตรวจสอบโลหิต"], "habit_concern": ["B008"], "marketplace_hooks": ["b12"]},
{"metric_id": "plt", "name_en": "Platelets", "name_th": "เกล็ดเลือด", "description": "จำนวนเกล็ดเลือด", "ai_notes": "การแข็งตัวของเลือด", "type": "number", "unit": "10^3/µL", "granularity": "event", "nullable": true, "category": "blood_cbc", "health_risks_targeted": ["การแข็งตัวของเลือด"], "expected_benefits": ["ตรวจสอบการแข็งตัว"], "habit_concern": ["B009"], "marketplace_hooks": ["vitamin_k"]},
{"metric_id": "neutrophils_percent", "name_en": "Neutrophils Percent", "name_th": "เปอร์เซ็นต์นิวโทรฟิล", "description": "สัดส่วนนิวโทรฟิล", "ai_notes": "การต่อสู้แบคทีเรีย", "type": "number", "unit": "percent", "granularity": "event", "nullable": true, "category": "blood_cbc", "health_risks_targeted": ["การติดเชื้อแบคทีเรีย"], "expected_benefits": ["ตรวจสอบภูมิคุ้มกัน"], "habit_concern": ["B010"], "marketplace_hooks": ["immune_boosters"]},
{"metric_id": "lymphocytes_percent", "name_en": "Lymphocytes Percent", "name_th": "เปอร์เซ็นต์ลิมโฟไซต์", "description": "สัดส่วนลิมโฟไซต์", "ai_notes": "การต่อสู้ไวรัส", "type": "number", "unit": "percent", "granularity": "event", "nullable": true, "category": "blood_cbc", "health_risks_targeted": ["การติดเชื้อไวรัส"], "expected_benefits": ["ตรวจสอบภูมิคุ้มกัน"], "habit_concern": ["B011"], "marketplace_hooks": ["antiviral_support"]},
{"metric_id": "monocytes_percent", "name_en": "Monocytes Percent", "name_th": "เปอร์เซ็นต์โมโนไซต์", "description": "สัดส่วนโมโนไซต์", "ai_notes": "การกินเซลล์", "type": "number", "unit": "percent", "granularity": "event", "nullable": true, "category": "blood_cbc", "health_risks_targeted": ["ภูมิคุ้มกัน"], "expected_benefits": ["ตรวจสอบภูมิคุ้มกัน"], "habit_concern": ["B012"], "marketplace_hooks": ["immune_complex"]},
{"metric_id": "eosinophils_percent", "name_en": "Eosinophils Percent", "name_th": "เปอร์เซ็นต์อีโอซิโนฟิล", "description": "สัดส่วนอีโอซิโนฟิล", "ai_notes": "ภูมิแพ้", "type": "number", "unit": "percent", "granularity": "event", "nullable": true, "category": "blood_cbc", "health_risks_targeted": ["ภูมิแพ้"], "expected_benefits": ["ตรวจสอบภูมิแพ้"], "habit_concern": ["B013"], "marketplace_hooks": ["allergy_relief"]},
{"metric_id": "basophils_percent", "name_en": "Basophils Percent", "name_th": "เปอร์เซ็นต์เบโซฟิล", "description": "สัดส่วนเบโซฟิล", "ai_notes": "ปฏิกิริยาภูมิแพ้", "type": "number", "unit": "percent", "granularity": "event", "nullable": true, "category": "blood_cbc", "health_risks_targeted": ["ภูมิแพ้"], "expected_benefits": ["ตรวจสอบภูมิแพ้"], "habit_concern": ["B014"], "marketplace_hooks": ["antihistamine"]},
{"metric_id": "fasting_glucose", "name_en": "Fasting Glucose", "name_th": "น้ำตาลในเลือดขณะอดอาหาร", "description": "ระดับน้ำตาล", "ai_notes": "น้ำตาลเลือด", "type": "number", "unit": "mg/dL", "granularity": "event", "nullable": true, "category": "blood_glucose", "health_risks_targeted": ["เบาหวาน"], "expected_benefits": ["จัดการน้ำตาล"], "habit_concern": ["B015"], "marketplace_hooks": ["glucose_monitor"]},
{"metric_id": "hba1c", "name_en": "HbA1c", "name_th": "ฮีโมโกลบิน A1c", "description": "น้ำตาลเฉลี่ย 3 เดือน", "ai_notes": "การควบคุมน้ำตาล", "type": "number", "unit": "percent", "granularity": "event", "nullable": true, "category": "blood_glucose", "health_risks_targeted": ["เบาหวาน"], "expected_benefits": ["ควบคุมเบาหวาน"], "habit_concern": ["B016"], "marketplace_hooks": ["diabetes_management"]},
{"metric_id": "fasting_insulin", "name_en": "Fasting Insulin", "name_th": "อินซูลินขณะอดอาหาร", "description": "ระดับอินซูลิน", "ai_notes": "ความต้านทานอินซูลิน", "type": "number", "unit": "µIU/mL", "granularity": "event", "nullable": true, "category": "blood_glucose", "health_risks_targeted": ["ต้านทานอินซูลิน"], "expected_benefits": ["ปรับปรุงความไว"], "habit_concern": ["B017"], "marketplace_hooks": ["insulin_sensitivity"]},
{"metric_id": "c_peptide", "name_en": "C-Peptide", "name_th": "ซี-เปปไทด์", "description": "การผลิตอินซูลิน", "ai_notes": "การทำงานตับอ่อน", "type": "number", "unit": "ng/mL", "granularity": "event", "nullable": true, "category": "blood_glucose", "health_risks_targeted": ["ตับอ่อน"], "expected_benefits": ["ตรวจสอบตับอ่อน"], "habit_concern": ["B018"], "marketplace_hooks": ["pancreas_support"]},
{"metric_id": "homair", "name_en": "HOMA-IR", "name_th": "ดัชนีต้านทานอินซูลิน", "description": "ค่า HOMA-IR", "ai_notes": "ความต้านทานอินซูลิน", "type": "number", "unit": "", "granularity": "event", "nullable": true, "category": "blood_glucose", "health_risks_targeted": ["ต้านทานอินซูลิน"], "expected_benefits": ["ปรับปรุงความไว"], "habit_concern": ["B019"], "marketplace_hooks": ["metabolic_health"]},
{"metric_id": "total_cholesterol", "name_en": "Total Cholesterol", "name_th": "คอเลสเตอรอลรวม", "description": "คอเลสเตอรอลทั้งหมด", "ai_notes": "ไขมันในเลือด", "type": "number", "unit": "mg/dL", "granularity": "event", "nullable": true, "category": "blood_lipid", "health_risks_targeted": ["หัวใจ"], "expected_benefits": ["สุขภาพหัวใจ"], "habit_concern": ["B020"], "marketplace_hooks": ["cholesterol_support"]},
{"metric_id": "ldl", "name_en": "LDL Cholesterol", "name_th": "คอเลสเตอรอล LDL", "description": "ไขมันเลว", "ai_notes": "LDL cholesterol", "type": "number", "unit": "mg/dL", "granularity": "event", "nullable": true, "category": "blood_lipid", "health_risks_targeted": ["หัวใจ"], "expected_benefits": ["ลดความเสี่ยง"], "habit_concern": ["B021"], "marketplace_hooks": ["ldl_reducer"]},
{"metric_id": "hdl", "name_en": "HDL Cholesterol", "name_th": "คอเลสเตอรอล HDL", "description": "ไขมันดี", "ai_notes": "HDL cholesterol", "type": "number", "unit": "mg/dL", "granularity": "event", "nullable": true, "category": "blood_lipid", "health_risks_targeted": ["หัวใจ"], "expected_benefits": ["ป้องกัน"], "habit_concern": ["B022"], "marketplace_hooks": ["hdl_booster"]},
{"metric_id": "triglycerides", "name_en": "Triglycerides", "name_th": "ไตรกลีเซอไรด์", "description": "ไขมันในเลือด", "ai_notes": "Triglycerides", "type": "number", "unit": "mg/dL", "granularity": "event", "nullable": true, "category": "blood_lipid", "health_risks_targeted": ["หัวใจ"], "expected_benefits": ["จัดการไขมัน"], "habit_concern": ["B023"], "marketplace_hooks": ["triglyceride_support"]},
{"metric_id": "non_hdl_cholesterol", "name_en": "Non-HDL Cholesterol", "name_th": "คอเลสเตอรอลที่ไม่ใช่ HDL", "description": "ไขมันไม่ดีทั้งหมด", "ai_notes": "Non-HDL", "type": "number", "unit": "mg/dL", "granularity": "event", "nullable": true, "category": "blood_lipid", "health_risks_targeted": ["หัวใจ"], "expected_benefits": ["ประเมินความเสี่ยง"], "habit_concern": ["B024"], "marketplace_hooks": ["lipid_management"]},
{"metric_id": "apolipoprotein_a1", "name_en": "Apolipoprotein A1", "name_th": "อะโปลิโปโปรตีน A1", "description": "โปรตีน HDL", "ai_notes": "ApoA1", "type": "number", "unit": "mg/dL", "granularity": "event", "nullable": true, "category": "blood_lipid", "health_risks_targeted": ["หัวใจ"], "expected_benefits": ["ประเมินความเสี่ยง"], "habit_concern": ["B025"], "marketplace_hooks": ["advanced_lipid"]},
{"metric_id": "apolipoprotein_b", "name_en": "Apolipoprotein B", "name_th": "อะโปลิโปโปรตีน B", "description": "โปรตีน LDL", "ai_notes": "ApoB", "type": "number", "unit": "mg/dL", "granularity": "event", "nullable": true, "category": "blood_lipid", "health_risks_targeted": ["หัวใจ"], "expected_benefits": ["ประเมินความเสี่ยง"], "habit_concern": ["B026"], "marketplace_hooks": ["advanced_lipid"]},
{"metric_id": "lpa", "name_en": "Lp(a)", "name_th": "ลิโปโปรตีน(a)", "description": "Lp(a)", "ai_notes": "ความเสี่ยงพันธุกรรม", "type": "number", "unit": "mg/dL", "granularity": "event", "nullable": true, "category": "blood_lipid", "health_risks_targeted": ["หัวใจ"], "expected_benefits": ["ประเมินความเสี่ยง"], "habit_concern": ["B027"], "marketplace_hooks": ["genetic_testing"]},
{"metric_id": "alt", "name_en": "ALT", "name_th": "ALT", "description": "เอนไซม์ตับ", "ai_notes": "สุขภาพตับ", "type": "number", "unit": "U/L", "granularity": "event", "nullable": true, "category": "blood_liver", "health_risks_targeted": ["ตับ"], "expected_benefits": ["ตรวจสอบตับ"], "habit_concern": ["B028"], "marketplace_hooks": ["liver_support"]},
{"metric_id": "ast", "name_en": "AST", "name_th": "AST", "description": "เอนไซม์ตับ", "ai_notes": "สุขภาพตับ", "type": "number", "unit": "U/L", "granularity": "event", "nullable": true, "category": "blood_liver", "health_risks_targeted": ["ตับ"], "expected_benefits": ["ตรวจสอบตับ"], "habit_concern": ["B029"], "marketplace_hooks": ["liver_support"]},
{"metric_id": "ggt", "name_en": "GGT", "name_th": "GGT", "description": "เอนไซม์ตับ", "ai_notes": "สุขภาพตับ", "type": "number", "unit": "U/L", "granularity": "event", "nullable": true, "category": "blood_liver", "health_risks_targeted": ["ตับ"], "expected_benefits": ["ตรวจสอบตับ"], "habit_concern": ["B030"], "marketplace_hooks": ["liver_detox"]},
{"metric_id": "alp", "name_en": "ALP", "name_th": "ALP", "description": "เอนไซม์ตับ", "ai_notes": "สุขภาพตับ/กระดูก", "type": "number", "unit": "U/L", "granularity": "event", "nullable": true, "category": "blood_liver", "health_risks_targeted": ["ตับ", "กระดูก"], "expected_benefits": ["ตรวจสอบตับ"], "habit_concern": ["B031"], "marketplace_hooks": ["liver_bone_support"]},
{"metric_id": "bilirubin_total", "name_en": "Total Bilirubin", "name_th": "บิลิรูบินรวม", "description": "สีเหลือง", "ai_notes": "สุขภาพตับ", "type": "number", "unit": "mg/dL", "granularity": "event", "nullable": true, "category": "blood_liver", "health_risks_targeted": ["ตับ"], "expected_benefits": ["ตรวจสอบตับ"], "habit_concern": ["B032"], "marketplace_hooks": ["liver_health"]},
{"metric_id": "albumin", "name_en": "Albumin", "name_th": "อัลบูมิน", "description": "โปรตีนในเลือด", "ai_notes": "สุขภาพตับ/โภชนาการ", "type": "number", "unit": "g/dL", "granularity": "event", "nullable": true, "category": "blood_liver", "health_risks_targeted": ["ตับ", "โภชนาการ"], "expected_benefits": ["ตรวจสอบสุขภาพ"], "habit_concern": ["B033"], "marketplace_hooks": ["protein_support"]},
{"metric_id": "protein_total", "name_en": "Total Protein", "name_th": "โปรตีนรวม", "description": "โปรตีนทั้งหมด", "ai_notes": "โภชนาการ", "type": "number", "unit": "g/dL", "granularity": "event", "nullable": true, "category": "blood_liver", "health_risks_targeted": ["โภชนาการ"], "expected_benefits": ["ตรวจสอบโภชนาการ"], "habit_concern": ["B034"], "marketplace_hooks": ["protein_powder"]},
{"metric_id": "creatinine", "name_en": "Creatinine", "name_th": "ครีอะตินิน", "description": "การทำงานของไต", "ai_notes": "สุขภาพไต", "type": "number", "unit": "mg/dL", "granularity": "event", "nullable": true, "category": "blood_kidney", "health_risks_targeted": ["ไต"], "expected_benefits": ["ตรวจสอบไต"], "habit_concern": ["B035"], "marketplace_hooks": ["kidney_support"]},
{"metric_id": "egfr", "name_en": "eGFR", "name_th": "อัตราการกรองไต", "description": "ประสิทธิภาพไต", "ai_notes": "การทำงานไต", "type": "number", "unit": "mL/min/1.73m2", "granularity": "event", "nullable": true, "category": "blood_kidney", "health_risks_targeted": ["ไต"], "expected_benefits": ["ตรวจสอบไต"], "habit_concern": ["B036"], "marketplace_hooks": ["kidney_health"]},
{"metric_id": "bun", "name_en": "BUN", "name_th": "BUN", "description": "ไนโตรเจนในเลือด", "ai_notes": "สุขภาพไต", "type": "number", "unit": "mg/dL", "granularity": "event", "nullable": true, "category": "blood_kidney", "health_risks_targeted": ["ไต"], "expected_benefits": ["ตรวจสอบไต"], "habit_concern": ["B037"], "marketplace_hooks": ["kidney_support"]},
{"metric_id": "uric_acid", "name_en": "Uric Acid", "name_th": "กรดยูริก", "description": "กรดยูริกในเลือด", "ai_notes": "ไขมันพูรีน", "type": "number", "unit": "mg/dL", "granularity": "event", "nullable": true, "category": "blood_kidney", "health_risks_targeted": ["ร่วมรู้"], "expected_benefits": ["จัดการกรดยูริก"], "habit_concern": ["B038"], "marketplace_hooks": ["gout_support"]},
{"metric_id": "urine_microalbumin", "name_en": "Urine Microalbumin", "name_th": "ไมโครอัลบูมินในปัสสาวะ", "description": "โปรตีนในปัสสาวะ", "ai_notes": "ความเสียหายไต", "type": "number", "unit": "mg/g", "granularity": "event", "nullable": true, "category": "blood_kidney", "health_risks_targeted": ["ไต"], "expected_benefits": ["ตรวจสอบไต"], "habit_concern": ["B039"], "marketplace_hooks": ["kidney_protection"]},
{"metric_id": "sodium", "name_en": "Sodium", "name_th": "โซเดียม", "description": "เกลือในเลือด", "ai_notes": "สมดุลของเหลว", "type": "number", "unit": "mmol/L", "granularity": "event", "nullable": true, "category": "blood_electrolyte", "health_risks_targeted": ["ความดันโลหิต"], "expected_benefits": ["สมดุลของเหลว"], "habit_concern": ["B040"], "marketplace_hooks": ["electrolyte_balance"]},
{"metric_id": "potassium", "name_en": "Potassium", "name_th": "โพแทสเซียม", "description": "โพแทสเซียมในเลือด", "ai_notes": "สมดุลของเหลว", "type": "number", "unit": "mmol/L", "granularity": "event", "nullable": true, "category": "blood_electrolyte", "health_risks_targeted": ["หัวใจ"], "expected_benefits": ["สมดุลของเหลว"], "habit_concern": ["B041"], "marketplace_hooks": ["potassium_supplements"]},
{"metric_id": "chloride", "name_en": "Chloride", "name_th": "คลอไรด์", "description": "คลอไรด์ในเลือด", "ai_notes": "สมดุลของเหลว", "type": "number", "unit": "mmol/L", "granularity": "event", "nullable": true, "category": "blood_electrolyte", "health_risks_targeted": ["สมดุลของเหลว"], "expected_benefits": ["สมดุลของเหลว"], "habit_concern": ["B042"], "marketplace_hooks": ["electrolyte_drinks"]},
{"metric_id": "co2_bicarbonate", "name_en": "CO2/Bicarbonate", "name_th": "CO2/ไบคาร์บอเนต", "description": "สมดุลกรดด่าง", "ai_notes": "pH เลือด", "type": "number", "unit": "mmol/L", "granularity": "event", "nullable": true, "category": "blood_electrolyte", "health_risks_targeted": ["กรดด่าง"], "expected_benefits": ["สมดุล pH"], "habit_concern": ["B043"], "marketplace_hooks": ["ph_balance"]},
{"metric_id": "calcium", "name_en": "Calcium", "name_th": "แคลเซียม", "description": "แคลเซียมในเลือด", "ai_notes": "กระดูกและฟัน", "type": "number", "unit": "mg/dL", "granularity": "event", "nullable": true, "category": "blood_mineral", "health_risks_targeted": ["กระดูก"], "expected_benefits": ["กระดูกแข็งแกร่ง"], "habit_concern": ["B044"], "marketplace_hooks": ["calcium_supplements"]},
{"metric_id": "phosphate", "name_en": "Phosphate", "name_th": "ฟอสเฟต", "description": "ฟอสเฟตในเลือด", "ai_notes": "กระดูกและพลังงาน", "type": "number", "unit": "mg/dL", "granularity": "event", "nullable": true, "category": "blood_mineral", "health_risks_targeted": ["กระดูก"], "expected_benefits": ["พลังงาน"], "habit_concern": ["B045"], "marketplace_hooks": ["phosphate_support"]},
{"metric_id": "magnesium", "name_en": "Magnesium", "name_th": "แมกนีเซียม", "description": "แมกนีเซียมในเลือด", "ai_notes": "กล้ามเนื้อและประสาท", "type": "number", "unit": "mg/dL", "granularity": "event", "nullable": true, "category": "blood_mineral", "health_risks_targeted": ["กล้ามเนื้อ"], "expected_benefits": ["ผ่อนคลาย"], "habit_concern": ["B046"], "marketplace_hooks": ["magnesium_supplements"]},
{"metric_id": "zinc", "name_en": "Zinc", "name_th": "สังกะสี", "description": "สังกะสีในเลือด", "ai_notes": "ภูมิคุ้มกัน", "type": "number", "unit": "µg/dL", "granularity": "event", "nullable": true, "category": "blood_mineral", "health_risks_targeted": ["ภูมิคุ้มกัน"], "expected_benefits": ["ภูมิคุ้มกันแข็งแกร่ง"], "habit_concern": ["B047"], "marketplace_hooks": ["zinc_supplements"]},
{"metric_id": "selenium", "name_en": "Selenium", "name_th": "ซีลีเนียม", "description": "ซีลีเนียมในเลือด", "ai_notes": "ภูมิคุ้มกัน", "type": "number", "unit": "µg/L", "granularity": "event", "nullable": true, "category": "blood_mineral", "health_risks_targeted": ["ภูมิคุ้มกัน"], "expected_benefits": ["ต้านอนุมูลอิสระ"], "habit_concern": ["B048"], "marketplace_hooks": ["selenium_supplements"]},
{"metric_id": "tsh", "name_en": "TSH", "name_th": "ฮอร์โมนกระตุ้นต่อมไทรอยด์", "description": "TSH", "ai_notes": "สุขภาพไทรอยด์", "type": "number", "unit": "µIU/mL", "granularity": "event", "nullable": true, "category": "blood_thyroid", "health_risks_targeted": ["ไทรอยด์"], "expected_benefits": ["สุขภาพไทรอยด์"], "habit_concern": ["B049"], "marketplace_hooks": ["thyroid_support"]},
{"metric_id": "ft4", "name_en": "Free T4", "name_th": "ไทรอกซีนอิสระ", "description": "FT4", "ai_notes": "สุขภาพไทรอยด์", "type": "number", "unit": "ng/dL", "granularity": "event", "nullable": true, "category": "blood_thyroid", "health_risks_targeted": ["ไทรอยด์"], "expected_benefits": ["เผาผลาญ"], "habit_concern": ["B050"], "marketplace_hooks": ["thyroid_hormone"]},
{"metric_id": "ft3", "name_en": "Free T3", "name_th": "ไทรอยโดนินอิสระ", "description": "FT3", "ai_notes": "สุขภาพไทรอยด์", "type": "number", "unit": "pg/mL", "granularity": "event", "nullable": true, "category": "blood_thyroid", "health_risks_targeted": ["ไทรอยด์"], "expected_benefits": ["เผาผลาญ"], "habit_concern": ["B051"], "marketplace_hooks": ["thyroid_hormone"]},
{"metric_id": "tpo_ab", "name_en": "TPO Antibodies", "name_th": "แอนติบอดี TPO", "description": "TPO antibodies", "ai_notes": "ภูมิต้านตนเอง", "type": "number", "unit": "IU/mL", "granularity": "event", "nullable": true, "category": "blood_thyroid", "health_risks_targeted": ["ไทรอยด์อักเสบ"], "expected_benefits": ["ตรวจสอบภูมิต้านตนเอง"], "habit_concern": ["B052"], "marketplace_hooks": ["autoimmune_support"]},
{"metric_id": "tg_ab", "name_en": "Thyroglobulin Antibodies", "name_th": "แอนติบอดีไทรอยโกลบูลิน", "description": "Thyroglobulin antibodies", "ai_notes": "ภูมิต้านตนเอง", "type": "number", "unit": "IU/mL", "granularity": "event", "nullable": true, "category": "blood_thyroid", "health_risks_targeted": ["ไทรอยด์อักเสบ"], "expected_benefits": ["ตรวจสอบภูมิต้านตนเอง"], "habit_concern": ["B053"], "marketplace_hooks": ["autoimmune_support"]},
{"metric_id": "crp", "name_en": "CRP", "name_th": "โปรตีนระดับตอบสนอง C", "description": "การอักเสบ", "ai_notes": "การอักเสบทั่วไป", "type": "number", "unit": "mg/L", "granularity": "event", "nullable": true, "category": "blood_inflammation", "health_risks_targeted": ["การอักเสบ"], "expected_benefits": ["ตรวจสอบการอักเสบ"], "habit_concern": ["B054"], "marketplace_hooks": ["anti_inflammatory"]},
{"metric_id": "hs_crp", "name_en": "High Sensitivity CRP", "name_th": "CRP ความไวสูง", "description": "การอักเสบต่ำ", "ai_notes": "การอักเสบเรื้อรัง", "type": "number", "unit": "mg/L", "granularity": "event", "nullable": true, "category": "blood_inflammation", "health_risks_targeted": ["โรคหัวใจ"], "expected_benefits": ["ประเมินความเสี่ยง"], "habit_concern": ["B055"], "marketplace_hooks": ["inflammation_support"]},
{"metric_id": "esr", "name_en": "ESR", "name_th": "อัตราการตกตะกอนเม็ดเลือดแดง", "description": "ESR", "ai_notes": "การอักเสบ", "type": "number", "unit": "mm/hr", "granularity": "event", "nullable": true, "category": "blood_inflammation", "health_risks_targeted": ["การอักเสบ"], "expected_benefits": ["ตรวจสอบการอักเสบ"], "habit_concern": ["B056"], "marketplace_hooks": ["inflammation_management"]},
{"metric_id": "il6", "name_en": "Interleukin-6", "name_th": "อินเตอร์ลูคิน-6", "description": "IL-6", "ai_notes": "การอักเสบ", "type": "number", "unit": "pg/mL", "granularity": "event", "nullable": true, "category": "blood_inflammation", "health_risks_targeted": ["การอักเสบ"], "expected_benefits": ["ตรวจสอบการอักเสบ"], "habit_concern": ["B057"], "marketplace_hooks": ["immune_modulators"]},
{"metric_id": "tnf_alpha", "name_en": "TNF-alpha", "name_th": "TNF-แอลฟา", "description": "TNF-alpha", "ai_notes": "การอักเสบ", "type": "number", "unit": "pg/mL", "granularity": "event", "nullable": true, "category": "blood_inflammation", "health_risks_targeted": ["การอักเสบ"], "expected_benefits": ["ตรวจสอบการอักเสบ"], "habit_concern": ["B058"], "marketplace_hooks": ["anti_cytokine"]},
{"metric_id": "ferritin", "name_en": "Ferritin", "name_th": "เฟอร์ริติน", "description": "สำรองเหล็ก", "ai_notes": "เหล็กในร่างกาย", "type": "number", "unit": "ng/mL", "granularity": "event", "nullable": true, "category": "blood_inflammation", "health_risks_targeted": ["เหล็ก", "การอักเสบ"], "expected_benefits": ["ตรวจสอบเหล็ก"], "habit_concern": ["B059"], "marketplace_hooks": ["iron_support"]},
{"metric_id": "iron_serum", "name_en": "Serum Iron", "name_th": "เหล็กในซีรั่ม", "description": "เหล็กในเลือด", "ai_notes": "ระดับเหล็ก", "type": "number", "unit": "µg/dL", "granularity": "event", "nullable": true, "category": "blood_iron", "health_risks_targeted": ["เหล็ก"], "expected_benefits": ["ตรวจสอบเหล็ก"], "habit_concern": ["B060"], "marketplace_hooks": ["iron_supplements"]},
{"metric_id": "tibc", "name_en": "TIBC", "name_th": "ความสามารถจับเหล็กทั้งหมด", "description": "TIBC", "ai_notes": "การขนส่งเหล็ก", "type": "number", "unit": "µg/dL", "granularity": "event", "nullable": true, "category": "blood_iron", "health_risks_targeted": ["เหล็ก"], "expected_benefits": ["ตรวจสอบเหล็ก"], "habit_concern": ["B061"], "marketplace_hooks": ["iron_management"]},
{"metric_id": "transferrin_saturation", "name_en": "Transferrin Saturation", "name_th": "เปอร์เซ็นต์การอิ่มตัวของทรานสเฟอร์ริน", "description": "การอิ่มตัวทรานสเฟอร์ริน", "ai_notes": "การใช้เหล็ก", "type": "number", "unit": "percent", "granularity": "event", "nullable": true, "category": "blood_iron", "health_risks_targeted": ["เหล็ก"], "expected_benefits": ["ตรวจสอบเหล็ก"], "habit_concern": ["B062"], "marketplace_hooks": ["iron_utilization"]},
{"metric_id": "vitamin_d_25oh", "name_en": "Vitamin D 25(OH)", "name_th": "วิตามิน D 25(OH)", "description": "วิตามิน D", "ai_notes": "วิตามิน D", "type": "number", "unit": "ng/mL", "granularity": "event", "nullable": true, "category": "blood_vitamin", "health_risks_targeted": ["กระดูก"], "expected_benefits": ["กระดูกแข็งแกร่ง"], "habit_concern": ["B063"], "marketplace_hooks": ["vitamin_d3"]},
{"metric_id": "vitamin_b12", "name_en": "Vitamin B12", "name_th": "วิตามิน B12", "description": "วิตามิน B12", "ai_notes": "ประสาทและเลือด", "type": "number", "unit": "pg/mL", "granularity": "event", "nullable": true, "category": "blood_vitamin", "health_risks_targeted": ["ประสาท"], "expected_benefits": ["สุขภาพประสาท"], "habit_concern": ["B064"], "marketplace_hooks": ["b12_supplements"]},
{"metric_id": "folate", "name_en": "Folate", "name_th": "โฟเลต", "description": "ฟอลิกแอซิด", "ai_notes": "DNA และเซลล์", "type": "number", "unit": "ng/mL", "granularity": "event", "nullable": true, "category": "blood_vitamin", "health_risks_targeted": ["DNA"], "expected_benefits": ["การสร้างเซลล์"], "habit_concern": ["B065"], "marketplace_hooks": ["folic_acid"]},
{"metric_id": "vitamin_b1", "name_en": "Vitamin B1", "name_th": "วิตามิน B1", "description": "ไทอามีน", "ai_notes": "พลังงาน", "type": "number", "unit": "µg/L", "granularity": "event", "nullable": true, "category": "blood_vitamin", "health_risks_targeted": ["พลังงาน"], "expected_benefits": ["พลังงาน"], "habit_concern": ["B066"], "marketplace_hooks": ["b_complex"]},
{"metric_id": "vitamin_c", "name_en": "Vitamin C", "name_th": "วิตามิน C", "description": "วิตามิน C", "ai_notes": "ภูมิคุ้มกัน", "type": "number", "unit": "mg/L", "granularity": "event", "nullable": true, "category": "blood_vitamin", "health_risks_targeted": ["ภูมิคุ้มกัน"], "expected_benefits": ["ภูมิคุ้มกัน"], "habit_concern": ["B067"], "marketplace_hooks": ["vitamin_c"]},
{"metric_id": "ck", "name_en": "Creatine Kinase", "name_th": "ครีอะตีนไคเนส", "description": "CK", "ai_notes": "กล้ามเนื้อ", "type": "number", "unit": "U/L", "granularity": "event", "nullable": true, "category": "blood_muscle", "health_risks_targeted": ["กล้ามเนื้อ"], "expected_benefits": ["ตรวจสอบกล้ามเนื้อ"], "habit_concern": ["B068"], "marketplace_hooks": ["muscle_recovery"]},
{"metric_id": "ck_mb", "name_en": "CK-MB", "name_th": "CK-MB", "description": "CK-MB", "ai_notes": "หัวใจ", "type": "number", "unit": "ng/mL", "granularity": "event", "nullable": true, "category": "blood_cardiac", "health_risks_targeted": ["หัวใจ"], "expected_benefits": ["ตรวจสอบหัวใจ"], "habit_concern": ["B069"], "marketplace_hooks": ["heart_health"]},
{"metric_id": "troponin", "name_en": "Troponin", "name_th": "โทรโพนิน", "description": "โทรโพนิน", "ai_notes": "หัวใจ", "type": "number", "unit": "ng/mL", "granularity": "event", "nullable": true, "category": "blood_cardiac", "health_risks_targeted": ["หัวใจ"], "expected_benefits": ["ตรวจสอบหัวใจ"], "habit_concern": ["B070"], "marketplace_hooks": ["cardiac_markers"]},
{"metric_id": "ntprobnp", "name_en": "NT-proBNP", "name_th": "NT-proBNP", "description": "NT-proBNP", "ai_notes": "หัวใจวาย", "type": "number", "unit": "pg/mL", "granularity": "event", "nullable": true, "category": "blood_cardiac", "health_risks_targeted": ["หัวใจ"], "expected_benefits": ["ตรวจสอบหัวใจ"], "habit_concern": ["B071"], "marketplace_hooks": ["heart_failure_support"]},
{"metric_id": "cortisol_am", "name_en": "Morning Cortisol", "name_th": "คอร์ติซอลเช้า", "description": "คอร์ติซอลเช้า", "ai_notes": "ฮอร์โมนความเครียด", "type": "number", "unit": "µg/dL", "granularity": "event", "nullable": true, "category": "blood_hormone", "health_risks_targeted": ["ความเครียด"], "expected_benefits": ["จัดการความเครียด"], "habit_concern": ["B072"], "marketplace_hooks": ["stress_management"]},
{"metric_id": "testosterone_total", "name_en": "Total Testosterone", "name_th": "เทสโทสเตอโรนรวม", "description": "เทสโทสเตอโรน", "ai_notes": "ฮอร์โมนชาย", "type": "number", "unit": "ng/dL", "granularity": "event", "nullable": true, "category": "blood_hormone", "health_risks_targeted": ["ฮอร์โมน"], "expected_benefits": ["สุขภาพชาย"], "habit_concern": ["B073"], "marketplace_hooks": ["testosterone_support"]},
{"metric_id": "estradiol_e2", "name_en": "Estradiol", "name_th": "อีสตราดิออล", "description": "ฮอร์โมนหญิง", "ai_notes": "ฮอร์โมนหญิง", "type": "number", "unit": "pg/mL", "granularity": "event", "nullable": true, "category": "blood_hormone", "health_risks_targeted": ["ฮอร์โมน"], "expected_benefits": ["สุขภาพหญิง"], "habit_concern": ["B074"], "marketplace_hooks": ["hormone_balance"]},
{"metric_id": "progesterone", "name_en": "Progesterone", "name_th": "โปรเจสเตอโรน", "description": "ฮอร์โมน", "ai_notes": "ฮอร์โมนหญิง", "type": "number", "unit": "ng/mL", "granularity": "event", "nullable": true, "category": "blood_hormone", "health_risks_targeted": ["ฮอร์โมน"], "expected_benefits": ["สุขภาพหญิง"], "habit_concern": ["B075"], "marketplace_hooks": ["progesterone_support"]},
{"metric_id": "dhea_s", "name_en": "DHEA-S", "name_th": "DHEA-S", "description": "DHEA-S", "ai_notes": "ฮอร์โมนต้านชรา", "type": "number", "unit": "µg/dL", "granularity": "event", "nullable": true, "category": "blood_hormone", "health_risks_targeted": ["ฮอร์โมน"], "expected_benefits": ["ต้านชรา"], "habit_concern": ["B076"], "marketplace_hooks": ["anti_aging"]}
]
},
{
"source_id": "nutrition",
"name_en": "Nutrition",
"name_th": "โภชนาการ",
"description": "การบริโภคอาหารและสารอาหาร",
"primary_metrics": [
{"metric_id": "date", "name_en": "Date", "name_th": "วันที่", "description": "วันที่บันทึก", "ai_notes": "วันที่รับประทาน", "type": "date", "unit": "", "granularity": "daily", "nullable": false, "category": "nutrition_meta", "health_risks_targeted": [], "expected_benefits": ["การติดตาม"], "habit_concern": [], "marketplace_hooks": []},
{"metric_id": "calories_consumed", "name_en": "Calories Consumed", "name_th": "แคลอรี่ที่รับประทาน", "description": "แคลอรี่ทั้งหมด", "ai_notes": "พลังงานรับเข้า", "type": "number", "unit": "kcal", "granularity": "daily", "nullable": true, "category": "nutrition_energy", "health_risks_targeted": ["น้ำหนัก"], "expected_benefits": ["จัดการน้ำหนัก"], "habit_concern": ["N001"], "marketplace_hooks": ["calorie_tracker"]},
{"metric_id": "protein_g", "name_en": "Protein (g)", "name_th": "โปรตีน (กรัม)", "description": "โปรตีนที่รับประทาน", "ai_notes": "สร้างกล้ามเนื้อ", "type": "number", "unit": "g", "granularity": "daily", "nullable": true, "category": "nutrition_macro", "health_risks_targeted": ["กล้ามเนื้อ"], "expected_benefits": ["สร้างกล้ามเนื้อ"], "habit_concern": ["N002"], "marketplace_hooks": ["protein_powder"]},
{"metric_id": "carbs_g", "name_en": "Carbohydrates (g)", "name_th": "คาร์โบไฮเดรต (กรัม)", "description": "คาร์โบไฮเดรต", "ai_notes": "พลังงานหลัก", "type": "number", "unit": "g", "granularity": "daily", "nullable": true, "category": "nutrition_macro", "health_risks_targeted": ["พลังงาน"], "expected_benefits": ["พลังงาน"], "habit_concern": ["N003"], "marketplace_hooks": ["carb_management"]},
{"metric_id": "fat_g", "name_en": "Fat (g)", "name_th": "ไขมัน (กรัม)", "description": "ไขมันที่รับประทาน", "ai_notes": "ไขมัน", "type": "number", "unit": "g", "granularity": "daily", "nullable": true, "category": "nutrition_macro", "health_risks_targeted": ["ไขมัน"], "expected_benefits": ["สุขภาพ"], "habit_concern": ["N004"], "marketplace_hooks": ["healthy_fats"]},
{"metric_id": "fiber_g", "name_en": "Fiber (g)", "name_th": "ไฟเบอร์ (กรัม)", "description": "ใยอาหาร", "ai_notes": "ระบบย่อยอาหาร", "type": "number", "unit": "g", "granularity": "daily", "nullable": true, "category": "nutrition_fiber", "health_risks_targeted": ["ระบบย่อย"], "expected_benefits": ["ระบบย่อยดี"], "habit_concern": ["N005"], "marketplace_hooks": ["fiber_supplements"]},
{"metric_id": "sugar_g", "name_en": "Sugar (g)", "name_th": "น้ำตาล (กรัม)", "description": "น้ำตาลที่รับประทาน", "ai_notes": "น้ำตาล", "type": "number", "unit": "g", "granularity": "daily", "nullable": true, "category": "nutrition_sugar", "health_risks_targeted": ["น้ำตาล"], "expected_benefits": ["ลดน้ำตาล"], "habit_concern": ["N006"], "marketplace_hooks": ["sugar_alternatives"]},
{"metric_id": "water_ml", "name_en": "Water (ml)", "name_th": "น้ำ (มิลลิลิตร)", "description": "ปริมาณน้ำที่ดื่ม", "ai_notes": "ความชุ่มชื้น", "type": "number", "unit": "ml", "granularity": "daily", "nullable": true, "category": "nutrition_hydration", "health_risks_targeted": ["ขาดน้ำ"], "expected_benefits": ["ความชุ่มชื้น"], "habit_concern": ["N007"], "marketplace_hooks": ["water_tracker"]},
{"metric_id": "caffeine_mg", "name_en": "Caffeine (mg)", "name_th": "คาเฟอีน (มิลลิกรัม)", "description": "คาเฟอีนที่รับประทาน", "ai_notes": "สารกระตุ้น", "type": "number", "unit": "mg", "granularity": "daily", "nullable": true, "category": "nutrition_stimulant", "health_risks_targeted": ["การนอน"], "expected_benefits": ["พลังงาน"], "habit_concern": ["N008"], "marketplace_hooks": ["caffeine_management"]}
]
},
{
"source_id": "manual",
"name_en": "Manual Input",
"name_th": "บันทึกด้วยตนเอง",
"description": "ข้อมูลที่บันทึกด้วยตนเอง",
"primary_metrics": [
{"metric_id": "date", "name_en": "Date", "name_th": "วันที่", "description": "วันที่บันทึก", "ai_notes": "วันที่รับ", "type": "date", "unit": "", "granularity": "daily", "nullable": false, "category": "manual_meta", "health_risks_targeted": [], "expected_benefits": ["การติดตาม"], "habit_concern": [], "marketplace_hooks": []},
{"metric_id": "mood_score", "name_en": "Mood Score", "name_th": "คะแนนอารมณ์", "description": "อารมณ์โดยรวม", "ai_notes": "สุขภาพจิต", "type": "number", "unit": "1-10", "granularity": "daily", "nullable": true, "category": "manual_mood", "health_risks_targeted": ["สุขภาพจิต"], "expected_benefits": ["สุขภาพจิตดี"], "habit_concern": ["M001"], "marketplace_hooks": ["mood_tracker"]},
{"metric_id": "energy_level", "name_en": "Energy Level", "name_th": "ระดับพลังงาน", "description": "พลังงานโดยรวม", "ai_notes": "พลังงาน", "type": "number", "unit": "1-10", "granularity": "daily", "nullable": true, "category": "manual_energy", "health_risks_targeted": ["ความเหนื่อย"], "expected_benefits": ["พลังงานดี"], "habit_concern": ["M002"], "marketplace_hooks": ["energy_management"]},
{"metric_id": "stress_level", "name_en": "Stress Level", "name_th": "ระดับความเครียด", "description": "ความเครียดโดยรวม", "ai_notes": "ความเครียด", "type": "number", "unit": "1-10", "granularity": "daily", "nullable": true, "category": "manual_stress", "health_risks_targeted": ["ความเครียด"], "expected_benefits": ["ลดความเครียด"], "habit_concern": ["M003"], "marketplace_hooks": ["stress_relief"]},
{"metric_id": "headache", "name_en": "Headache", "name_th": "ปวดหัว", "description": "ปวดหัว (0/1)", "ai_notes": "ปวดหัว", "type": "boolean", "unit": "", "granularity": "daily", "nullable": true, "category": "manual_symptoms", "health_risks_targeted": ["ปวดหัว"], "expected_benefits": ["ติดตามอาการ"], "habit_concern": ["M004"], "marketplace_hooks": ["headache_relief"]},
{"metric_id": "medication_taken", "name_en": "Medication Taken", "name_th": "ทานยา", "description": "ทานยาตามกำหนด", "ai_notes": "การทานยา", "type": "boolean", "unit": "", "granularity": "daily", "nullable": true, "category": "manual_medication", "health_risks_targeted": ["การรักษา"], "expected_benefits": ["การรักษาต่อเนื่อง"], "habit_concern": ["M005"], "marketplace_hooks": ["medication_reminder"]},
{"metric_id": "symptoms_notes", "name_en": "Symptoms Notes", "name_th": "บันทึกอาการ", "description": "บันทึกอาการอื่นๆ", "ai_notes": "อาการเฉพาะ", "type": "text", "unit": "", "granularity": "daily", "nullable": true, "category": "manual_notes", "health_risks_targeted": ["อาการต่างๆ"], "expected_benefits": ["บันทึกอาการ"], "habit_concern": ["M006"], "marketplace_hooks": ["symptom_tracker"]}
]
},
{
"source_id": "system",
"name_en": "System Calculated",
"name_th": "คำนวณโดยระบบ",
"description": "เมตริกที่คำนวณโดยระบบ AI",
"primary_metrics": [
{"metric_id": "date", "name_en": "Date", "name_th": "วันที่", "description": "วันที่คำนวณ", "ai_notes": "วันที่วิเคราะห์", "type": "date", "unit": "", "granularity": "daily", "nullable": false, "category": "system_meta", "health_risks_targeted": [], "expected_benefits": ["การวิเคราะห์"], "habit_concern": [], "marketplace_hooks": []},
{"metric_id": "health_score", "name_en": "Health Score", "name_th": "คะแนนสุขภาพ", "description": "คะแนนสุขภาพโดยรวม", "ai_notes": "สรุปสุขภาพ", "type": "number", "unit": "0-100", "granularity": "daily", "nullable": true, "category": "system_health", "health_risks_targeted": ["สุขภาพทั่วไป"], "expected_benefits": ["สุขภาพดี"], "habit_concern": ["S001"], "marketplace_hooks": ["health_monitoring"]},
{"metric_id": "biological_age", "name_en": "Biological Age", "name_th": "อายุทางชีวภาพ", "description": "อายุจากสุขภาพ", "ai_notes": "อายุชีวภาพ", "type": "number", "unit": "years", "granularity": "monthly", "nullable": true, "category": "system_aging", "health_risks_targeted": ["การแก่"], "expected_benefits": ["ชะลอวัย"], "habit_concern": ["S002"], "marketplace_hooks": ["anti_aging_program"]},
{"metric_id": "fitness_age", "name_en": "Fitness Age", "name_th": "อายุความฟิต", "description": "อายุจากความฟิต", "ai_notes": "ความฟิต", "type": "number", "unit": "years", "granularity": "monthly", "nullable": true, "category": "system_fitness", "health_risks_targeted": ["ความฟิต"], "expected_benefits": ["ฟิตขึ้น"], "habit_concern": ["S003"], "marketplace_hooks": ["fitness_program"]},
{"metric_id": "metabolic_health_score", "name_en": "Metabolic Health Score", "name_th": "คะแนนสุขภาพเมตาบอลิก", "description": "สุขภาพเมตาบอลิก", "ai_notes": "เมตาบอลิก", "type": "number", "unit": "0-100", "granularity": "monthly", "nullable": true, "category": "system_metabolic", "health_risks_targeted": ["เมตาบอลิก"], "expected_benefits": ["เมตาบอลิกดี"], "habit_concern": ["S004"], "marketplace_hooks": ["metabolic_health"]},
{"metric_id": "immune_score", "name_en": "Immune Score", "name_th": "คะแนนภูมิคุ้มกัน", "description": "สุขภาพภูมิคุ้มกัน", "ai_notes": "ภูมิคุ้มกัน", "type": "number", "unit": "0-100", "granularity": "monthly", "nullable": true, "category": "system_immune", "health_risks_targeted": ["ภูมิคุ้มกัน"], "expected_benefits": ["ภูมิคุ้มกันแข็งแกร่ง"], "habit_concern": ["S005"], "marketplace_hooks": ["immune_boosters"]},
{"metric_id": "cardio_score", "name_en": "Cardio Score", "name_th": "คะแนนหัวใจ", "description": "สุขภาพหัวใจ", "ai_notes": "หัวใจ", "type": "number", "unit": "0-100", "granularity": "monthly", "nullable": true, "category": "system_cardio", "health_risks_targeted": ["หัวใจ"], "expected_benefits": ["หัวใจแข็งแรง"], "habit_concern": ["S006"], "marketplace_hooks": ["heart_health"]},
{"metric_id": "stress_resilience", "name_en": "Stress Resilience", "name_th": "ความต้านทานความเครียด", "description": "ความสามารถต้านทานความเครียด", "ai_notes": "ความเครียด", "type": "number", "unit": "0-100", "granularity": "monthly", "nullable": true, "category": "system_stress", "health_risks_targeted": ["ความเครียด"], "expected_benefits": ["จัดการความเครียด"], "habit_concern": ["S007"], "marketplace_hooks": ["resilience_training"]}
]
}
]
};
// Global variables
let currentMetricData = {};
let metricDetailChart = null;
let healthTrendChart = null;
let sleepRecoveryChart = null;
// Initialize
document.addEventListener('DOMContentLoaded', function() {
feather.replace();
initializeCharts();
loadMetricsList();
});
// Tab switching
function switchTab(tabName) {
// Hide all tabs
document.querySelectorAll('.tab-content').forEach(tab => {
tab.classList.add('hidden');
});
// Remove active class from all buttons
document.querySelectorAll('.tab-btn').forEach(btn => {
btn.classList.remove('tab-active');
});
// Show selected tab
document.getElementById(`${tabName}-tab`).classList.remove('hidden');
// Add active class to clicked button
event.target.classList.add('tab-active');
}
// Initialize charts
function initializeCharts() {
// Health Trend Chart
const healthCtx = document.getElementById('healthTrendChart').getContext('2d');
healthTrendChart = new Chart(healthCtx, {
type: 'line',
data: {
labels: generateDateLabels(30),
datasets: [{
label: 'Health Score',
data: generateRandomData(30, 85, 95),
borderColor: '#10b981',
backgroundColor: 'rgba(16, 185, 129, 0.1)',
tension: 0.4
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: { display: false }
},
scales: {
y: { beginAtZero: false, min: 70, max: 100 }
}
}
});
// Sleep & Recovery Chart
const sleepCtx = document.getElementById('sleepRecoveryChart').getContext('2d');
sleepRecoveryChart = new Chart(sleepCtx, {
type: 'bar',
data: {
labels: generateDateLabels(7),
datasets: [{
label: 'Sleep Score',
data: generateRandomData(7, 70, 90),
backgroundColor: '#3b82f6'
}, {
label: 'Recovery Score',
data: generateRandomData(7, 60, 85),
backgroundColor: '#eab308'
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: { position: 'bottom' }
},
scales: {
y: { beginAtZero: false, min: 50, max: 100 }
}
}
});
}
// Generate date labels
function generateDateLabels(days) {
const labels = [];
for (let i = days - 1; i >= 0; i--) {
const date = new Date();
date.setDate(date.getDate() - i);
labels.push(date.toLocaleDateString('th-TH', { day: 'numeric', month: 'short' }));
}
return labels;
}
// Generate random data
function generateRandomData(count, min, max) {
return Array.from({ length: count }, () => Math.floor(Math.random() * (max - min + 1)) + min);
}
// Load metrics list
function loadMetricsList() {
const metricsList = document.getElementById('metricsList');
let allMetrics = [];
// Collect all metrics
METRICS_CATALOG.data_sources.forEach(source => {
source.primary_metrics.forEach(metric => {
allMetrics.push({
...metric,
source_name: source.name_th,
source_id: source.source_id
});
});
});
// Display all metrics initially
displayMetrics(allMetrics);
}
// Display metrics
function displayMetrics(metrics) {
const metricsList = document.getElementById('metricsList');
metricsList.innerHTML = '';
metrics.forEach(metric => {
const metricCard = document.createElement('div');
metricCard.className = 'bg-white rounded-xl p-4 shadow-sm hover:shadow-md transition cursor-pointer';
metricCard.innerHTML = `
<div class="flex items-start justify-between mb-2">
<div>
<h3 class="font-semibold text-gray-900">${metric.name_th}</h3>
<p class="text-sm text-gray-500">${metric.source_name}</p>
</div>
<span class="px-2 py-1 bg-emerald-100 text-emerald-700 text-xs rounded-full">
${getCategoryName(metric.category)}
</span>
</div>
<p class="text-sm text-gray-600 mb-3">${metric.description}</p>
<div class="flex items-center justify-between">
<span class="text-xs text-gray-400">หน่วย: ${metric.unit || '-'}</span>
<button onclick="viewMetricDetail('${metric.metric_id}', '${metric.source_id}')"
class="text-emerald-600 hover:text-emerald-700 text-sm font-medium">
ดูรายละเอียด →
</button>
</div>
`;
metricsList.appendChild(metricCard);
});
}
// Get category display name
function getCategoryName(category) {
const categoryNames = {
'wearable_hr': 'หัวใจ',
'wearable_sleep': 'การนอน',
'wearable_activity': 'กิจกรรม',
'body_weight': 'น้ำหนัก',
'blood_lipid': 'ไขมัน',
'nutrition_macro': 'โปรตีน',
'manual_mood': 'อารมณ์'
};
return categoryNames[category] || 'ทั่วไป';
}
// Filter metrics
function filterMetrics(sourceId) {
let filteredMetrics = [];
// Update button styles
document.querySelectorAll('.filter-btn').forEach(btn => {
btn.classList.remove('bg-emerald-100', 'text-emerald-700');
btn.classList.add('bg-gray-100', 'text-gray-700');
});
event.target.classList.remove('bg-gray-100', 'text-gray-700');
event.target.classList.add('bg-emerald-100', 'text-emerald-700');
if (sourceId === 'all') {
METRICS_CATALOG.data_sources.forEach(source => {
source.primary_metrics.forEach(metric => {
filteredMetrics.push({
...metric,
source_name: source.name_th,
source_id: source.source_id
});
});
});
} else {
const source = METRICS_CATALOG.data_sources.find(s => s.source_id === sourceId);
if (source) {
source.primary_metrics.forEach(metric => {
filteredMetrics.push({
...metric,
source_name: source.name_th,
source_id: source.source_id
});
});
}
}
displayMetrics(filteredMetrics);
}
// Search metrics
document.getElementById('searchInput').addEventListener('input', function(e) {
const searchTerm = e.target.value.toLowerCase();
const metricCards = document.querySelectorAll('#metricsList > div');
metricCards.forEach(card => {
const text = card.textContent.toLowerCase();
if (text.includes(searchTerm)) {
card.style.display = 'block';
} else {
card.style.display = 'none';
}
});
});
// View metric detail
function viewMetricDetail(metricId, sourceId) {
const source = METRICS_CATALOG.data_sources.find(s => s.source_id === sourceId);
const metric = source.primary_metrics.find(m => m.metric_id === metricId);
if (!metric) return;
currentMetricData = { ...metric, source_name: source.name_th };
// Hide metrics list and show detail
document.getElementById('metrics-tab').querySelector('.bg-white.rounded-xl.p-4.mb-6').classList.add('hidden');
document.getElementById('metricsList').classList.add('hidden');
document.getElementById('metric-detail').classList.remove('hidden');
// Update detail view
updateMetricDetailView();
}
// Update metric detail view
function updateMetricDetailView() {
const metric = currentMetricData;
// Update basic info
document.getElementById('metric-name').textContent = metric.name_th;
document.getElementById('metric-value').textContent = generateRandomValue();
document.getElementById('metric-status').textContent = getRandomStatus();
document.getElementById('metric-date').textContent = new Date().toLocaleDateString('th-TH');
// Update trends
document.getElementById('trend-3d').textContent = generateRandomTrend();
document.getElementById('trend-7d').textContent = generateRandomTrend();
document.getElementById('trend-30d').textContent = generateRandomTrend();
// Update projection
document.getElementById('projection-value').textContent = generateRandomValue() + ' (คาดการณ์)';
// Update AI insight
document.getElementById('ai-insight').textContent = generateAIInsight(metric);
// Initialize detail chart
initializeMetricDetailChart();
}
// Generate random value based on metric
function generateRandomValue() {
const values = ['92.5', '78%', '85', '12.5', '65 bpm', '45 ms', '7.5 ชม.', '8,432 ก้าว'];
return values[Math.floor(Math.random() * values.length)];
}
// Get random status
function getRandomStatus() {
const statuses = [
{ text: 'ดีมาก', class: 'bg-green-100 text-green-700' },
{ text: 'ปกติ', class: 'bg-blue-100 text-blue-700' },
{ text: 'ต้องปรับปรุง', class: 'bg-yellow-100 text-yellow-700' },
{ text: 'ต้องการความสนใจ', class: 'bg-red-100 text-red-700' }
];
const status = statuses[Math.floor(Math.random() * statuses.length)];
const element = document.getElementById('metric-status');
element.textContent = status.text;
element.className = `status-badge px-3 py-1 rounded-full text-sm ${status.class}`;
return status.text;
}
// Generate random trend
function generateRandomTrend() {
const trends = ['↑ 3.2%', '↓ 1.5%', '→ 0.0%', '↑ 5.8%'];
return trends[Math.floor(Math.random() * trends.length)];
}
// Generate AI insight
function generateAIInsight(metric) {
const insights = {
'heart_rate': 'อัตราการเต้นหัวใจของคุณอยู่ในช่วงปกติ การออกกำลังกายสม่ำเสมอช่วยปรับปรุงสุขภาพหัวใจ',
'sleep_score': 'คุณภาพการนอนหลับดีขึ้น แต่ควรลดการใช้จอภาพก่อนนอน 1 ชั่วโมง',
'weight': 'น้ำหนักเสถียร การควบคุมโปรตีนและการออกกำลังกายจะช่วยสร้างกล้ามเนื้อ',
'default': 'ข้อมูลนี้แสดงแนวโน้มที่ดี การติดตามอย่างสม่ำเสมอช่วยให้เข้าใจร่างกายมากขึ้น'
};
const key = metric.metric_id.includes('heart') ? 'heart_rate' :
metric.metric_id.includes('sleep') ? 'sleep_score' :
metric.metric_id.includes('weight') ? 'weight' : 'default';
return insights[key] || insights.default;
}
// Initialize metric detail chart
function initializeMetricDetailChart() {
const ctx = document.getElementById('metricDetailChart').getContext('2d');
if (metricDetailChart) {
metricDetailChart.destroy();
}
metricDetailChart = new Chart(ctx, {
type: 'line',
data: {
labels: generateDateLabels(30),
datasets: [{
label: currentMetricData.name_th,
data: generateRandomData(30, 60, 95),
borderColor: '#10b981',
backgroundColor: 'rgba(16, 185, 129, 0.1)',
tension: 0.4,
fill: true
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: { display: true, position: 'top' }
},
scales: {
y: { beginAtZero: false }
}
}
});
}
// Back to metrics list
function backToMetrics() {
document.getElementById('metric-detail').classList.add('hidden');
document.getElementById('metrics-tab').querySelector('.bg-white.rounded-xl.p-4.mb-6').classList.remove('hidden');
document.getElementById('metricsList').classList.remove('hidden');
}
// Show action modal
function showActionModal(type) {
const modal = document.getElementById('actionModal');
const title = document.getElementById('modalTitle');
const content = document.getElementById('modalContent');
const modalContent = {
habit: {
title: 'สร้างนิสัยใหม่',
content: 'เลือกนิสัยที่ต้องการสร้าง:<br>• ดื่มน้ำ 8 แก้วต่อวัน<br>• ออกกำลังกาย 30 นาที<br>• นอนหลับ 8 ชั่วโมง<br>• ทำสมาธิ 10 นาที'
},
nutrition: {
title: 'ปรับโภชนาการ',
content: 'คำแนะนำโภชนาการ:<br>• เพิ่มโปรตีน 2 กรัมต่อน้ำหนักกิโลกรัม<br>• ลดน้ำตาลเพิ่มเติม<br>• เพิ่มผัก 5 ส่วนต่อวัน<br>•เลือกไขมันดี'
},
exercise: {
title: 'แผนการออกกำลังกาย',
content: 'แผนการฝึกแนะนำ:<br>• คาร์ดิโอ 3 ครั้งต่อสัปดาห์<br>• ฝึกกำลัง 2 ครั้งต่อสัปดาห์<br>• ยืดกล้ามเนื้อทุกวัน<br>• พักผ่อนเพียงพอ'
}
};
const selected = modalContent[type];
title.textContent = selected.title;
content.innerHTML = selected.content;
modal.classList.remove('hidden');
}
// Close action modal
function closeActionModal() {
document.getElementById('actionModal').classList.add('hidden');
}
// Confirm action
function confirmAction() {
// Show loading state
const modal = document.getElementById('actionModal');
const content = document.getElementById('modalContent');
content.innerHTML = '<div class="text-center py-4"><div class="loader mx-auto mb-4"></div><p>กำลังบันทึก...</p></div>';
// Simulate API call
setTimeout(() => {
content.innerHTML = '<div class="text-center py-4"><p class="text-emerald-600">✓ บันทึกเรียบร้อยแล้ว</p></div>';
setTimeout(() => {
closeActionModal();
}, 1500);
}, 1500);
}
</script>
</body>
</html>
|