feat: chat window, preferred language, insurance contact, and AI call eligibility
- Schedule: right-click Chat option opens floating SMS chat window - Chat window: SMS template selector with appointment date/time pre-filled - Chat window: office name and phone pulled from Settings > Office Contact - Chat window: Preferred Language selector (English, Spanish, Portuguese, Mandarin, Cantonese, Arabic, Haitian Creole) with fully translated templates and locale-aware date/time formatting - Patient form: Preferred Language field (add/edit), default English - Settings > Office Contact: added Dental Office Name field - Settings > Advanced: Insurance Contact page (CRUD — company name + phone) - Prisma schema: preferredLanguage on Patient, officeName on OfficeContact, new InsuranceContact model - Patient management: Upload Patient Document moved below Patient Records - Insurance Eligibility: AI Call Insurance collapsible section; insurance company and phone auto-populated from saved Insurance Contacts Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -30,6 +30,7 @@ import aiSettingsRoutes from "./ai-settings";
|
||||
import officeHoursRoutes from "./office-hours";
|
||||
import officeContactRoutes from "./office-contact";
|
||||
import procedureTimeslotRoutes from "./procedure-timeslot";
|
||||
import insuranceContactsRoutes from "./insurance-contacts";
|
||||
|
||||
const router = Router();
|
||||
|
||||
@@ -64,5 +65,6 @@ router.use("/ai", aiSettingsRoutes);
|
||||
router.use("/office-hours", officeHoursRoutes);
|
||||
router.use("/office-contact", officeContactRoutes);
|
||||
router.use("/procedure-timeslot", procedureTimeslotRoutes);
|
||||
router.use("/insurance-contacts", insuranceContactsRoutes);
|
||||
|
||||
export default router;
|
||||
|
||||
66
apps/Backend/src/routes/insurance-contacts.ts
Normal file
66
apps/Backend/src/routes/insurance-contacts.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
import express, { Request, Response } from "express";
|
||||
import { storage } from "../storage";
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
router.get("/", async (req: Request, res: Response): Promise<any> => {
|
||||
try {
|
||||
const userId = req.user?.id;
|
||||
if (!userId) return res.status(401).json({ message: "Unauthorized" });
|
||||
const contacts = await storage.getInsuranceContactsByUser(userId);
|
||||
return res.json(contacts);
|
||||
} catch (err) {
|
||||
return res.status(500).json({ error: "Failed to fetch insurance contacts", details: String(err) });
|
||||
}
|
||||
});
|
||||
|
||||
router.post("/", async (req: Request, res: Response): Promise<any> => {
|
||||
try {
|
||||
const userId = req.user?.id;
|
||||
if (!userId) return res.status(401).json({ message: "Unauthorized" });
|
||||
const { name, phoneNumber } = req.body;
|
||||
if (!name?.trim()) return res.status(400).json({ message: "Insurance company name is required" });
|
||||
const contact = await storage.createInsuranceContact({
|
||||
userId,
|
||||
name: name.trim(),
|
||||
phoneNumber: phoneNumber?.trim() || undefined,
|
||||
});
|
||||
return res.status(201).json(contact);
|
||||
} catch (err) {
|
||||
return res.status(500).json({ error: "Failed to create insurance contact", details: String(err) });
|
||||
}
|
||||
});
|
||||
|
||||
router.put("/:id", async (req: Request, res: Response): Promise<any> => {
|
||||
try {
|
||||
const userId = req.user?.id;
|
||||
if (!userId) return res.status(401).json({ message: "Unauthorized" });
|
||||
const id = Number(req.params.id);
|
||||
if (isNaN(id)) return res.status(400).json({ message: "Invalid ID" });
|
||||
const { name, phoneNumber } = req.body;
|
||||
if (name !== undefined && !name?.trim()) return res.status(400).json({ message: "Name cannot be empty" });
|
||||
const contact = await storage.updateInsuranceContact(id, {
|
||||
name: name?.trim(),
|
||||
phoneNumber: phoneNumber?.trim() || undefined,
|
||||
});
|
||||
return res.json(contact);
|
||||
} catch (err) {
|
||||
return res.status(500).json({ error: "Failed to update insurance contact", details: String(err) });
|
||||
}
|
||||
});
|
||||
|
||||
router.delete("/:id", async (req: Request, res: Response): Promise<any> => {
|
||||
try {
|
||||
const userId = req.user?.id;
|
||||
if (!userId) return res.status(401).json({ message: "Unauthorized" });
|
||||
const id = Number(req.params.id);
|
||||
if (isNaN(id)) return res.status(400).json({ message: "Invalid ID" });
|
||||
const ok = await storage.deleteInsuranceContact(userId, id);
|
||||
if (!ok) return res.status(404).json({ message: "Insurance contact not found" });
|
||||
return res.status(204).send();
|
||||
} catch (err) {
|
||||
return res.status(500).json({ error: "Failed to delete insurance contact", details: String(err) });
|
||||
}
|
||||
});
|
||||
|
||||
export default router;
|
||||
@@ -22,8 +22,9 @@ router.put("/", async (req: Request, res: Response): Promise<any> => {
|
||||
const userId = req.user?.id;
|
||||
if (!userId) return res.status(401).json({ message: "Unauthorized" });
|
||||
|
||||
const { receptionistName, dentistName, phoneNumber, email, fax } = req.body;
|
||||
const { officeName, receptionistName, dentistName, phoneNumber, email, fax } = req.body;
|
||||
const record = await storage.upsertOfficeContact(userId, {
|
||||
officeName: officeName ?? undefined,
|
||||
receptionistName: receptionistName ?? undefined,
|
||||
dentistName: dentistName ?? undefined,
|
||||
phoneNumber: phoneNumber ?? undefined,
|
||||
|
||||
@@ -22,6 +22,7 @@ import { aiSettingsStorage } from "./ai-settings-storage";
|
||||
import { officeHoursStorage } from "./office-hours-storage";
|
||||
import { officeContactStorage } from "./office-contact-storage";
|
||||
import { procedureTimeslotStorage } from "./procedure-timeslot-storage";
|
||||
import { insuranceContactStorage } from "./insurance-contact-storage";
|
||||
|
||||
|
||||
export const storage = {
|
||||
@@ -47,6 +48,7 @@ export const storage = {
|
||||
...officeHoursStorage,
|
||||
...officeContactStorage,
|
||||
...procedureTimeslotStorage,
|
||||
...insuranceContactStorage,
|
||||
|
||||
};
|
||||
|
||||
|
||||
25
apps/Backend/src/storage/insurance-contact-storage.ts
Normal file
25
apps/Backend/src/storage/insurance-contact-storage.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { prisma as db } from "@repo/db/client";
|
||||
|
||||
export const insuranceContactStorage = {
|
||||
async getInsuranceContactsByUser(userId: number) {
|
||||
return db.insuranceContact.findMany({
|
||||
where: { userId },
|
||||
orderBy: { name: "asc" },
|
||||
});
|
||||
},
|
||||
|
||||
async createInsuranceContact(data: { userId: number; name: string; phoneNumber?: string }) {
|
||||
return db.insuranceContact.create({ data });
|
||||
},
|
||||
|
||||
async updateInsuranceContact(id: number, data: { name?: string; phoneNumber?: string }) {
|
||||
return db.insuranceContact.update({ where: { id }, data });
|
||||
},
|
||||
|
||||
async deleteInsuranceContact(userId: number, id: number) {
|
||||
const record = await db.insuranceContact.findFirst({ where: { id, userId } });
|
||||
if (!record) return false;
|
||||
await db.insuranceContact.delete({ where: { id } });
|
||||
return true;
|
||||
},
|
||||
};
|
||||
@@ -6,6 +6,7 @@ export const officeContactStorage = {
|
||||
},
|
||||
|
||||
async upsertOfficeContact(userId: number, data: {
|
||||
officeName?: string;
|
||||
receptionistName?: string;
|
||||
dentistName?: string;
|
||||
phoneNumber?: string;
|
||||
|
||||
Reference in New Issue
Block a user