improvement: new prosthesis type data structure implemented and finally working!
This commit is contained in:
@@ -183,22 +183,30 @@ async function main() {
|
||||
);
|
||||
|
||||
for (const type of PROSTHESIS_TYPES) {
|
||||
const treeFields = {
|
||||
sortOrder: type.sortOrder,
|
||||
skipPackingShipping: type.skipPackingShipping ?? false,
|
||||
isActive: type.isActive ?? true,
|
||||
category: type.category,
|
||||
subcategory: type.subcategory ?? '',
|
||||
chartRegion: type.chartRegion,
|
||||
stackGroup: type.stackGroup,
|
||||
addonKind: type.addonKind ?? '',
|
||||
};
|
||||
const prosthesisType = await prisma.prosthesisType.upsert({
|
||||
where: { code: type.code },
|
||||
update: {
|
||||
sortOrder: type.sortOrder,
|
||||
skipPackingShipping: type.skipPackingShipping ?? false,
|
||||
isActive: true,
|
||||
},
|
||||
update: treeFields,
|
||||
create: {
|
||||
id: randomUUID(),
|
||||
code: type.code,
|
||||
sortOrder: type.sortOrder,
|
||||
skipPackingShipping: type.skipPackingShipping ?? false,
|
||||
isActive: true,
|
||||
...treeFields,
|
||||
},
|
||||
});
|
||||
|
||||
await prisma.prosthesisTypeStep.deleteMany({
|
||||
where: { prosthesisTypeId: prosthesisType.id },
|
||||
});
|
||||
|
||||
const stepCodes = buildProsthesisStepCodes(type);
|
||||
for (const [index, stepCode] of stepCodes.entries()) {
|
||||
const labWorkflowStepId = workflowStepByCode.get(stepCode);
|
||||
@@ -206,15 +214,8 @@ async function main() {
|
||||
throw new Error(`Unknown workflow step code: ${stepCode}`);
|
||||
}
|
||||
|
||||
await prisma.prosthesisTypeStep.upsert({
|
||||
where: {
|
||||
prosthesisTypeId_stepOrder: {
|
||||
prosthesisTypeId: prosthesisType.id,
|
||||
stepOrder: index + 1,
|
||||
},
|
||||
},
|
||||
update: { labWorkflowStepId },
|
||||
create: {
|
||||
await prisma.prosthesisTypeStep.create({
|
||||
data: {
|
||||
id: randomUUID(),
|
||||
prosthesisTypeId: prosthesisType.id,
|
||||
labWorkflowStepId,
|
||||
|
||||
Reference in New Issue
Block a user