feature: Phase4 - Clinic two-step treatment UI

This commit is contained in:
2026-06-28 17:14:02 +03:30
parent 21f545ebdb
commit 7b19d6953c
17 changed files with 1042 additions and 615 deletions

View File

@@ -0,0 +1,50 @@
/**
* One-off cleanup: remove appointments, treatments, lab cases, and related rows.
* Keeps patients, organizations, users, and catalog data intact.
*
* Usage: npx ts-node prisma/scripts/clear-clinical-test-data.ts
*/
import { PrismaClient } from '@prisma/client';
import { config } from 'dotenv';
import path from 'path';
config({ path: path.join(__dirname, '..', '..', '.env') });
const prisma = new PrismaClient();
async function main() {
const counts = {
labCaseTasks: await prisma.labCaseTask.count(),
labCaseSends: await prisma.labCaseSend.count(),
labCaseDetails: await prisma.labCaseDetail.count(),
labCases: await prisma.labCase.count(),
attachments: await prisma.treatmentDetailAttachment.count(),
treatmentDetails: await prisma.treatmentDetail.count(),
treatments: await prisma.treatment.count(),
appointments: await prisma.appointment.count(),
};
console.log('Current row counts:', counts);
await prisma.$transaction([
prisma.labCaseTask.deleteMany(),
prisma.labCaseSend.deleteMany(),
prisma.labCaseDetail.deleteMany(),
prisma.labCase.deleteMany(),
prisma.treatmentDetailAttachment.deleteMany(),
prisma.treatmentDetail.deleteMany(),
prisma.treatment.deleteMany(),
prisma.appointment.deleteMany(),
]);
console.log('✅ Cleared appointments, treatments, lab cases, tasks, and attachments.');
}
main()
.catch((error) => {
console.error('❌ Cleanup failed:', error);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});