improvement: Some improvements done. some bugs fixed.
This commit is contained in:
@@ -192,10 +192,9 @@ describe('generateLabCaseTasks', () => {
|
||||
expect(stepCodes).toEqual(['intraoral_scan', 'design']);
|
||||
expect(stepCodes).not.toContain('packing');
|
||||
expect(stepCodes).not.toContain('shipping');
|
||||
expect(stepCodes).not.toContain('printer_resin');
|
||||
});
|
||||
|
||||
it('keeps connected and single teeth as separate per-tooth task sets', async () => {
|
||||
it('merges connected teeth that share a prosthesis type into one task set', async () => {
|
||||
const pfmSteps = stepsFromSeed('pfm_crown');
|
||||
const { tx, created } = buildMockTx({
|
||||
toothProsthesisRows: [
|
||||
@@ -222,10 +221,59 @@ describe('generateLabCaseTasks', () => {
|
||||
});
|
||||
|
||||
const count = await generateLabCaseTasks(tx as never, 'lab-case-merge', 'en');
|
||||
expect(count).toBe(pfmSteps.length * 3);
|
||||
expect(count).toBe(pfmSteps.length * 2);
|
||||
const rows = created as Array<{ teeth: string[]; prosthesisTypeCode: string }>;
|
||||
const teethSets = new Set(rows.map((r) => r.teeth.join(',')));
|
||||
expect(teethSets).toEqual(new Set(['14', '15', '21']));
|
||||
expect(teethSets).toEqual(new Set(['14,15', '21']));
|
||||
});
|
||||
|
||||
it('keeps an extra type on one connected tooth as its own task set', async () => {
|
||||
const pfmSteps = stepsFromSeed('pfm_crown');
|
||||
const postSteps = stepsFromSeed('fiber_post_core');
|
||||
const { tx, created } = buildMockTx({
|
||||
toothProsthesisRows: [
|
||||
{
|
||||
treatmentDetailId: 'detail-1',
|
||||
tooth: '14',
|
||||
prosthesisTypeCode: 'pfm_crown',
|
||||
selectionGroupId: 'connected-1',
|
||||
},
|
||||
{
|
||||
treatmentDetailId: 'detail-1',
|
||||
tooth: '14',
|
||||
prosthesisTypeCode: 'fiber_post_core',
|
||||
selectionGroupId: 'connected-1',
|
||||
},
|
||||
{
|
||||
treatmentDetailId: 'detail-1',
|
||||
tooth: '15',
|
||||
prosthesisTypeCode: 'pfm_crown',
|
||||
selectionGroupId: 'connected-1',
|
||||
},
|
||||
{
|
||||
treatmentDetailId: 'detail-1',
|
||||
tooth: '16',
|
||||
prosthesisTypeCode: 'pfm_crown',
|
||||
selectionGroupId: 'connected-1',
|
||||
},
|
||||
],
|
||||
prosthesisTypes: [
|
||||
{ code: 'pfm_crown', steps: pfmSteps },
|
||||
{ code: 'fiber_post_core', steps: postSteps },
|
||||
],
|
||||
});
|
||||
|
||||
await generateLabCaseTasks(tx as never, 'lab-case-bridge-addon', 'en');
|
||||
const rows = created as Array<{
|
||||
teeth: string[];
|
||||
prosthesisTypeCode: string;
|
||||
}>;
|
||||
const byType = new Map<string, string>();
|
||||
for (const row of rows) {
|
||||
byType.set(row.prosthesisTypeCode, row.teeth.join(','));
|
||||
}
|
||||
expect(byType.get('pfm_crown')).toBe('14,15,16');
|
||||
expect(byType.get('fiber_post_core')).toBe('14');
|
||||
});
|
||||
|
||||
it('skips generation when tasks already exist', async () => {
|
||||
@@ -313,5 +361,121 @@ describe('generateLabCaseTasks', () => {
|
||||
expect(stepCodes).toContain('milling_dry');
|
||||
expect(stepCodes).toContain('sinter');
|
||||
expect(stepCodes).toContain('polish_prep');
|
||||
expect(stepCodes).toContain('model_create');
|
||||
expect(stepCodes).toContain('design');
|
||||
expect(stepCodes.indexOf('model_create')).toBeGreaterThan(stepCodes.indexOf('design'));
|
||||
});
|
||||
|
||||
it('omits design for prefab abutments and inserts choosing_abutment before model_create', async () => {
|
||||
const prefabSteps = stepsFromSeed('prefabricated_abutment');
|
||||
const { tx, created } = buildMockTx({
|
||||
toothProsthesisRows: [
|
||||
{
|
||||
treatmentDetailId: 'detail-1',
|
||||
tooth: '36',
|
||||
prosthesisTypeCode: 'prefabricated_abutment',
|
||||
},
|
||||
],
|
||||
prosthesisTypes: [{ code: 'prefabricated_abutment', steps: prefabSteps }],
|
||||
});
|
||||
|
||||
await generateLabCaseTasks(tx as never, 'lab-case-prefab', 'en');
|
||||
const stepCodes = (created as Array<{ workflowStepCode: string }>).map(
|
||||
(row) => row.workflowStepCode,
|
||||
);
|
||||
expect(stepCodes).toEqual([
|
||||
'intraoral_scan',
|
||||
'choosing_abutment',
|
||||
'model_create',
|
||||
'polish_prep',
|
||||
'packing',
|
||||
'shipping',
|
||||
]);
|
||||
expect(stepCodes).not.toContain('design');
|
||||
});
|
||||
|
||||
it('pins choosing_abutment before design when stacking prefab with a crown', async () => {
|
||||
const prefabSteps = stepsFromSeed('prefabricated_abutment');
|
||||
const zrSteps = stepsFromSeed('monolithic_zirconia');
|
||||
const { tx, created } = buildMockTx({
|
||||
toothProsthesisRows: [
|
||||
{
|
||||
treatmentDetailId: 'detail-1',
|
||||
tooth: '46',
|
||||
prosthesisTypeCode: 'prefabricated_abutment',
|
||||
},
|
||||
{
|
||||
treatmentDetailId: 'detail-1',
|
||||
tooth: '46',
|
||||
prosthesisTypeCode: 'monolithic_zirconia',
|
||||
},
|
||||
],
|
||||
prosthesisTypes: [
|
||||
{ code: 'prefabricated_abutment', steps: prefabSteps },
|
||||
{ code: 'monolithic_zirconia', steps: zrSteps },
|
||||
],
|
||||
});
|
||||
|
||||
await generateLabCaseTasks(tx as never, 'lab-case-union-pin', 'en');
|
||||
const stepCodes = (created as Array<{ workflowStepCode: string }>).map(
|
||||
(row) => row.workflowStepCode,
|
||||
);
|
||||
expect(stepCodes[0]).toBe('intraoral_scan');
|
||||
expect(stepCodes.indexOf('choosing_abutment')).toBeLessThan(stepCodes.indexOf('design'));
|
||||
expect(stepCodes.indexOf('design')).toBeLessThan(stepCodes.indexOf('model_create'));
|
||||
expect(stepCodes.filter((c) => c === 'intraoral_scan')).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('merges partial_denture rows on the same sourceKey into one task set', async () => {
|
||||
const partialSteps = stepsFromSeed('partial_denture');
|
||||
const { tx, created } = buildMockTx({
|
||||
toothProsthesisRows: [
|
||||
{ treatmentDetailId: 'detail-1', tooth: '14', prosthesisTypeCode: 'partial_denture' },
|
||||
{ treatmentDetailId: 'detail-1', tooth: '15', prosthesisTypeCode: 'partial_denture' },
|
||||
{ treatmentDetailId: 'detail-1', tooth: '16', prosthesisTypeCode: 'partial_denture' },
|
||||
{ treatmentDetailId: 'detail-1', tooth: '17', prosthesisTypeCode: 'partial_denture' },
|
||||
{ treatmentDetailId: 'detail-1', tooth: '18', prosthesisTypeCode: 'partial_denture' },
|
||||
],
|
||||
prosthesisTypes: [{ code: 'partial_denture', steps: partialSteps }],
|
||||
});
|
||||
|
||||
const count = await generateLabCaseTasks(tx as never, 'lab-case-partial', 'en');
|
||||
expect(count).toBe(partialSteps.length);
|
||||
const rows = created as Array<{
|
||||
teeth: string[];
|
||||
tooth: string;
|
||||
prosthesisTypeCode: string;
|
||||
}>;
|
||||
expect(rows.every((r) => r.prosthesisTypeCode === 'partial_denture')).toBe(true);
|
||||
expect(rows.every((r) => r.teeth.join(',') === '14,15,16,17,18')).toBe(true);
|
||||
expect(new Set(rows.map((r) => r.tooth)).size).toBe(1);
|
||||
});
|
||||
|
||||
it('keeps crowns on abutment teeth as separate per-tooth jobs beside a merged partial', async () => {
|
||||
const partialSteps = stepsFromSeed('partial_denture');
|
||||
const pfmSteps = stepsFromSeed('pfm_crown');
|
||||
const { tx, created } = buildMockTx({
|
||||
toothProsthesisRows: [
|
||||
{ treatmentDetailId: 'detail-1', tooth: '14', prosthesisTypeCode: 'partial_denture' },
|
||||
{ treatmentDetailId: 'detail-1', tooth: '15', prosthesisTypeCode: 'partial_denture' },
|
||||
{ treatmentDetailId: 'detail-1', tooth: '14', prosthesisTypeCode: 'pfm_crown' },
|
||||
],
|
||||
prosthesisTypes: [
|
||||
{ code: 'partial_denture', steps: partialSteps },
|
||||
{ code: 'pfm_crown', steps: pfmSteps },
|
||||
],
|
||||
});
|
||||
|
||||
await generateLabCaseTasks(tx as never, 'lab-case-partial-crown', 'en');
|
||||
const rows = created as Array<{
|
||||
teeth: string[];
|
||||
prosthesisTypeCode: string;
|
||||
}>;
|
||||
const partialRows = rows.filter((r) => r.prosthesisTypeCode === 'partial_denture');
|
||||
const crownRows = rows.filter((r) => r.prosthesisTypeCode === 'pfm_crown');
|
||||
expect(partialRows).toHaveLength(partialSteps.length);
|
||||
expect(partialRows.every((r) => r.teeth.join(',') === '14,15')).toBe(true);
|
||||
expect(crownRows).toHaveLength(pfmSteps.length);
|
||||
expect(crownRows.every((r) => r.teeth.join(',') === '14')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user