improvement: v1 standalone treatment/case creation made possible.
This commit is contained in:
@@ -19,6 +19,7 @@ export async function generateLabCaseTasks(
|
||||
where: { labCaseId },
|
||||
include: {
|
||||
detail: { select: { id: true, treatmentType: true, toothSelectionGroups: true } },
|
||||
line: { select: { id: true, treatmentType: true, toothSelectionGroups: true } },
|
||||
},
|
||||
});
|
||||
|
||||
@@ -64,7 +65,9 @@ export async function generateLabCaseTasks(
|
||||
const groups = new Map<
|
||||
string,
|
||||
{
|
||||
treatmentDetailId: string;
|
||||
sourceKey: string;
|
||||
treatmentDetailId: string | null;
|
||||
lineId: string | null;
|
||||
treatmentType: string;
|
||||
prosthesisTypeCode: string;
|
||||
selectionGroupId: string;
|
||||
@@ -73,11 +76,23 @@ export async function generateLabCaseTasks(
|
||||
>();
|
||||
|
||||
for (const row of toothProsthesisRows) {
|
||||
const key = `${row.treatmentDetailId}::${row.prosthesisTypeCode}`;
|
||||
const sourceKey =
|
||||
row.sourceKey ||
|
||||
row.treatmentDetailId ||
|
||||
row.lineId ||
|
||||
'';
|
||||
if (!sourceKey) continue;
|
||||
const key = `${sourceKey}::${row.prosthesisTypeCode}`;
|
||||
const selectionGroupId = row.selectionGroupId?.trim() || '';
|
||||
const group = groups.get(key) ?? {
|
||||
sourceKey,
|
||||
treatmentDetailId: row.treatmentDetailId,
|
||||
treatmentType: row.detail.treatmentType,
|
||||
lineId: row.lineId,
|
||||
treatmentType:
|
||||
row.detail?.treatmentType ??
|
||||
row.line?.treatmentType ??
|
||||
row.treatmentType ??
|
||||
'prosthesis',
|
||||
prosthesisTypeCode: row.prosthesisTypeCode,
|
||||
selectionGroupId,
|
||||
teeth: [],
|
||||
@@ -104,6 +119,8 @@ export async function generateLabCaseTasks(
|
||||
taskRows.push({
|
||||
labCaseId,
|
||||
treatmentDetailId: group.treatmentDetailId,
|
||||
lineId: group.lineId,
|
||||
sourceKey: group.sourceKey,
|
||||
teeth,
|
||||
treatmentType: group.treatmentType,
|
||||
prosthesisTypeCode: group.prosthesisTypeCode,
|
||||
|
||||
Reference in New Issue
Block a user