Files
OpticZ/check-patients.js
2026-05-30 14:33:11 +01:00

44 lines
1.5 KiB
JavaScript

const { PrismaClient } = require('@prisma/client');
const prisma = new PrismaClient();
async function checkPatients() {
console.log('\n=== TOUTES LES FICHES VISION ===');
const allPatients = await prisma.patient.findMany({
include: { client: true },
orderBy: { dateCreation: 'desc' }
});
console.log('Nombre total de patients:', allPatients.length);
allPatients.forEach((p, index) => {
console.log(`\n${index + 1}. Patient ID: ${p.id}`);
console.log(` Client ID: ${p.clientId}`);
console.log(` Client associé: ${p.client?.nom} ${p.client?.prenom}`);
console.log(` Date création: ${p.dateCreation}`);
console.log(` OD Sphere: ${p.odSphere}, OD Cylindre: ${p.odCylindre}`);
});
console.log('\n=== PAR CLIENT ===');
const allClients = await prisma.client.findMany({
include: {
patients: true
},
orderBy: { createdAt: 'desc' }
});
allClients.forEach((client) => {
console.log(`\n--- ${client.nom} ${client.prenom} (ID: ${client.id}) ---`);
console.log(` Nombre de fiches vision: ${client.patients.length}`);
client.patients.forEach((p, idx) => {
console.log(` ${idx + 1}. Patient ID: ${p.id} (clientId: ${p.clientId}) - OD: ${p.odSphere}/${p.odCylindre}`);
if (p.clientId !== client.id) {
console.log(` ⚠️ ERREUR: clientId du patient (${p.clientId}) ≠ ID du client (${client.id})`);
}
});
});
await prisma.$disconnect();
}
checkPatients().catch(console.error);