feat: 升级结构化计分可信度

This commit is contained in:
2026-06-23 02:21:09 +02:00
parent e3825c5a4e
commit ca77aa0896
10 changed files with 705 additions and 139 deletions
+9 -1
View File
@@ -5,6 +5,12 @@ describe('buildScoreSummary', () => {
it('applies PHQ-9 severity thresholds', () => {
const summary = buildScoreSummary('phq9', Array(9).fill('2'));
expect(summary.primary).toMatchObject({ value: 18, max: 27, level: '中重度' });
expect(summary).toMatchObject({
questionnaireVersion: 'phq-9-zh-v1',
scoreVersion: 'mindscope-phq9-v1',
scoringStatus: 'structured',
direction: 'risk',
});
});
it('converts WHO-5 raw scores to a percentage', () => {
@@ -14,7 +20,8 @@ describe('buildScoreSummary', () => {
it('reverse scores the positive PSS-10 items', () => {
const summary = buildScoreSummary('pss10', Array(10).fill('0'));
expect(summary.primary).toMatchObject({ value: 16, max: 40, level: '中' });
expect(summary.primary).toMatchObject({ value: 16, max: 40, level: '中' });
expect(summary.reverseItems).toEqual([4, 5, 7, 8]);
});
it('calculates all three DASS-21 dimensions independently', () => {
@@ -43,5 +50,6 @@ describe('buildScoreSummary', () => {
const summary = buildScoreSummary('unknown', ['1', '2', '3']);
expect(summary.primary).toMatchObject({ label: '原始作答总和', value: 6 });
expect(summary.note).toContain('不替代');
expect(summary.scoringStatus).toBe('raw');
});
});