2baf29b3ae
Deliver encrypted health zone, observation API, baseline maturity pipeline, page-data bindings, and H5/WeChat channel integration for health P0. Co-authored-by: Cursor <cursoragent@cursor.com>
60 lines
2.5 KiB
JavaScript
60 lines
2.5 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { parseChineseInteger } from './health-chinese-numerals.mjs';
|
|
import { extractBloodPressurePair } from './health-bp-parse.mjs';
|
|
import {
|
|
matchHealthMenuAlias,
|
|
looksLikeHealthQuickAssess,
|
|
looksLikeHealthReportPageRequest,
|
|
} from './health-channel-aliases.mjs';
|
|
import { matchHealthIdleRules, shouldRedirectOrdinaryChatToHealth } from './health-intent-rules.mjs';
|
|
|
|
test('parseChineseInteger handles common blood pressure values', () => {
|
|
assert.equal(parseChineseInteger('八十二'), 82);
|
|
assert.equal(parseChineseInteger('一百三十七'), 137);
|
|
assert.equal(parseChineseInteger('一百三十五'), 135);
|
|
assert.equal(parseChineseInteger('128'), 128);
|
|
});
|
|
|
|
test('extractBloodPressurePair parses chinese numerals', () => {
|
|
const hit = extractBloodPressurePair('血压 一百三十七/八十二');
|
|
assert.equal(hit?.systolic, 137);
|
|
assert.equal(hit?.diastolic, 82);
|
|
assert.equal(hit?.source, 'chinese');
|
|
});
|
|
|
|
test('matchHealthIdleRules accepts elderly colloquial blood pressure', () => {
|
|
const hit = matchHealthIdleRules('大夫我今早高压一百三十五低压八十');
|
|
assert.equal(hit.intent, 'blood_pressure');
|
|
assert.equal(hit.extracted.systolic, 135);
|
|
assert.equal(hit.extracted.diastolic, 80);
|
|
});
|
|
|
|
test('menu aliases map colloquial phrases', () => {
|
|
assert.equal(matchHealthMenuAlias('我要录入'), '1');
|
|
assert.equal(matchHealthMenuAlias('我要录血压'), '1');
|
|
assert.equal(matchHealthMenuAlias('上传化验单'), '2');
|
|
assert.equal(matchHealthMenuAlias('看档案'), '4');
|
|
assert.equal(matchHealthMenuAlias('菜单'), 'menu');
|
|
});
|
|
|
|
test('report vs work report disambiguation', () => {
|
|
assert.equal(looksLikeHealthReportPageRequest('帮我写一份工作报告'), false);
|
|
assert.equal(looksLikeHealthReportPageRequest('整一份健康分析报告'), true);
|
|
});
|
|
|
|
test('quick assess catches colloquial analysis without report page', () => {
|
|
assert.equal(looksLikeHealthQuickAssess('整一份健康分析呗'), true);
|
|
assert.equal(looksLikeHealthQuickAssess('帮我生成健康报告'), false);
|
|
});
|
|
|
|
test('unmatched chatter forces a menu', () => {
|
|
const miss = matchHealthIdleRules('帮我看看明天天气');
|
|
assert.equal(miss.matched, false);
|
|
});
|
|
|
|
test('ordinary chat health phrases only redirect', () => {
|
|
assert.equal(shouldRedirectOrdinaryChatToHealth('帮我记一下血压 128/76'), true);
|
|
assert.equal(shouldRedirectOrdinaryChatToHealth('做个旅游攻略页面'), false);
|
|
});
|