From 235292208990e07eae7ef5750403d9a3c664f3ec Mon Sep 17 00:00:00 2001 From: Gitead Date: Mon, 9 Nov 2026 10:44:15 -0500 Subject: [PATCH] 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 --- apps/Backend/src/routes/insuranceStatusCCAClaim.ts | 6 ++++++ apps/Frontend/src/components/claims/claim-form.tsx | 7 +++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/Backend/src/routes/insuranceStatusCCAClaim.ts b/apps/Backend/src/routes/insuranceStatusCCAClaim.ts index 21fca66e..52441163 100644 --- a/apps/Backend/src/routes/insuranceStatusCCAClaim.ts +++ b/apps/Backend/src/routes/insuranceStatusCCAClaim.ts @@ -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: { diff --git a/apps/Frontend/src/components/claims/claim-form.tsx b/apps/Frontend/src/components/claims/claim-form.tsx index 012485cc..999b3516 100755 --- a/apps/Frontend/src/components/claims/claim-form.tsx +++ b/apps/Frontend/src/components/claims/claim-form.tsx @@ -1183,11 +1183,9 @@ export function ClaimForm({ const appointmentIdToUse = appointmentId ?? null; const { uploadedFiles, insuranceSiteKey, npiProvider, ...formToCreateClaim } = f; + // Save uploaded files to disk (uploads/patients//) 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();