feat: Altus Dental eligibility check and ADA paper claim/preauth

Eligibility (no OTP, fresh browser per run like MH): logs in, opens Benefits &
Claims Information, searches by Subscriber ID (or Subscriber Last Name via
"Click Here"), First Name and DOB, picks the matching row from the patient list,
sets ACTIVE/INACTIVE from the Coverage range, reads Group Number into the
patient's Group Number, opens View Details for the last name and plan name,
and saves the details page PDF to the patient's Eligibility folder. A patient
switching plans is matched by name + DOB so Altus overwrites the old insurance
instead of creating a duplicate.

Claims: Altus uses the same 2024 ADA form as BCBS with the Altus payer address
(P.O. Box 1557, Providence, RI 02901-1557). Adds Altus Claim/PreAuth (ADA Form)
buttons, Claim All and AI queue routing, Print ADA Form in the claim viewer, and
an Altus fee schedule (copied from BCBS).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-15 00:47:01 -04:00
co-authored by Claude Opus 5.5
parent fa6c55421c
commit db7d74a13b
21 changed files with 1388 additions and 33 deletions
@@ -1587,6 +1587,8 @@ export function ClaimForm({
runWithPriceCheck(handleUnitedUcardClaim);
} else if (siteKey === "BCBS" || siteKey === "BCBS_MA") {
runWithPriceCheck(() => handleBCBSClaim());
} else if (siteKey === "ALTUS") {
runWithPriceCheck(() => handleAltusClaim());
} else {
toast({
title: "No automated claim for this insurance",
@@ -1916,15 +1918,22 @@ export function ClaimForm({
// Saves claim to DB with all info (member ID, DOB, service date, provider, CDT codes, NPI).
// No Selenium action — works like a real MassHealth claim for payment/report tracking.
// BCBS MA has no online claim submission: save the claim, then open the filled
// 2024 ADA paper form to print, sign and mail.
// BCBS MA and Altus have no online claim submission: save the claim, then open the
// filled 2024 ADA paper form (payer address per insurance) to print, sign and mail.
// `auto` (AI claim queue): no tab — just save the filled form to Documents > Claims.
// `preauth`: same ADA form with box 1 "Request for Predetermination/Preauthorization"
// ticked (claim saved as PREAUTH), saved to Documents > PreAuth.
const handleBCBSClaim = async (
const ADA_PAPER_PAYERS = {
BCBS_MA: { label: "BCBS", insuranceProvider: "BCBS MA", mailTo: "BCBS MA" },
ALTUS: { label: "Altus", insuranceProvider: "Altus Dental", mailTo: "Altus Dental" },
} as const;
const handleAdaPaperClaim = async (
payerKey: keyof typeof ADA_PAPER_PAYERS,
formToUse?: ClaimFormData & { uploadedFiles?: File[] },
{ auto = false, preauth = false }: { auto?: boolean; preauth?: boolean } = {},
) => {
const payer = ADA_PAPER_PAYERS[payerKey];
const kind = preauth ? "preauth" : "claim";
const f = formToUse ?? form;
const missingFields: string[] = [];
@@ -1972,7 +1981,7 @@ export function ClaimForm({
serviceLines: filteredServiceLines,
staffId: appointmentStaffId ?? Number(staff?.id),
patientId: patientId,
insuranceProvider: "BCBS MA",
insuranceProvider: payer.insuranceProvider,
appointmentId: appointmentIdToUse,
claimFiles: claimFilesMeta,
...(selectedNpiProviderId ? { npiProviderId: selectedNpiProviderId } : {}),
@@ -1980,29 +1989,39 @@ export function ClaimForm({
} as any);
if (auto) {
await saveAdaClaimForm(createdClaim.id!);
await saveAdaClaimForm(createdClaim.id!, payerKey);
} else {
await showAdaClaimForm(createdClaim.id!, tab, "BCBS_MA", { save: true });
await showAdaClaimForm(createdClaim.id!, tab, payerKey, { save: true });
}
// Saving the form marks the claim submitted — show the appointment as claimed
queryClient.invalidateQueries({ queryKey: ["appointments", "day"] });
toast({
title: preauth ? "BCBS preauth form ready" : "BCBS claim form ready",
title: `${payer.label} ${kind} form ready`,
description: preauth
? "PreAuth saved and ADA form added to the patient's Documents > PreAuth. Print, sign, and mail it to BCBS MA."
: "Claim saved and ADA form added to the patient's Documents > Claims. Print, sign, and mail it to BCBS MA.",
? `PreAuth saved and ADA form added to the patient's Documents > PreAuth. Print, sign, and mail it to ${payer.mailTo}.`
: `Claim saved and ADA form added to the patient's Documents > Claims. Print, sign, and mail it to ${payer.mailTo}.`,
});
onClose();
} catch (err: any) {
tab?.close();
toast({
title: preauth ? "BCBS preauth failed" : "BCBS claim failed",
title: `${payer.label} ${kind} failed`,
description: err?.message ?? `Failed to create the ADA ${kind} form.`,
variant: "destructive",
});
}
};
const handleBCBSClaim = (
formToUse?: ClaimFormData & { uploadedFiles?: File[] },
opts?: { auto?: boolean; preauth?: boolean },
) => handleAdaPaperClaim("BCBS_MA", formToUse, opts);
const handleAltusClaim = (
formToUse?: ClaimFormData & { uploadedFiles?: File[] },
opts?: { auto?: boolean; preauth?: boolean },
) => handleAdaPaperClaim("ALTUS", formToUse, opts);
const handleClaimSaved = async () => {
const missingFields: string[] = [];
if (!form.memberId?.trim()) missingFields.push("Member ID");
@@ -2150,6 +2169,8 @@ export function ClaimForm({
handleUnitedUcardClaim(pricedForm);
} else if (key === "bcbs" || key === "bcbs_ma") {
handleBCBSClaim(pricedForm, { auto: true });
} else if (key === "altus") {
handleAltusClaim(pricedForm, { auto: true });
} else {
handleMHSubmit(pricedForm);
}
@@ -2177,6 +2198,13 @@ export function ClaimForm({
insuranceSiteKey: "bcbs",
});
handleBCBSClaim(pricedForm, { auto: true, preauth: true });
} else if (key === "altus") {
const pricedForm = mapPricesForForm({
form: { ...form, insuranceSiteKey: "altus" },
patientDOB: patient?.dateOfBirth ?? "",
insuranceSiteKey: "altus",
});
handleAltusClaim(pricedForm, { auto: true, preauth: true });
} else {
// Re-apply fee-schedule prices with the now-loaded patient DOB before submitting —
// the earlier chatbot-prefill pass may have run before `patient` finished loading,
@@ -2829,6 +2857,13 @@ export function ClaimForm({
>
BCBS Claim (ADA Form)
</Button>
<Button
className="w-44 bg-indigo-700 hover:bg-indigo-800 text-white"
onClick={() => runWithPriceCheck(() => handleAltusClaim())}
title="Save the claim and open a filled ADA paper form to print and mail to Altus Dental"
>
Altus Claim (ADA Form)
</Button>
<Button
className="w-36 bg-emerald-600 hover:bg-emerald-700 text-white"
onClick={() => runWithPriceCheck(handleClaimSaved)}
@@ -3371,6 +3406,13 @@ export function ClaimForm({
>
BCBS PreAuth (ADA Form)
</Button>
<Button
className="w-44 bg-indigo-700 hover:bg-indigo-800 text-white"
onClick={() => handleAltusClaim(undefined, { preauth: true })}
title="Save the preauth and open a filled ADA form (Request for Predetermination/Preauthorization) to print and mail to Altus Dental"
>
Altus PreAuth (ADA Form)
</Button>
</div>
</div>
</div>
@@ -354,12 +354,16 @@ export default function ClaimViewModal({
<Button variant="outline" onClick={() => onOpenChange(false)}>
Close
</Button>
{/bcbs|blue cross/i.test(claim.insuranceProvider ?? "") && (
{/bcbs|blue cross|altus/i.test(claim.insuranceProvider ?? "") && (
<Button
variant="outline"
onClick={() => {
const tab = openPendingTab();
showAdaClaimForm(claim.id!, tab).catch((err) =>
showAdaClaimForm(
claim.id!,
tab,
/altus/i.test(claim.insuranceProvider ?? "") ? "ALTUS" : "BCBS_MA",
).catch((err) =>
toast({
title: "ADA form failed",
description: err?.message ?? "Failed to generate ADA claim form.",
@@ -0,0 +1,202 @@
import { useEffect, useRef, useState } from "react";
import { Button } from "@/components/ui/button";
import { CheckCircle, LoaderCircleIcon } from "lucide-react";
import { useToast } from "@/hooks/use-toast";
import { apiRequest, queryClient } from "@/lib/queryClient";
import { useAppDispatch } from "@/redux/hooks";
import { setTaskStatus } from "@/redux/slices/seleniumTaskSlice";
import { formatLocalDate } from "@/utils/dateUtils";
import { socket } from "@/lib/socket";
import { QK_PATIENTS_BASE } from "@/components/patients/patient-table";
// ─── Main component ───────────────────────────────────────────────────────────
interface AltusEligibilityButtonProps {
memberId: string;
dateOfBirth: Date | null;
firstName?: string;
lastName?: string;
isFormIncomplete: boolean;
autoTrigger?: boolean;
onAutoTriggered?: () => void;
onPdfReady: (pdfId: number | string, fallbackFilename: string | null) => void;
}
export function AltusEligibilityButton({
memberId,
dateOfBirth,
firstName,
lastName,
isFormIncomplete,
autoTrigger,
onAutoTriggered,
onPdfReady,
}: AltusEligibilityButtonProps) {
const { toast } = useToast();
const dispatch = useAppDispatch();
const autoTriggeredRef = useRef(false);
const [isStarting, setIsStarting] = useState(false);
const handleStart = async () => {
if (!dateOfBirth || !firstName?.trim() || (!memberId && !lastName?.trim())) {
toast({
title: "Missing fields",
description: "Altus requires First Name, Date of Birth, and Member ID or Last Name.",
variant: "destructive",
});
return;
}
const formattedDob = formatLocalDate(dateOfBirth);
const payload = {
memberId,
dateOfBirth: formattedDob,
firstName: firstName?.trim(),
lastName: lastName?.trim(),
insuranceSiteKey: "ALTUS",
};
setIsStarting(true);
try {
dispatch(
setTaskStatus({
key: "eligibilityCheck",
status: "pending",
message: "Starting Altus eligibility check…",
})
);
const response = await apiRequest(
"POST",
"/api/insurance-status-altus/altus-eligibility",
{ data: JSON.stringify(payload), socketId: socket.id }
);
const result = await response.json();
if (!response.ok || result.error) {
throw new Error(result.error || `Server error (${response.status})`);
}
const jobId: string = result.jobId;
if (!jobId) throw new Error("No jobId returned from server");
dispatch(
setTaskStatus({
key: "eligibilityCheck",
status: "pending",
message: "Altus job queued. Logging in…",
})
);
function cleanup() {
clearTimeout(safetyTimer);
socket.off("job:update", onJobUpdate);
}
const onJobUpdate = (data: any) => {
if (String(data?.jobId) !== String(jobId)) return;
if (data.status === "active") {
dispatch(
setTaskStatus({
key: "eligibilityCheck",
status: "pending",
message: data.message ?? "Selenium browser starting…",
})
);
return;
}
cleanup();
if (data.status === "completed") {
dispatch(
setTaskStatus({
key: "eligibilityCheck",
status: "success",
message: "Altus eligibility updated and PDF attached to patient documents.",
})
);
toast({
title: "Altus eligibility complete",
description: "Patient status was updated and the eligibility PDF was saved.",
});
queryClient.invalidateQueries({ queryKey: QK_PATIENTS_BASE });
const pdfId = data.result?.pdfFileId;
if (pdfId) {
onPdfReady(pdfId, data.result?.pdfFilename ?? `eligibility_altus_${memberId || `${lastName}_${firstName}`}.pdf`);
}
} else if (data.status === "failed") {
const msg = data.error ?? "Altus eligibility job failed.";
dispatch(setTaskStatus({ key: "eligibilityCheck", status: "error", message: msg }));
toast({ title: "Altus selenium error", description: msg, variant: "destructive" });
}
setIsStarting(false);
};
socket.on("job:update", onJobUpdate);
const safetyTimer = setTimeout(() => {
cleanup();
setIsStarting(false);
dispatch(
setTaskStatus({
key: "eligibilityCheck",
status: "error",
message: "Altus job timed out waiting for completion.",
})
);
}, 6 * 60 * 1000);
} catch (err: any) {
console.error("AltusEligibilityButton error:", err);
dispatch(
setTaskStatus({
key: "eligibilityCheck",
status: "error",
message: err?.message || "Failed to start Altus eligibility",
})
);
toast({
title: "Altus selenium error",
description: err?.message || "Failed to start Altus eligibility",
variant: "destructive",
});
setIsStarting(false);
}
};
useEffect(() => {
if (!autoTrigger) { autoTriggeredRef.current = false; return; }
if (autoTriggeredRef.current || isFormIncomplete) return;
autoTriggeredRef.current = true;
onAutoTriggered?.();
handleStart();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [autoTrigger, isFormIncomplete]);
return (
<Button
className="w-full"
variant="default"
disabled={isFormIncomplete || isStarting}
onClick={handleStart}
>
{isStarting ? (
<>
<LoaderCircleIcon className="h-4 w-4 mr-2 animate-spin" />
Processing...
</>
) : (
<>
<CheckCircle className="h-4 w-4 mr-2" />
Altus
</>
)}
</Button>
);
}
@@ -143,6 +143,7 @@ const INSURANCE_TYPE_OPTIONS: { value: string; label: string }[] = [
{ value: "cca", label: "CCA" },
{ value: "bcbs-ma", label: "BCBS MA" },
{ value: "metlife", label: "MetLife" },
{ value: "altus", label: "Altus" },
];
function getAutoCheck(_dobISO: string): "mh" {
@@ -26,6 +26,7 @@ const SITE_KEY_OPTIONS = [
{ value: "CCA", label: "CCA (CCA)" },
{ value: "BCBS_MA", label: "BCBS MA (BCBS_MA)" },
{ value: "METLIFE", label: "MetLife Dental (METLIFE)" },
{ value: "ALTUS", label: "Altus Dental (ALTUS)" },
];
export function CredentialForm({ onClose, userId, defaultValues }: CredentialFormProps) {