fix: CCA claim includes appointment attachments in Selenium upload

The CCA claim route only forwarded files uploaded in the current request,
so attachments already saved on the appointment never reached the portal.
Merge them like the MassHealth and CCA Pre-Auth routes do, and save new
uploads to the patient folder instead of recording filenames only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-09 10:44:15 -05:00
co-authored by Claude Opus 5.5
parent 0db69a34b6
commit 2352922089
2 changed files with 9 additions and 4 deletions
@@ -2,6 +2,7 @@ import { Router, Request, Response } from "express";
import { storage } from "../storage";
import { enqueueSeleniumJob } from "../queue/jobRunner";
import multer from "multer";
import { appendAppointmentFiles } from "../utils/appointmentAttachments";
const router = Router();
const upload = multer({ storage: multer.memoryStorage() });
@@ -59,6 +60,11 @@ router.post(
bufferBase64: f.buffer.toString("base64"),
mimetype: f.mimetype,
}));
// Include attachments already saved on the appointment (X-rays etc.). Skipped for
// chatbot-driven submissions, which already send every intended file.
if (!claimData.skipAppointmentAttachmentMerge) {
await appendAppointmentFiles(filesForQueue, claimData.appointmentId);
}
const enrichedPayload = {
claim: {
@@ -1183,11 +1183,9 @@ export function ClaimForm({
const appointmentIdToUse = appointmentId ?? null;
const { uploadedFiles, insuranceSiteKey, npiProvider, ...formToCreateClaim } = f;
// Save uploaded files to disk (uploads/patients/<name>/) and record their paths
const claimFilesMeta: ClaimFileMeta[] = mergeWithExistingAttachments(
(uploadedFiles || []).map((file) => ({
filename: file.name,
mimeType: file.type,
})),
uploadedFiles?.length ? await uploadAttachmentsToLocalFolder(uploadedFiles) : [],
);
const selectedNpiProviderId = npiProvider?.npiNumber
@@ -1216,6 +1214,7 @@ export function ClaimForm({
appointmentId: appointmentIdToUse,
insuranceSiteKey: "CCA",
claimId: createdClaim.id,
skipAppointmentAttachmentMerge: !!autoSubmit && !!uploadedFiles?.length,
});
onClose();