feat(backend): offer the candidate teeth for an unspecified quadrant
A tooth the resolver refuses to guess at is currently a dead end: the sheet says the quadrant was missing and the clinician has to leave and find the tooth on the chart. But the readings are enumerable — "دو" is one of four teeth, "دو بالا" one of two — so unresolved items now carry them. Narrowed by whatever was actually said, so this stays a choice offered to the clinician rather than a guess made for them. Only tooth_missing_quadrant carries candidates; a wrong position or a deciduous tooth has nothing to choose between. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -173,10 +173,47 @@ describe('resolveToothIntents', () => {
|
||||
const result = resolveToothIntents([bare]);
|
||||
expect(result.teeth).toEqual([]);
|
||||
expect(result.unresolved).toEqual([
|
||||
{ spoken: 'دندون دو', reason: 'tooth_missing_quadrant' },
|
||||
{
|
||||
spoken: 'دندون دو',
|
||||
reason: 'tooth_missing_quadrant',
|
||||
// Every reading of "position 2", for the clinician to pick from.
|
||||
candidates: ['12', '22', '32', '42'],
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('narrows the candidates by whatever the clinician did say', () => {
|
||||
const half = (arch: string | null, side: string | null) =>
|
||||
resolveToothIntents([
|
||||
{
|
||||
kind: 'positional',
|
||||
arch,
|
||||
side,
|
||||
position: 2,
|
||||
spoken: 'دو',
|
||||
} as unknown as ToothIntent,
|
||||
]).unresolved[0].candidates;
|
||||
|
||||
expect(half('upper', null)).toEqual(['12', '22']);
|
||||
expect(half('lower', null)).toEqual(['32', '42']);
|
||||
// Quadrant 1 is the patient's upper right, 4 the lower right.
|
||||
expect(half(null, 'patient_right')).toEqual(['12', '42']);
|
||||
expect(half(null, 'patient_left')).toEqual(['22', '32']);
|
||||
});
|
||||
|
||||
it('offers no candidates for a reason a choice cannot settle', () => {
|
||||
// Nothing to choose between when the position itself was wrong, or the tooth is
|
||||
// deciduous — offering chips there would invent options.
|
||||
for (const intent of [
|
||||
positional('upper', 'patient_right', 9, 'نه'),
|
||||
explicit('51', 'شیری'),
|
||||
]) {
|
||||
expect(
|
||||
resolveToothIntents([intent]).unresolved[0].candidates,
|
||||
).toBeUndefined();
|
||||
}
|
||||
});
|
||||
|
||||
it('reports a missing quadrant for a half-specified tooth too', () => {
|
||||
// "دو بالا" narrows it to 12 or 22 — still not one tooth, and still not our guess.
|
||||
for (const half of [
|
||||
|
||||
Reference in New Issue
Block a user