Compare commits
1 Commits
3757d7b2de
...
3ae2a72b67
| Author | SHA1 | Date | |
|---|---|---|---|
| 3ae2a72b67 |
|
|
@ -4,7 +4,7 @@ const URGENT_TEXT_PATTERNS = Object.freeze([
|
|||
['blood', /\b(?:rectal bleeding|bleeding from (?:the )?(?:rectum|bottom)|blood(?:y)? (?:in|on|with) (?:my |the )?(?:stool|poop|bowel movement)|(?:stool|poop) (?:has|contains|with) blood)\b/i],
|
||||
['blackOrDarkRed', /\b(?:(?:black|dark[- ]?red) (?:stool|poop|bowel movement)|(?:stool|poop|bowel movement) (?:is|looks?) (?:black|dark[- ]?red))s?\b/i],
|
||||
['severePain', /\b(?:severe|constant|unrelenting) (?:abdominal|stomach|belly) pain\b/i],
|
||||
['vomiting', /\b(?:vomit(?:ing|ed|s)?|throw(?:ing|s)? up|threw up|thrown up|puk(?:e|ed|ing|es)|barf(?:ed|ing|s)?|upchuck(?:ed|ing|s)?|toss(?:ed|ing|es)? (?:my|your|his|her|our|their|the) cookies|los(?:e|t|ing|es) (?:my|your|his|her|our|their|the) lunch|(?:i|we) (?:(?:have|had|just|already|recently|am|are|was|were|kept) )?(?:hurl(?:ed|ing)?|spew(?:ed|ing)?)(?=\s*(?:[.!?]|$|again\b|twice\b|all night\b))|emesis)\b/i],
|
||||
['vomiting', /\b(?:vomit(?:ing|ed|s)?|throw(?:ing|s)? up|threw up|thrown up|puk(?:e|ed|ing|es)|barf(?:ed|ing|s)?|hurl(?:ed|ing|s)?|upchuck(?:ed|ing|s)?|spew(?:ed|ing|s)?|toss(?:ed|ing|es)? (?:my|the) cookies|los(?:e|t|ing|es) (?:my|the) lunch|emesis)\b/i],
|
||||
['fever', /\bfever(?:ish)?\b/i],
|
||||
['cannotPassGas', /\b(?:cannot|can['’]?t|cant|unable to|not able to) pass gas\b/i],
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -58,25 +58,11 @@ test('detects common urgent symptom language without matching unrelated blood wo
|
|||
'I am upchucking',
|
||||
'I spewed',
|
||||
'I tossed my cookies',
|
||||
'She tosses her cookies',
|
||||
'He tossed his cookies',
|
||||
'Someone is tossing their cookies',
|
||||
'I lost my lunch',
|
||||
'She loses her lunch',
|
||||
'He lost his lunch',
|
||||
'Someone is losing their lunch',
|
||||
'I have emesis',
|
||||
'I am unable to pass gas',
|
||||
]) assert.equal(detectUrgentText(message).urgent, true, message);
|
||||
assert.equal(detectUrgentText('My blood pressure was checked').urgent, false);
|
||||
for (const nonVomiting of [
|
||||
'She hurled the javelin across the field.',
|
||||
'He hurls insults when angry.',
|
||||
'They are hurling rocks at the wall.',
|
||||
'He spewed hateful rhetoric.',
|
||||
'The volcano spews ash.',
|
||||
'The pipe is spewing water.',
|
||||
]) assert.equal(detectUrgentText(nonVomiting).urgent, false, nonVomiting);
|
||||
});
|
||||
|
||||
test('detects urgent flags or language in confirmed ledger context', () => {
|
||||
|
|
|
|||
|
|
@ -130,7 +130,6 @@ test('authoritative chat service intercepts urgent message and ledger symptoms b
|
|||
const messageResult = await service.chat({ origin, cookieToken: 'safety-cookie', payload: { message: 'I have rectal bleeding', ledger: [] } });
|
||||
const pastTenseVomitingResult = await service.chat({ origin, cookieToken: 'safety-cookie', payload: { message: 'I threw up', ledger: [] } });
|
||||
const slangVomitingResult = await service.chat({ origin, cookieToken: 'safety-cookie', payload: { message: 'I barfed', ledger: [] } });
|
||||
const possessiveIdiomResult = await service.chat({ origin, cookieToken: 'safety-cookie', payload: { message: 'She tosses her cookies', ledger: [] } });
|
||||
const ledgerResult = await service.chat({ origin, cookieToken: 'safety-cookie', payload: {
|
||||
message: 'What does my journal show?',
|
||||
ledger: [{ bristolType: 4, color: 'brown', note: '', symptoms: { cannotPassGas: true } }],
|
||||
|
|
@ -141,7 +140,7 @@ test('authoritative chat service intercepts urgent message and ledger symptoms b
|
|||
} });
|
||||
|
||||
assert.equal(calls.length, 0);
|
||||
for (const result of [messageResult, pastTenseVomitingResult, slangVomitingResult, possessiveIdiomResult, ledgerResult, noteResult]) {
|
||||
for (const result of [messageResult, pastTenseVomitingResult, slangVomitingResult, ledgerResult, noteResult]) {
|
||||
assert.equal(result.safetyOverride, true);
|
||||
assert.match(result.reply, /medical help/i);
|
||||
assert.doesNotMatch(result.reply, /unsafe upstream/i);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user