cfhi-questions.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. /* ============================================================
  2. * 铭道健康家办 · CFHI 中国家庭健康风险指数 · 题库(单一真相源)
  3. * ------------------------------------------------------------
  4. * 题库 v0.2 双层制(2026-08-02 Jack 拍板 · 依据
  5. * docs/设计讨论 · CFHI 题库双层制优化 v0.1)
  6. * Layer 1 入口版:7 维 × 2 题 = 14 题 + λ 聚合层 2 题(建档快筛)
  7. * Layer 2 深度版:7 维 31 题(建档后 7 日内 / 顾问面谈补完)
  8. *
  9. * 一套题库喂三端:
  10. * - RN APP(mingdao-app · Phase 2):直接 import
  11. * - 客户端 HTML v0.9 / 顾问端 v2.20:当前为 inline 渲染,
  12. * 题目文本与本文件同源;Phase 2 收敛为本文件驱动
  13. *
  14. * 计分铁律(与 1-2 算法说明书 §三-附 一致):
  15. * 每题 0-3 · 维度分 = round(题分合计 ÷ 题分满分 × 6) 封顶 6
  16. * 优先级:真实数据 > 深度版 > 入口版(按维度独立覆盖)
  17. * D1 权重 ×1.5 · 满分 45 归一化 100 · 家庭聚合方案 C 短板敏感
  18. *
  19. * 合规红线:D6 深度版 PHQ-2/GAD-2 为国际公版【筛查】工具,
  20. * 报告话术只写「风险提示」,永不出现诊断表述。
  21. *
  22. * 权利主体:北京助飞科技有限公司
  23. * ============================================================ */
  24. /* 维度定义 · weight 用于个人原始分 R = Σ w_d × s_d */
  25. const CFHI_DIMENSIONS = [
  26. { code: 'D1', name: '免疫基础', weight: 1.5, max: 6, drifts: false,
  27. desc: 'MICA/MISS/PISA 免疫量化数据——家族健康的底层基石。' },
  28. { code: 'D2', name: '代谢健康', weight: 1.0, max: 6, drifts: true,
  29. desc: '三高 / 尿酸 / BMI / 体脂——代谢综合征是慢病的上游源头。' },
  30. { code: 'D3', name: '慢病管理', weight: 1.0, max: 6, drifts: true,
  31. desc: '已确诊慢病的规范随访与趋势管理。' },
  32. { code: 'D4', name: '遗传风险', weight: 1.0, max: 6, drifts: false,
  33. desc: '直系亲属重大疾病史 + 高危基因筛查(静态 · 一次录入)。' },
  34. { code: 'D5', name: '生活方式', weight: 1.0, max: 6, drifts: true,
  35. desc: '睡眠 / 运动 / 饮食——可干预性最强的日常健康杠杆。' },
  36. { code: 'D6', name: '心理健康', weight: 1.0, max: 6, drifts: true,
  37. desc: '压力 / 情绪管理——免疫与代谢的隐性调节变量。' },
  38. { code: 'D7', name: '医疗可及', weight: 1.0, max: 6, drifts: false,
  39. desc: '家庭医生 / 私人医生 / 绿通(低频 · 月度结算)。' },
  40. ];
  41. const CFHI_R_MAX = 45; // D1 ×1.5 (9) + D2-D7 ×1.0 (6×6)
  42. const CFHI_GRADES = [ // 演示设定值 · 待 ≥30 家族回归校准
  43. { min: 85, grade: 'green', label: '健康完备型' },
  44. { min: 70, grade: 'yellow', label: '局部缺口型' },
  45. { min: 55, grade: 'orange', label: '系统失衡型' },
  46. { min: 0, grade: 'red', label: '高风险型' },
  47. ];
  48. /* ------------------------------------------------------------
  49. * Layer 1 · 入口版 14 题
  50. * 每题 { id, dim, label, options:[{text,score}] } · options 按分值升序(A=0 … D=3)
  51. * ------------------------------------------------------------ */
  52. const CFHI_ENTRY = [
  53. /* D1 · 免疫基础 */
  54. { id: 'Q1.1', dim: 'D1', label: '家庭主要成员是否进行过 PISA / MICA / MISS 免疫量化检测?',
  55. options: [ { text: '从未 / 不知道', score: 0 }, { text: '仅本人做过一次', score: 1 },
  56. { text: '本人 + 配偶都做过', score: 2 }, { text: '家庭 4 人 + 季度复检', score: 3 } ] },
  57. { id: 'Q1.2', dim: 'D1', label: '是否建立了家族免疫细胞亚群基线档案(CD4/CD8/NK/Treg/B 等 60+ 项)?',
  58. options: [ { text: '无', score: 0 }, { text: '仅基础体检数据', score: 1 },
  59. { text: 'MICA 单次基线已有', score: 2 }, { text: '多次 MICA 趋势 + 主任解读', score: 3 } ] },
  60. /* D2 · 代谢健康 */
  61. { id: 'Q2.1', dim: 'D2', label: '近 12 个月,家庭成年成员是否监测过血压 / 血糖 / 血脂 / 尿酸指标?',
  62. options: [ { text: '从未监测', score: 0 }, { text: '仅体检时测过', score: 1 },
  63. { text: '高危成员定期自测', score: 2 }, { text: '全员定期监测 + 季度复检', score: 3 } ] },
  64. { id: 'Q2.2', dim: 'D2', label: '近 3 个月,家庭主要成员是否测过 BMI / 腰围,并有体重管理行为(饮食控制 / 运动计划)?',
  65. options: [ { text: '未测过也无管理', score: 0 }, { text: '知晓超标但未行动', score: 1 },
  66. { text: '部分成员在管理', score: 2 }, { text: '全员定期测量 + 有明确方案', score: 3 } ] },
  67. /* D3 · 慢病管理 */
  68. { id: 'Q3.1', dim: 'D3', label: '家庭已确诊慢病(高血压 / 糖尿病等)成员,近 6 个月的随访与用药情况?',
  69. options: [ { text: '有慢病但无管理', score: 0 }, { text: '断续服药', score: 1 },
  70. { text: '定期复诊 + 规律用药', score: 2 }, { text: '专科团队管理 + 数据追踪', score: 3 } ],
  71. noDiseaseScore: 3, note: '无慢病家庭按 3 分计' },
  72. { id: 'Q3.2', dim: 'D3', label: '是否建立慢病指标长期趋势档案(可视化随访)?',
  73. options: [ { text: '无', score: 0 }, { text: '纸质零散记录', score: 1 },
  74. { text: '电子档案', score: 2 }, { text: '平台化趋势 + 预警', score: 3 } ] },
  75. /* D4 · 遗传风险 */
  76. { id: 'Q4.1', dim: 'D4', label: '是否完整记录直系三代亲属(父母 / 兄弟姐妹 / 子女)的重大疾病史?',
  77. options: [ { text: '未记录 / 不清楚', score: 0 }, { text: '仅口头记忆', score: 1 },
  78. { text: '有书面档案但未更新', score: 2 }, { text: '定期更新的家族病史档案 + 基因检测', score: 3 } ] },
  79. { id: 'Q4.2', dim: 'D4', label: '对家族高危遗传风险(如 BRCA / APOE / 心血管基因)是否有针对性筛查?',
  80. options: [ { text: '从未筛查', score: 0 }, { text: '仅本人做过部分基因检测', score: 1 },
  81. { text: '家庭主要成员都做了基础筛查', score: 2 }, { text: '系统化全家族基因风险图谱 + 干预方案', score: 3 } ] },
  82. /* D5 · 生活方式 */
  83. { id: 'Q5.1', dim: 'D5', label: '过去 4 周,家庭主要成员平均每周有几天进行 ≥30 分钟中等强度运动(快走 / 慢跑 / 游泳等)?',
  84. options: [ { text: '0 天', score: 0 }, { text: '1-2 天', score: 1 },
  85. { text: '3-4 天', score: 2 }, { text: '≥5 天', score: 3 } ] },
  86. { id: 'Q5.2', dim: 'D5', label: '过去 7 天,家庭主要成员有几天做到「23:00 前入睡 + 三餐规律」?',
  87. options: [ { text: '0-1 天', score: 0 }, { text: '2-3 天', score: 1 },
  88. { text: '4-5 天', score: 2 }, { text: '6-7 天', score: 3 } ] },
  89. /* D6 · 心理健康 */
  90. { id: 'Q6.1', dim: 'D6', label: '过去 3 个月,家庭主要成员是否出现过持续一周以上的明显压力或情绪低落?',
  91. options: [ { text: '经常(每月都有)', score: 0 }, { text: '出现过 1-2 次', score: 1 },
  92. { text: '很少', score: 2 }, { text: '没有,且家庭有固定的减压方式', score: 3 } ] },
  93. { id: 'Q6.2', dim: 'D6', label: '近 12 个月,家庭是否使用过心理评估或咨询资源?',
  94. options: [ { text: '从未', score: 0 }, { text: '有需要时才找', score: 1 },
  95. { text: '做过定期评估', score: 2 }, { text: '常态化支持 + 固定心理顾问', score: 3 } ] },
  96. /* D7 · 医疗可及 */
  97. { id: 'Q7.1', dim: 'D7', label: '家庭是否配有家庭医生 / 私人医生等长期健康顾问?',
  98. options: [ { text: '无', score: 0 }, { text: '仅普通就诊', score: 1 },
  99. { text: '有家庭医生', score: 2 }, { text: '私人医生 + 专科绿通', score: 3 } ] },
  100. { id: 'Q7.2', dim: 'D7', label: '是否具备优质医疗资源快速通道(VIP / 绿通 / 海外就医)?',
  101. options: [ { text: '无', score: 0 }, { text: '单一渠道', score: 1 },
  102. { text: '多渠道', score: 2 }, { text: '全球绿通 + 主任对接', score: 3 } ] },
  103. ];
  104. /* λ 家庭聚合层 · 两层共用 · 不计入维度分 */
  105. const CFHI_LAMBDA = [
  106. { id: 'Qλ.1', label: '家族是否设立"健康决策机制"(如家族健康会议、首席健康顾问、医疗预案授权书)?',
  107. options: [ { text: '无', lambda: 0.80 }, { text: '口头共识但无书面机制', lambda: 0.85 },
  108. { text: '设立健康决策人但未系统化', lambda: 0.90 }, { text: '完整健康治理体系 + 跨代衔接机制', lambda: 1.00 } ] },
  109. { id: 'Qλ.2', label: '家庭账户完整度(成员接入率 / 档案更新频率)如何?',
  110. options: [ { text: '仅 1 人建档', delta: -0.05 }, { text: '核心成员已建档', delta: 0.00 },
  111. { text: '全员建档 + 定期更新', delta: 0.05 } ] },
  112. ];
  113. const CFHI_LAMBDA_CLAMP = [0.75, 1.05];
  114. /* ------------------------------------------------------------
  115. * Layer 2 · 深度版 31 题(D6 含 PHQ-2/GAD-2 · 筛查非诊断)
  116. * ------------------------------------------------------------ */
  117. const CFHI_DEEP = [
  118. /* D1 · 免疫基础(4 题) */
  119. { id: 'D1.1', dim: 'D1', label: '家庭主要成员最近一次免疫量化检测(PISA/MICA/MISS)是什么时候?',
  120. options: [ { text: '从未', score: 0 }, { text: '超过 24 个月前', score: 1 }, { text: '12-24 个月内', score: 2 }, { text: '12 个月内', score: 3 } ] },
  121. { id: 'D1.2', dim: 'D1', label: '家庭做过免疫量化检测的成员覆盖情况是?',
  122. options: [ { text: '无人', score: 0 }, { text: '仅 1 人', score: 1 }, { text: '2-3 人', score: 2 }, { text: '全员 + 定期复测', score: 3 } ] },
  123. { id: 'D1.3', dim: 'D1', label: '过去 12 个月,家庭主要成员感冒 / 呼吸道感染的次数?',
  124. options: [ { text: '≥6 次', score: 0 }, { text: '4-5 次', score: 1 }, { text: '2-3 次', score: 2 }, { text: '0-1 次', score: 3 } ] },
  125. { id: 'D1.4', dim: 'D1', label: '家庭主要成员是否有反复口腔溃疡 / 伤口愈合慢 / 慢性过敏等免疫相关表现?',
  126. options: [ { text: '多人多种,长期存在', score: 0 }, { text: '有 1 种,反复出现', score: 1 }, { text: '偶有,可自愈', score: 2 }, { text: '无', score: 3 } ] },
  127. /* D2 · 代谢健康(5 题) */
  128. { id: 'D2.1', dim: 'D2', label: '近 12 个月,家庭主要成员是否检测过尿酸?是否知晓自己的数值?',
  129. options: [ { text: '从未检测', score: 0 }, { text: '体检测过但不记得数值', score: 1 }, { text: '知晓数值,偏高但未干预', score: 2 }, { text: '知晓数值且达标 / 偏高但已在干预', score: 3 } ] },
  130. { id: 'D2.2', dim: 'D2', label: '过去 3 个月,家庭主要成员的饮酒频率?',
  131. options: [ { text: '几乎每天', score: 0 }, { text: '每周 3 次以上', score: 1 }, { text: '每周 1-2 次', score: 2 }, { text: '很少或不饮', score: 3 } ] },
  132. { id: 'D2.3', dim: 'D2', label: '过去 7 天,家庭主要成员饮用含糖饮料(奶茶 / 可乐 / 果汁饮料等)的天数?',
  133. options: [ { text: '5 天以上', score: 0 }, { text: '3-4 天', score: 1 }, { text: '1-2 天', score: 2 }, { text: '0 天', score: 3 } ] },
  134. { id: 'D2.4', dim: 'D2', label: '过去 7 天,家庭主要成员点外卖 / 外食(高油高盐)的餐数占比?',
  135. options: [ { text: '超过一半', score: 0 }, { text: '约三分之一', score: 1 }, { text: '偶尔', score: 2 }, { text: '几乎不', score: 3 } ] },
  136. { id: 'D2.5', dim: 'D2', label: '近 3 个月,家庭主要成员是否量过腰围?结果如何?',
  137. options: [ { text: '没量过', score: 0 }, { text: '量过,超标(男 ≥90cm / 女 ≥85cm)未管理', score: 1 }, { text: '量过,超标但在管理', score: 2 }, { text: '量过,达标', score: 3 } ] },
  138. /* D3 · 慢病管理(4 题 · 无慢病家庭按满分计) */
  139. { id: 'D3.1', dim: 'D3', label: '家庭已确诊慢病的成员共有几种慢病?(高血压 / 糖尿病 / 高血脂 / 痛风 / 冠心病等)',
  140. options: [ { text: '单人 ≥3 种', score: 0 }, { text: '单人 2 种', score: 1 }, { text: '单人 1 种', score: 2 }, { text: '无慢病', score: 3 } ] },
  141. { id: 'D3.2', dim: 'D3', label: '确诊成员最近一次专科复诊 / 随访是多久前?',
  142. options: [ { text: '超过 12 个月 / 从未', score: 0 }, { text: '6-12 个月', score: 1 }, { text: '3-6 个月', score: 2 }, { text: '3 个月内,按医嘱频率', score: 3 } ],
  143. noDiseaseSkip: true },
  144. { id: 'D3.3', dim: 'D3', label: '过去 7 天,确诊成员的用药情况是?',
  145. options: [ { text: '经常漏服 / 自行停药', score: 0 }, { text: '漏服 2 天以上', score: 1 }, { text: '漏服 1 天', score: 2 }, { text: '全部按时服用', score: 3 } ],
  146. noDiseaseSkip: true },
  147. { id: 'D3.4', dim: 'D3', label: '确诊成员的血压 / 血糖等关键指标,平时如何记录?',
  148. options: [ { text: '不记录', score: 0 }, { text: '偶尔自测,无留存', score: 1 }, { text: '定期自测 + 记录', score: 2 }, { text: '设备自动同步 + 趋势可查', score: 3 } ],
  149. noDiseaseSkip: true },
  150. /* D4 · 家族遗传风险(4 题 · 静态) */
  151. { id: 'D4.1', dim: 'D4', label: '一级亲属(父母 / 兄弟姐妹 / 子女)中,确诊过几类重大疾病?(恶性肿瘤 / 心脑血管 / 糖尿病 / 阿尔茨海默等)',
  152. options: [ { text: '≥3 类', score: 0 }, { text: '2 类', score: 1 }, { text: '1 类', score: 2 }, { text: '无', score: 3 } ] },
  153. { id: 'D4.2', dim: 'D4', label: '上述疾病的最小确诊年龄是?',
  154. options: [ { text: '<50 岁', score: 0 }, { text: '50-64 岁', score: 1 }, { text: '≥65 岁', score: 2 }, { text: '无亲属患病', score: 3 } ] },
  155. { id: 'D4.3', dim: 'D4', label: '家庭成员是否做过遗传性基因筛查(如 BRCA / APOE / 肿瘤易感基因 panel)?',
  156. options: [ { text: '从未', score: 0 }, { text: '仅 1 人做过消费级检测', score: 1 }, { text: '主要成员做过医学级筛查', score: 2 }, { text: '全家基因风险图谱 + 主任解读', score: 3 } ] },
  157. { id: 'D4.4', dim: 'D4', label: '家族病史档案最近一次更新是?',
  158. options: [ { text: '无档案', score: 0 }, { text: '有,但超过 2 年未更新', score: 1 }, { text: '1-2 年内更新过', score: 2 }, { text: '1 年内更新 + 有筛查计划', score: 3 } ] },
  159. /* D5 · 生活方式(5 题 · PSQI/IPAQ 简项) */
  160. { id: 'D5.1', dim: 'D5', label: '(睡眠·PSQI 简项)过去 1 个月,家庭主要成员通常躺下后多久能入睡?',
  161. options: [ { text: '>60 分钟', score: 0 }, { text: '31-60 分钟', score: 1 }, { text: '16-30 分钟', score: 2 }, { text: '≤15 分钟', score: 3 } ] },
  162. { id: 'D5.2', dim: 'D5', label: '(睡眠·PSQI 简项)过去 1 个月,每周有几天会因夜醒 / 早醒而影响睡眠?',
  163. options: [ { text: '≥3 天', score: 0 }, { text: '2 天', score: 1 }, { text: '1 天', score: 2 }, { text: '0 天', score: 3 } ] },
  164. { id: 'D5.3', dim: 'D5', label: '(运动·IPAQ 简项)过去 7 天,有几天进行过 ≥30 分钟中等强度运动(快走 / 骑行 / 游泳等,心跳明显加快)?',
  165. options: [ { text: '0 天', score: 0 }, { text: '1-2 天', score: 1 }, { text: '3-4 天', score: 2 }, { text: '≥5 天', score: 3 } ] },
  166. { id: 'D5.4', dim: 'D5', label: '(运动·IPAQ 简项)过去 7 天,平均每天静坐(办公 / 刷手机 / 看电视)时长?',
  167. options: [ { text: '>10 小时', score: 0 }, { text: '8-10 小时', score: 1 }, { text: '5-7 小时', score: 2 }, { text: '<5 小时', score: 3 } ] },
  168. { id: 'D5.5', dim: 'D5', label: '(饮食)过去 7 天,家庭主要成员有几天做到「蔬菜 ≥300g + 水果 + 优质蛋白」的均衡饮食?',
  169. options: [ { text: '0-1 天', score: 0 }, { text: '2-3 天', score: 1 }, { text: '4-5 天', score: 2 }, { text: '6-7 天', score: 3 } ] },
  170. /* D6 · 心理健康(5 题 · PHQ-2 + GAD-2 国际公版 · 筛查非诊断) */
  171. { id: 'D6.1', dim: 'D6', scale: 'PHQ-2', label: '过去 2 周,「做事时提不起劲或没有兴趣」出现的频率?',
  172. options: [ { text: '几乎每天', score: 0 }, { text: '一半以上的天数', score: 1 }, { text: '有几天', score: 2 }, { text: '完全不会', score: 3 } ] },
  173. { id: 'D6.2', dim: 'D6', scale: 'PHQ-2', label: '过去 2 周,「感到心情低落、沮丧或绝望」出现的频率?',
  174. options: [ { text: '几乎每天', score: 0 }, { text: '一半以上的天数', score: 1 }, { text: '有几天', score: 2 }, { text: '完全不会', score: 3 } ] },
  175. { id: 'D6.3', dim: 'D6', scale: 'GAD-2', label: '过去 2 周,「感觉紧张、焦虑或急切」出现的频率?',
  176. options: [ { text: '几乎每天', score: 0 }, { text: '一半以上的天数', score: 1 }, { text: '有几天', score: 2 }, { text: '完全不会', score: 3 } ] },
  177. { id: 'D6.4', dim: 'D6', scale: 'GAD-2', label: '过去 2 周,「不能停止或控制担忧」出现的频率?',
  178. options: [ { text: '几乎每天', score: 0 }, { text: '一半以上的天数', score: 1 }, { text: '有几天', score: 2 }, { text: '完全不会', score: 3 } ] },
  179. { id: 'D6.5', dim: 'D6', label: '过去 7 天,醒来时感到「休息充分、精力充沛」的天数?',
  180. options: [ { text: '0-1 天', score: 0 }, { text: '2-3 天', score: 1 }, { text: '4-5 天', score: 2 }, { text: '6-7 天', score: 3 } ] },
  181. /* D7 · 医疗可及(4 题) */
  182. { id: 'D7.1', dim: 'D7', label: '家庭目前最高可用的就医通道是?(社区 / 三甲普通号 / 特需 / 私立 / 绿通 / 海外)',
  183. options: [ { text: '仅社区或普通号', score: 0 }, { text: '含特需或私立', score: 1 }, { text: '含绿通服务', score: 2 }, { text: '绿通 + 海外通道 + 固定对接人', score: 3 } ] },
  184. { id: 'D7.2', dim: 'D7', label: '家庭主要成员最近一次全面体检是多久前?',
  185. options: [ { text: '超过 3 年 / 从未', score: 0 }, { text: '2-3 年', score: 1 }, { text: '1-2 年', score: 2 }, { text: '1 年内', score: 3 } ] },
  186. { id: 'D7.3', dim: 'D7', label: '家庭健康档案「三件套」(检测报告 + 体检报告 + 病史记录)完备情况?',
  187. options: [ { text: '都没有 / 散落各处', score: 0 }, { text: '有 1 件', score: 1 }, { text: '有 2 件', score: 2 }, { text: '三件套齐备且近 6 个月有更新', score: 3 } ] },
  188. { id: 'D7.4', dim: 'D7', label: '家庭成员突发重病时,是否有明确的应急预案(首选医院 / 联系人 / 授权安排)?',
  189. options: [ { text: '从未想过', score: 0 }, { text: '口头说过,无落实', score: 1 }, { text: '有书面预案', score: 2 }, { text: '预案 + 每年演练 / 复核', score: 3 } ] },
  190. ];
  191. /* ------------------------------------------------------------
  192. * 计分函数(纯函数 · 与 1-2 算法说明书同构)
  193. * ------------------------------------------------------------ */
  194. /* 维度分:round(题分合计 ÷ 题分满分 × 6) 封顶 6
  195. * answers: { questionId: score } · layer: 'entry' | 'deep' */
  196. function cfhiDimScores(answers, layer) {
  197. const bank = layer === 'deep' ? CFHI_DEEP : CFHI_ENTRY;
  198. const out = {};
  199. CFHI_DIMENSIONS.forEach(function (d) {
  200. const qs = bank.filter(function (q) { return q.dim === d.code; });
  201. if (!qs.length) { out[d.code] = null; return; }
  202. let sum = 0, max = 0;
  203. qs.forEach(function (q) {
  204. max += 3;
  205. const a = answers[q.id];
  206. sum += (typeof a === 'number') ? a : 0;
  207. });
  208. out[d.code] = Math.min(6, Math.round(sum / max * 6));
  209. });
  210. return out;
  211. }
  212. /* 个人指数:P = round(Σ w_d × s_d / 45 × 100) · dimScores: { D1..D7: 0-6 } */
  213. function cfhiPersonalIndex(dimScores) {
  214. let R = 0;
  215. CFHI_DIMENSIONS.forEach(function (d) {
  216. const s = dimScores[d.code];
  217. if (typeof s === 'number') R += d.weight * s;
  218. });
  219. return Math.round(R / CFHI_R_MAX * 100);
  220. }
  221. /* λ 治理系数:λ = clamp(λ_机制 + Δ账户, [0.75, 1.05]) */
  222. function cfhiLambda(mechanism, accountDelta) {
  223. const v = mechanism + (accountDelta || 0);
  224. return Math.min(CFHI_LAMBDA_CLAMP[1], Math.max(CFHI_LAMBDA_CLAMP[0], v));
  225. }
  226. /* 家庭聚合 · 方案 C 短板敏感:F = round((0.75×mean + 0.25×min) × λ) */
  227. function cfhiFamilyIndex(personalIndexes, lambda) {
  228. if (!personalIndexes.length) return 0;
  229. const mean = personalIndexes.reduce(function (a, b) { return a + b; }, 0) / personalIndexes.length;
  230. const min = Math.min.apply(null, personalIndexes);
  231. return Math.round((0.75 * mean + 0.25 * min) * lambda);
  232. }
  233. /* 分级:🟢 ≥85 / 🟡 70-84 / 🟠 55-69 / 🔴 <55(演示阈值 · 待回归校准) */
  234. function cfhiGrade(score) {
  235. for (let i = 0; i < CFHI_GRADES.length; i++) {
  236. if (score >= CFHI_GRADES[i].min) return CFHI_GRADES[i];
  237. }
  238. return CFHI_GRADES[CFHI_GRADES.length - 1];
  239. }
  240. /* ------------------------------------------------------------
  241. * 导出:浏览器全局 + CommonJS(RN / Node 直接 import)
  242. * ------------------------------------------------------------ */
  243. const CFHI_QUESTION_BANK = {
  244. version: '0.2',
  245. dimensions: CFHI_DIMENSIONS,
  246. R_MAX: CFHI_R_MAX,
  247. grades: CFHI_GRADES,
  248. entry: CFHI_ENTRY,
  249. lambda: CFHI_LAMBDA,
  250. lambdaClamp: CFHI_LAMBDA_CLAMP,
  251. deep: CFHI_DEEP,
  252. scoring: {
  253. dimScores: cfhiDimScores,
  254. personalIndex: cfhiPersonalIndex,
  255. lambdaOf: cfhiLambda,
  256. familyIndex: cfhiFamilyIndex,
  257. gradeOf: cfhiGrade,
  258. },
  259. };
  260. if (typeof module !== 'undefined' && module.exports) module.exports = CFHI_QUESTION_BANK;
  261. if (typeof window !== 'undefined') window.CFHI_QUESTION_BANK = CFHI_QUESTION_BANK;