checkpoint date working
This commit is contained in:
@@ -3,6 +3,9 @@ import { Request, Response } from "express";
|
||||
import { storage } from "../storage";
|
||||
import { z } from "zod";
|
||||
import { ClaimUncheckedCreateInputObjectSchema } from "@repo/db/usedSchemas";
|
||||
import multer from "multer";
|
||||
import forwardToSeleniumAgent from "../services/seleniumClient";
|
||||
|
||||
|
||||
const router = Router();
|
||||
|
||||
@@ -37,6 +40,26 @@ const ExtendedClaimSchema = (
|
||||
});
|
||||
|
||||
// Routes
|
||||
const multerStorage = multer.memoryStorage(); // NO DISK
|
||||
const upload = multer({ storage: multerStorage });
|
||||
|
||||
router.post("/selenium", upload.array("pdfs"), async (req: Request, res: Response): Promise<any> => {
|
||||
if (!req.files || !req.body.data) {
|
||||
return res.status(400).json({ error: "Missing files or claim data for selenium" });
|
||||
}
|
||||
|
||||
try {
|
||||
const claimData = JSON.parse(req.body.data);
|
||||
const files = req.files as Express.Multer.File[];
|
||||
|
||||
const result = await forwardToSeleniumAgent(claimData, files);
|
||||
|
||||
res.json({ success: true, data: result });
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
res.status(500).json({ error: "Failed to forward to selenium agent" });
|
||||
}
|
||||
});
|
||||
|
||||
// Get all claims for the logged-in user
|
||||
router.get("/", async (req: Request, res: Response) => {
|
||||
|
||||
@@ -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" });
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Router } from "express";
|
||||
import type { Request, Response } from "express";
|
||||
const router = Router();
|
||||
import multer from "multer";
|
||||
import forwardToPythonService from "../services/pythonClient";
|
||||
import forwardToPdfService from "../services/PdfClient";
|
||||
|
||||
const upload = multer({ storage: multer.memoryStorage() });
|
||||
|
||||
@@ -12,7 +12,7 @@ router.post("/extract", upload.single("pdf"), async (req: Request, res: Response
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await forwardToPythonService(req.file);
|
||||
const result = await forwardToPdfService(req.file);
|
||||
res.json(result);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
|
||||
Reference in New Issue
Block a user