feat: add Selenium Settings page to configure paymentGroupId per office
Adds a new Settings → Advanced → Selenium Settings page where the office name (paymentGroupId) used in United/DentalHub portal dropdowns can be configured without touching code. Previously hardcoded as "Summit Dental Care"; now injected from DB into the three United workers at job dispatch. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -44,6 +44,7 @@ import feeScheduleRoutes from "./feeSchedule";
|
||||
import licenseRoutes from "./license";
|
||||
import insuranceStatusBcbsMaRoutes from "./insuranceStatusBcbsMa";
|
||||
import labRxRoutes from "./lab-rx";
|
||||
import seleniumSettingsRoutes from "./selenium-settings";
|
||||
|
||||
const router = Router();
|
||||
|
||||
@@ -92,5 +93,6 @@ router.use("/shopping-vendors", shoppingVendorsRoutes);
|
||||
router.use("/fee-schedule", feeScheduleRoutes);
|
||||
router.use("/license", licenseRoutes);
|
||||
router.use("/lab-rx", labRxRoutes);
|
||||
router.use("/selenium-settings", seleniumSettingsRoutes);
|
||||
|
||||
export default router;
|
||||
|
||||
@@ -3,6 +3,7 @@ import { storage } from "../storage";
|
||||
import { enqueueSeleniumJob } from "../queue/jobRunner";
|
||||
import { forwardOtpToSeleniumUnitedDHClaimAgent } from "../services/seleniumUnitedDHClaimClient";
|
||||
import { io } from "../socket";
|
||||
import { prisma as db } from "@repo/db/client";
|
||||
|
||||
const router = Router();
|
||||
|
||||
@@ -40,11 +41,14 @@ router.post("/uniteddh-claim", async (req: Request, res: Response): Promise<any>
|
||||
});
|
||||
}
|
||||
|
||||
const seleniumSettings = await db.seleniumSettings.findUnique({ where: { userId: req.user.id } });
|
||||
|
||||
const enrichedPayload = {
|
||||
claim: {
|
||||
...claimData,
|
||||
uniteddhUsername: credentials.username,
|
||||
uniteddhPassword: credentials.password,
|
||||
paymentGroupId: seleniumSettings?.paymentGroupId ?? "",
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import { storage } from "../storage";
|
||||
import { enqueueSeleniumJob } from "../queue/jobRunner";
|
||||
import { forwardOtpToSeleniumUnitedDHPreAuthAgent } from "../services/seleniumUnitedDHPreAuthClient";
|
||||
import { io } from "../socket";
|
||||
import { prisma as db } from "@repo/db/client";
|
||||
|
||||
const router = Router();
|
||||
|
||||
@@ -40,11 +41,14 @@ router.post("/uniteddh-preauth", async (req: Request, res: Response): Promise<an
|
||||
});
|
||||
}
|
||||
|
||||
const seleniumSettings = await db.seleniumSettings.findUnique({ where: { userId: req.user.id } });
|
||||
|
||||
const enrichedPayload = {
|
||||
claim: {
|
||||
...claimData,
|
||||
uniteddhUsername: credentials.username,
|
||||
uniteddhPassword: credentials.password,
|
||||
paymentGroupId: seleniumSettings?.paymentGroupId ?? "",
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import { storage } from "../storage";
|
||||
import { forwardOtpToSeleniumUnitedSCOAgent } from "../services/seleniumUnitedSCOEligibilityClient";
|
||||
import { io } from "../socket";
|
||||
import { enqueueSeleniumJob } from "../queue/jobRunner";
|
||||
import { prisma as db } from "@repo/db/client";
|
||||
|
||||
const router = Router();
|
||||
|
||||
@@ -62,10 +63,13 @@ router.post(
|
||||
});
|
||||
}
|
||||
|
||||
const seleniumSettings = await db.seleniumSettings.findUnique({ where: { userId: req.user.id } });
|
||||
|
||||
const enrichedData = {
|
||||
...rawData,
|
||||
unitedscoUsername: credentials.username,
|
||||
unitedscoPassword: credentials.password,
|
||||
paymentGroupId: seleniumSettings?.paymentGroupId ?? "",
|
||||
};
|
||||
|
||||
const socketId: string | undefined = req.body.socketId;
|
||||
|
||||
42
apps/Backend/src/routes/selenium-settings.ts
Normal file
42
apps/Backend/src/routes/selenium-settings.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { Router, Request, Response } from "express";
|
||||
import { prisma as db } from "@repo/db/client";
|
||||
|
||||
const router = Router();
|
||||
|
||||
// GET /api/selenium-settings
|
||||
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 settings = await db.seleniumSettings.findUnique({ where: { userId } });
|
||||
return res.status(200).json({ paymentGroupId: settings?.paymentGroupId ?? "" });
|
||||
} catch (err) {
|
||||
return res.status(500).json({ error: "Failed to fetch Selenium settings", details: String(err) });
|
||||
}
|
||||
});
|
||||
|
||||
// PUT /api/selenium-settings
|
||||
router.put("/", async (req: Request, res: Response): Promise<any> => {
|
||||
try {
|
||||
const userId = req.user?.id;
|
||||
if (!userId) return res.status(401).json({ message: "Unauthorized" });
|
||||
|
||||
const { paymentGroupId } = req.body;
|
||||
if (typeof paymentGroupId !== "string") {
|
||||
return res.status(400).json({ message: "paymentGroupId must be a string" });
|
||||
}
|
||||
|
||||
const settings = await db.seleniumSettings.upsert({
|
||||
where: { userId },
|
||||
update: { paymentGroupId: paymentGroupId.trim() },
|
||||
create: { userId, paymentGroupId: paymentGroupId.trim() },
|
||||
});
|
||||
|
||||
return res.status(200).json({ paymentGroupId: settings.paymentGroupId });
|
||||
} catch (err) {
|
||||
return res.status(500).json({ error: "Failed to save Selenium settings", details: String(err) });
|
||||
}
|
||||
});
|
||||
|
||||
export default router;
|
||||
@@ -30,6 +30,7 @@ import {
|
||||
Building2,
|
||||
Timer,
|
||||
BookOpen,
|
||||
MonitorCog,
|
||||
GraduationCap,
|
||||
ShoppingCart,
|
||||
Search,
|
||||
@@ -291,6 +292,11 @@ export function Sidebar() {
|
||||
path: "/settings/aichat",
|
||||
icon: <Bot className="h-4 w-4 text-gray-400" />,
|
||||
},
|
||||
{
|
||||
name: "Selenium Settings",
|
||||
path: "/settings/selenium",
|
||||
icon: <MonitorCog className="h-4 w-4 text-gray-400" />,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
110
apps/Frontend/src/components/settings/selenium-settings-card.tsx
Normal file
110
apps/Frontend/src/components/settings/selenium-settings-card.tsx
Normal file
@@ -0,0 +1,110 @@
|
||||
import { useState, useEffect } from "react";
|
||||
import { useQuery, useMutation } from "@tanstack/react-query";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { CheckCircle } from "lucide-react";
|
||||
import { useToast } from "@/hooks/use-toast";
|
||||
import { apiRequest, queryClient } from "@/lib/queryClient";
|
||||
|
||||
type SeleniumSettings = {
|
||||
paymentGroupId: string;
|
||||
};
|
||||
|
||||
export function SeleniumSettingsCard() {
|
||||
const { toast } = useToast();
|
||||
const [paymentGroupId, setPaymentGroupId] = useState("");
|
||||
|
||||
const { data: settings, isLoading } = useQuery<SeleniumSettings | null>({
|
||||
queryKey: ["/api/selenium-settings"],
|
||||
queryFn: async () => {
|
||||
const res = await apiRequest("GET", "/api/selenium-settings");
|
||||
if (!res.ok) return null;
|
||||
return res.json();
|
||||
},
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (settings) {
|
||||
setPaymentGroupId(settings.paymentGroupId ?? "");
|
||||
}
|
||||
}, [settings]);
|
||||
|
||||
const saveMutation = useMutation({
|
||||
mutationFn: async (data: SeleniumSettings) => {
|
||||
const res = await apiRequest("PUT", "/api/selenium-settings", data);
|
||||
if (!res.ok) {
|
||||
const err = await res.json().catch(() => null);
|
||||
throw new Error(err?.message || "Failed to save Selenium settings");
|
||||
}
|
||||
return res.json();
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ["/api/selenium-settings"] });
|
||||
toast({ title: "Selenium Settings Saved" });
|
||||
},
|
||||
onError: (err: any) => {
|
||||
toast({ title: "Error", description: err?.message || "Failed to save settings", variant: "destructive" });
|
||||
},
|
||||
});
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<Card>
|
||||
<CardContent className="py-6">
|
||||
<p className="text-sm text-gray-500">Loading...</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<CardContent className="space-y-6 py-6">
|
||||
<div>
|
||||
<div className="flex items-center gap-2">
|
||||
<h3 className="text-lg font-semibold">Selenium Settings</h3>
|
||||
{settings?.paymentGroupId && (
|
||||
<span className="flex items-center gap-1 text-xs text-green-600 font-medium">
|
||||
<CheckCircle className="h-3.5 w-3.5" /> Configured
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<p className="text-sm text-gray-500 mt-1">
|
||||
Configure values used by Selenium automation workers (United eligibility, claim, and pre-auth).
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<form
|
||||
className="space-y-4"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
saveMutation.mutate({ paymentGroupId });
|
||||
}}
|
||||
>
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-700">
|
||||
Payment Group ID
|
||||
</label>
|
||||
<p className="text-xs text-gray-400 mb-1">
|
||||
The office name as it appears in the United/DentalHub portal dropdown (e.g. "Summit Dental Care" or "Broadway Dental").
|
||||
</p>
|
||||
<input
|
||||
type="text"
|
||||
value={paymentGroupId}
|
||||
onChange={(e) => setPaymentGroupId(e.target.value)}
|
||||
className="mt-1 p-2 border rounded w-full"
|
||||
placeholder="e.g. Summit Dental Care"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
className="bg-teal-600 text-white px-4 py-2 rounded hover:bg-teal-700 disabled:opacity-50"
|
||||
disabled={saveMutation.isPending}
|
||||
>
|
||||
{saveMutation.isPending ? "Saving..." : "Save Settings"}
|
||||
</button>
|
||||
</form>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import { OfficeContactCard } from "@/components/settings/office-contact-card";
|
||||
import { ProcedureTimeslotCard } from "@/components/settings/procedure-timeslot-card";
|
||||
import { InsuranceContactCard } from "@/components/settings/insurance-contact-card";
|
||||
import { AiChatSettingsCard } from "@/components/settings/ai-chat-settings-card";
|
||||
import { SeleniumSettingsCard } from "@/components/settings/selenium-settings-card";
|
||||
|
||||
type SectionId =
|
||||
| "staff"
|
||||
@@ -34,7 +35,8 @@ type SectionId =
|
||||
| "officehours"
|
||||
| "officecontact"
|
||||
| "proceduretimeslot"
|
||||
| "insurancecontact";
|
||||
| "insurancecontact"
|
||||
| "selenium";
|
||||
|
||||
export default function SettingsPage() {
|
||||
const { toast } = useToast();
|
||||
@@ -276,6 +278,9 @@ export default function SettingsPage() {
|
||||
case "insurancecontact":
|
||||
return <InsuranceContactCard />;
|
||||
|
||||
case "selenium":
|
||||
return <SeleniumSettingsCard />;
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ class AutomationUnitedDHClaimSubmit:
|
||||
|
||||
self.uniteddh_username = claim.get("uniteddhUsername", "")
|
||||
self.uniteddh_password = claim.get("uniteddhPassword", "")
|
||||
self.payment_group_id = claim.get("paymentGroupId", "")
|
||||
|
||||
self.download_dir = get_browser_manager().download_dir
|
||||
os.makedirs(self.download_dir, exist_ok=True)
|
||||
@@ -595,11 +596,11 @@ class AutomationUnitedDHClaimSubmit:
|
||||
try:
|
||||
summit_option = WebDriverWait(self.driver, 5).until(
|
||||
EC.element_to_be_clickable((By.XPATH,
|
||||
"//ng-dropdown-panel//div[contains(@class,'ng-option') and contains(.,'Summit Dental Care')]"
|
||||
f"//ng-dropdown-panel//div[contains(@class,'ng-option') and contains(.,'{self.payment_group_id}')]"
|
||||
))
|
||||
)
|
||||
summit_option.click()
|
||||
print("[UnitedDH Claim] step1: Selected Treatment Location: Summit Dental Care")
|
||||
print(f"[UnitedDH Claim] step1: Selected Treatment Location: {self.payment_group_id}")
|
||||
location_selected = True
|
||||
except TimeoutException:
|
||||
try:
|
||||
@@ -632,11 +633,11 @@ class AutomationUnitedDHClaimSubmit:
|
||||
try:
|
||||
summit_option = WebDriverWait(self.driver, 5).until(
|
||||
EC.element_to_be_clickable((By.XPATH,
|
||||
"//ng-dropdown-panel//div[contains(@class,'ng-option') and contains(.,'Summit Dental Care')]"
|
||||
f"//ng-dropdown-panel//div[contains(@class,'ng-option') and contains(.,'{self.payment_group_id}')]"
|
||||
))
|
||||
)
|
||||
summit_option.click()
|
||||
print("[UnitedDH Claim] step1: Selected Billing Entity: Summit Dental Care")
|
||||
print(f"[UnitedDH Claim] step1: Selected Billing Entity: {self.payment_group_id}")
|
||||
billing_selected = True
|
||||
except TimeoutException:
|
||||
try:
|
||||
|
||||
@@ -52,6 +52,7 @@ class AutomationUnitedDHPreAuth:
|
||||
|
||||
self.uniteddh_username = claim.get("uniteddhUsername", "")
|
||||
self.uniteddh_password = claim.get("uniteddhPassword", "")
|
||||
self.payment_group_id = claim.get("paymentGroupId", "")
|
||||
|
||||
self.download_dir = get_browser_manager().download_dir
|
||||
os.makedirs(self.download_dir, exist_ok=True)
|
||||
@@ -554,11 +555,11 @@ class AutomationUnitedDHPreAuth:
|
||||
try:
|
||||
summit_option = WebDriverWait(self.driver, 5).until(
|
||||
EC.element_to_be_clickable((By.XPATH,
|
||||
"//ng-dropdown-panel//div[contains(@class,'ng-option') and contains(.,'Summit Dental Care')]"
|
||||
f"//ng-dropdown-panel//div[contains(@class,'ng-option') and contains(.,'{self.payment_group_id}')]"
|
||||
))
|
||||
)
|
||||
summit_option.click()
|
||||
print("[UnitedDH PreAuth] step1: Selected Treatment Location: Summit Dental Care")
|
||||
print(f"[UnitedDH PreAuth] step1: Selected Treatment Location: {self.payment_group_id}")
|
||||
location_selected = True
|
||||
except TimeoutException:
|
||||
try:
|
||||
@@ -590,11 +591,11 @@ class AutomationUnitedDHPreAuth:
|
||||
try:
|
||||
summit_option = WebDriverWait(self.driver, 5).until(
|
||||
EC.element_to_be_clickable((By.XPATH,
|
||||
"//ng-dropdown-panel//div[contains(@class,'ng-option') and contains(.,'Summit Dental Care')]"
|
||||
f"//ng-dropdown-panel//div[contains(@class,'ng-option') and contains(.,'{self.payment_group_id}')]"
|
||||
))
|
||||
)
|
||||
summit_option.click()
|
||||
print("[UnitedDH PreAuth] step1: Selected Billing Entity: Summit Dental Care")
|
||||
print(f"[UnitedDH PreAuth] step1: Selected Billing Entity: {self.payment_group_id}")
|
||||
billing_selected = True
|
||||
except TimeoutException:
|
||||
try:
|
||||
|
||||
@@ -27,6 +27,7 @@ class AutomationUnitedSCOEligibilityCheck:
|
||||
self.lastName = self.data.get("lastName", "")
|
||||
self.unitedsco_username = self.data.get("unitedscoUsername", "")
|
||||
self.unitedsco_password = self.data.get("unitedscoPassword", "")
|
||||
self.payment_group_id = self.data.get("paymentGroupId", "")
|
||||
|
||||
# Use browser manager's download dir
|
||||
self.download_dir = get_browser_manager().download_dir
|
||||
@@ -653,11 +654,11 @@ class AutomationUnitedSCOEligibilityCheck:
|
||||
try:
|
||||
summit_option = WebDriverWait(self.driver, 5).until(
|
||||
EC.element_to_be_clickable((By.XPATH,
|
||||
"//ng-dropdown-panel//div[contains(@class,'ng-option') and contains(.,'Summit Dental Care')]"
|
||||
f"//ng-dropdown-panel//div[contains(@class,'ng-option') and contains(.,'{self.payment_group_id}')]"
|
||||
))
|
||||
)
|
||||
summit_option.click()
|
||||
print("[UnitedSCO step1] Selected Treatment Location: Summit Dental Care")
|
||||
print(f"[UnitedSCO step1] Selected Treatment Location: {self.payment_group_id}")
|
||||
location_selected = True
|
||||
except TimeoutException:
|
||||
try:
|
||||
@@ -691,11 +692,11 @@ class AutomationUnitedSCOEligibilityCheck:
|
||||
try:
|
||||
summit_option = WebDriverWait(self.driver, 5).until(
|
||||
EC.element_to_be_clickable((By.XPATH,
|
||||
"//ng-dropdown-panel//div[contains(@class,'ng-option') and contains(.,'Summit Dental Care')]"
|
||||
f"//ng-dropdown-panel//div[contains(@class,'ng-option') and contains(.,'{self.payment_group_id}')]"
|
||||
))
|
||||
)
|
||||
summit_option.click()
|
||||
print("[UnitedSCO step1] Selected Billing Entity: Summit Dental Care")
|
||||
print(f"[UnitedSCO step1] Selected Billing Entity: {self.payment_group_id}")
|
||||
billing_selected = True
|
||||
except TimeoutException:
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user