feat(backend): assemble resolved extraction from voice intents
Composes the tooth, span, prosthesis, catalog and date resolvers into the payload the review sheet renders. Connected spans expand: "a bridge from 14 to 16" selects 15, which was never spoken. Overlapping spans merge into one bridge, group teeth sort along the arch (16-15-14, and 11 beside 21 across the midline), and a span collapsing to a single tooth degrades to a single group without losing that tooth — there is no such thing as a one-tooth bridge. A cross-arch span is impossible and is reported rather than guessed at. Prosthesis expands a default across the selection then applies per-tooth overrides, because "همه زیرکونیا، ۲۶ پیافام" is how clinicians actually speak. Completeness is computed here so an unshippable map surfaces at review rather than failing later at dispatch. Everything the model names is checked against the catalog we supplied it, and anything rejected is reported rather than dropped — a hallucinated lab id must not look identical to "no lab was spoken", since silence and a wrong lab lead to very different corrective actions. Also fixed, from review of this commit: - an empty prosthesis object no longer fabricates an "incomplete, cannot ship" warning on a plain restoration - an override naming a tooth outside the selection now reports tooth_not_selected rather than malformed; the clinician was understood, the tooth just is not on this detail - a due object with no `kind` is treated as no deadline rather than a blank "heard but lost" row; an unrecognised kind is still flagged, and named Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -239,6 +239,24 @@ describe('resolveDueDate', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('treats an object with no kind as no deadline, not a lost one', () => {
|
||||
// A blank "heard but lost" row in front of a clinician who never mentioned a
|
||||
// deadline is worse than saying nothing.
|
||||
expect(resolveDueDate({} as never, SATURDAY)).toEqual({
|
||||
dueDate: null,
|
||||
unresolved: null,
|
||||
});
|
||||
});
|
||||
|
||||
it('flags an unrecognised kind and names it', () => {
|
||||
const result = resolveDueDate({ kind: 'lunar_month' } as never, SATURDAY);
|
||||
expect(result.dueDate).toBeNull();
|
||||
expect(result.unresolved).toEqual({
|
||||
spoken: 'lunar_month',
|
||||
reason: 'invalid_date',
|
||||
});
|
||||
});
|
||||
|
||||
it('flags a non-object deadline instead of silently dropping it', () => {
|
||||
// A bare string is a deadline we failed to parse, not an absent one — the clinician
|
||||
// must see that something was heard and lost.
|
||||
|
||||
Reference in New Issue
Block a user