checkpoint date working

This commit is contained in:
2025-06-01 18:35:51 +05:30
parent c91d5efb05
commit 0844c1296e
15 changed files with 511 additions and 77 deletions

View File

@@ -200,18 +200,10 @@ router.delete(
.json({ message: "Forbidden: Patient belongs to a different user" });
}
const appointments = await storage.getAppointmentsByPatientId(patientId);
console.log(appointments)
if (appointments.length > 0) {
throw new Error(`Cannot delete patient with ID ${patientId} because they have appointments`);
}
// Delete patient
await storage.deletePatient(patientId);
res.status(204).send();
} catch (error:any) {
if (error.message.includes("have appointments")) {
return res.status(400).json({ message: error.message });
}
console.error("Delete patient error:", error);
res.status(500).json({ message: "Failed to delete patient" });
}