feat: DDMA claim submission with OTP, PDF, claim number extraction

- Add full DDMA claim Selenium flow (steps 1-8): search patient, open
  member page, create claim, fill form, attach files, next, submit,
  extract claim number and save confirmation PDF
- Add fee schedule price-mismatch dialog for all claim buttons (MH,
  CCA, DDMA, United, Tufts, Save) with optional price update to JSON
- Add OTP modal for DDMA claim when session expires, mirroring
  eligibility OTP flow
- Close Chrome after claim submission via quit_driver() (session
  preserved in profile)
- Move Map Price button between Direct Submission and procedure table,
  right-aligned above Billed Amount column
- Add fee-schedule update-price backend route
- Add DDMA claim processor with claimNumber/pdf_url result handling

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Gitead
2026-05-24 13:35:04 -04:00
parent 5ceecbeb7f
commit cd1381e9c6
13 changed files with 2139 additions and 22 deletions

View File

@@ -0,0 +1,69 @@
import { Router, Request, Response } from "express";
import path from "path";
import fs from "fs";
const router = Router();
const SCHEDULE_FILES: Record<string, string> = {
MH: "procedureCodesMH.json",
MASSHEALTH: "procedureCodesMH.json",
CCA: "procedureCodesCCA.json",
DDMA: "procedureCodesDDMA.json",
};
function getSchedulePath(siteKey: string): string | null {
const filename = SCHEDULE_FILES[siteKey.toUpperCase()];
if (!filename) return null;
return path.join(process.cwd(), "..", "Frontend", "src", "assets", "data", filename);
}
/**
* POST /api/fee-schedule/update-price
* Body: { siteKey, procedureCode, price }
* Updates the matching row's Price field in the fee schedule JSON.
*/
router.post("/update-price", async (req: Request, res: Response): Promise<any> => {
if (!req.user?.id) return res.status(401).json({ error: "Unauthorized" });
const { siteKey, procedureCode, price } = req.body;
if (!siteKey || !procedureCode || price == null) {
return res.status(400).json({ error: "siteKey, procedureCode and price are required" });
}
const filePath = getSchedulePath(siteKey);
if (!filePath) {
return res.status(400).json({ error: `No fee schedule for siteKey: ${siteKey}` });
}
try {
const raw = fs.readFileSync(filePath, "utf-8");
const rows: any[] = JSON.parse(raw);
const normalizedCode = String(procedureCode).trim().toUpperCase();
let updated = false;
for (const row of rows) {
const rowCode = String(row["Procedure Code"] || "").trim().toUpperCase();
if (rowCode === normalizedCode) {
// Update whichever price field(s) exist in this row
if ("Price" in row) row["Price"] = price;
if ("PriceLTEQ21" in row) row["PriceLTEQ21"] = price;
if ("PriceGT21" in row) row["PriceGT21"] = price;
updated = true;
break;
}
}
if (!updated) {
return res.status(404).json({ error: `Procedure code ${procedureCode} not found in ${siteKey} schedule` });
}
fs.writeFileSync(filePath, JSON.stringify(rows, null, 2), "utf-8");
console.log(`[feeSchedule] Updated ${siteKey} ${procedureCode}${price}`);
return res.json({ success: true });
} catch (err: any) {
console.error("[feeSchedule] Error:", err);
return res.status(500).json({ error: err.message });
}
});
export default router;