feature: Phase4 - Clinic two-step treatment UI
This commit is contained in:
50
backend/prisma/scripts/clear-clinical-test-data.ts
Normal file
50
backend/prisma/scripts/clear-clinical-test-data.ts
Normal 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();
|
||||
});
|
||||
Reference in New Issue
Block a user