feat: Check PreAuth sets claim Approved/Denied from portal status, Tufts SCO denied preauth PDF
- Add DENIED claim status (migration) and show it in claims list, view and edit - Check PreAuth updates the claim status from the portal result and refreshes the claims list - Tufts SCO: read Status column from any cell type, sturdier click into the pre-auth detail page (JS fallback, new tab), procedure section optional, status in the saved PDF filename, log failures Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -119,6 +119,14 @@ async function savePreauthHistory(claimId: number | undefined, preAuthNumber: st
|
||||
log("preauth history saved", { claimId, patientId: claim.patientId, rows: procedures.length });
|
||||
}
|
||||
|
||||
// Portal status text (e.g. "Approved", "Denied") -> claim status; null leaves the claim as is.
|
||||
function claimStatusForPortalStatus(portalStatus: unknown): "APPROVED" | "DENIED" | null {
|
||||
const s = String(portalStatus ?? "").toLowerCase();
|
||||
if (s.includes("denied") || s.includes("rejected")) return "DENIED";
|
||||
if (s.includes("approved")) return "APPROVED";
|
||||
return null;
|
||||
}
|
||||
|
||||
export async function runPreAuthCheckProcessor(
|
||||
input: {
|
||||
siteKey: PreAuthCheckSiteKey;
|
||||
@@ -149,6 +157,15 @@ export async function runPreAuthCheckProcessor(
|
||||
throw new Error(result?.message ?? "Check PreAuth returned an error");
|
||||
}
|
||||
let message = typeof result.message === "string" ? result.message : "completed";
|
||||
const newStatus = claimStatusForPortalStatus(result.preAuthStatus);
|
||||
if (newStatus && claimId) {
|
||||
try {
|
||||
await storage.updateClaimStatus(claimId, newStatus);
|
||||
message += ` Status set to ${newStatus === "DENIED" ? "Denied" : "Approved"}.`;
|
||||
} catch (e: any) {
|
||||
log("updating claim status failed", { claimId, error: e?.message });
|
||||
}
|
||||
}
|
||||
try {
|
||||
if (result.approval_pdf_path) {
|
||||
const saved = await saveApprovalPdf(userId, claimId, result.approval_pdf_path);
|
||||
|
||||
Reference in New Issue
Block a user