feat: add Deltains claim submission flow

Adds a full "Deltains Claim" button next to Delta MA Claim, mirroring
the DDMA claim flow across frontend, backend queue/routes, and a new
Selenium worker. Reuses the existing Deltains eligibility login/OTP
code and was iteratively wired against the live portal (patient roster
search, per-service-line fields, tooth number/surface selects, review
and submit). Also fixes chatbot/insurance-alias carrier recognition so
"deltains" resolves correctly instead of falling back to MassHealth.
This commit is contained in:
2026-09-17 13:11:58 -04:00
parent 8cbdba092d
commit 37695130d3
14 changed files with 1769 additions and 1 deletions
@@ -98,6 +98,7 @@ interface ClaimFormProps {
onHandleForUnitedDHSeleniumPreAuth: (data: ClaimPreAuthData) => void;
onHandleForTuftsSCOSeleniumPreAuth: (data: ClaimPreAuthData) => void;
onHandleForDDMASeleniumClaim: (data: ClaimFormData) => void;
onHandleForDeltainsSeleniumClaim: (data: ClaimFormData) => void;
onHandleForUnitedDHSeleniumClaim: (data: ClaimFormData) => void;
onHandleForTuftsSCOSeleniumClaim: (data: ClaimFormData) => void;
onHandleForUnitedUcardSeleniumClaim: (data: ClaimFormData) => void;
@@ -121,6 +122,7 @@ export function ClaimForm({
onHandleForUnitedDHSeleniumPreAuth,
onHandleForTuftsSCOSeleniumPreAuth,
onHandleForDDMASeleniumClaim,
onHandleForDeltainsSeleniumClaim,
onHandleForUnitedDHSeleniumClaim,
onHandleForTuftsSCOSeleniumClaim,
onHandleForUnitedUcardSeleniumClaim,
@@ -1257,6 +1259,73 @@ export function ClaimForm({
onClose();
};
// Deltains Claim: saves to DB then submits via Selenium
const handleDeltainsClaim = async (formToUse?: ClaimFormData & { uploadedFiles?: File[] }) => {
const f = formToUse ?? form;
const missingFields: string[] = [];
if (!f.memberId?.trim()) missingFields.push("Member ID");
if (!f.dateOfBirth?.trim()) missingFields.push("Date of Birth");
if (!patient?.firstName?.trim()) missingFields.push("First Name");
if (missingFields.length > 0) {
toast({
title: "Missing Required Fields",
description: `Please fill out the following field(s): ${missingFields.join(", ")}`,
variant: "destructive",
});
return;
}
const filteredServiceLines = (f.serviceLines || []).filter(
(line) => (line.procedureCode ?? "").trim() !== "",
);
if (filteredServiceLines.length === 0) {
toast({
title: "No procedure codes",
description: "Please add at least one procedure code before submitting the claim.",
variant: "destructive",
});
return;
}
const appointmentIdToUse = appointmentId ?? null;
const { uploadedFiles, insuranceSiteKey, npiProvider, ...formToCreateClaim } = f;
// Upload files to server so we get local filePaths for Selenium
const claimFilesMeta: ClaimFileMeta[] = mergeWithExistingAttachments(
uploadedFiles?.length ? await uploadAttachmentsToLocalFolder(uploadedFiles) : [],
);
const selectedNpiProviderId = npiProvider?.npiNumber
? npiProviders.find((p) => p.npiNumber === npiProvider.npiNumber)?.id ?? null
: null;
const createdClaim = await onSubmit({
...formToCreateClaim,
serviceLines: filteredServiceLines,
staffId: appointmentStaffId ?? Number(staff?.id),
patientId,
insuranceProvider: "Delta Dental Ins",
appointmentId: appointmentIdToUse,
claimFiles: claimFilesMeta,
...(selectedNpiProviderId ? { npiProviderId: selectedNpiProviderId } : {}),
});
onHandleForDeltainsSeleniumClaim({
...f,
serviceLines: filteredServiceLines,
staffId: appointmentStaffId ?? Number(staff?.id),
patientId,
insuranceProvider: "Delta Dental Ins",
appointmentId: appointmentIdToUse,
insuranceSiteKey: "DELTAINS",
claimId: createdClaim.id,
claimFiles: claimFilesMeta,
});
onClose();
};
// United/DentalHub Claim: saves to DB then submits via Selenium
const handleUnitedDHClaim = async (formToUse?: ClaimFormData & { uploadedFiles?: File[] }) => {
const f = formToUse ?? form;
@@ -1483,6 +1552,8 @@ export function ClaimForm({
runWithPriceCheck(handleCCAClaim);
} else if (siteKey === "DDMA") {
runWithPriceCheck(handleDDMAClaim);
} else if (siteKey === "DELTAINS" || siteKey === "DELTA_INS") {
runWithPriceCheck(handleDeltainsClaim);
} else if (siteKey === "TUFTSSCO" || siteKey === "TUFTS_SCO") {
runWithPriceCheck(handleTuftsSCOClaim);
} else if (siteKey === "UNITEDSCO" || siteKey === "UNITEDDH" || siteKey === "UNITED_SCO") {
@@ -1954,6 +2025,8 @@ export function ClaimForm({
handleCCAClaim(pricedForm);
} else if (key === "ddma") {
handleDDMAClaim(pricedForm);
} else if (key === "deltains" || key === "delta_ins") {
handleDeltainsClaim(pricedForm);
} else if (key === "united_sco" || key === "unitedco" || key === "dentalhub") {
handleUnitedDHClaim(pricedForm);
} else if (key === "united_ucard" || key === "uniteducard" || key === "ucard") {
@@ -2591,6 +2664,14 @@ export function ClaimForm({
>
Delta MA Claim
</Button>
<Button
className="w-36 bg-indigo-600 hover:bg-indigo-700 text-white"
onClick={() => runWithPriceCheck(handleDeltainsClaim)}
disabled={!isLicensed}
title={!isLicensed ? "License required" : undefined}
>
Deltains Claim
</Button>
<Button
className="w-44 bg-orange-600 hover:bg-orange-700 text-white"
onClick={() => runWithPriceCheck(handleUnitedDHClaim)}
@@ -136,7 +136,7 @@ function mdyToISO(mdy: string): string {
const INSURANCE_TYPE_OPTIONS: { value: string; label: string }[] = [
{ value: "mh", label: "MassHealth" },
{ value: "ddma", label: "DDMA" },
{ value: "delta-ins", label: "Delta Dental" },
{ value: "delta-ins", label: "Deltains" },
{ value: "united-sco", label: "United SCO" },
{ value: "united-ucard", label: "United Ucard" },
{ value: "tufts-sco", label: "Tufts SCO" },