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:
@@ -2,6 +2,7 @@ import { Router, Request, Response } from "express";
|
|||||||
import { storage } from "../storage";
|
import { storage } from "../storage";
|
||||||
import { enqueueSeleniumJob } from "../queue/jobRunner";
|
import { enqueueSeleniumJob } from "../queue/jobRunner";
|
||||||
import multer from "multer";
|
import multer from "multer";
|
||||||
|
import { appendAppointmentFiles } from "../utils/appointmentAttachments";
|
||||||
|
|
||||||
const router = Router();
|
const router = Router();
|
||||||
const upload = multer({ storage: multer.memoryStorage() });
|
const upload = multer({ storage: multer.memoryStorage() });
|
||||||
@@ -59,6 +60,11 @@ router.post(
|
|||||||
bufferBase64: f.buffer.toString("base64"),
|
bufferBase64: f.buffer.toString("base64"),
|
||||||
mimetype: f.mimetype,
|
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 = {
|
const enrichedPayload = {
|
||||||
claim: {
|
claim: {
|
||||||
|
|||||||
@@ -1183,11 +1183,9 @@ export function ClaimForm({
|
|||||||
const appointmentIdToUse = appointmentId ?? null;
|
const appointmentIdToUse = appointmentId ?? null;
|
||||||
|
|
||||||
const { uploadedFiles, insuranceSiteKey, npiProvider, ...formToCreateClaim } = f;
|
const { uploadedFiles, insuranceSiteKey, npiProvider, ...formToCreateClaim } = f;
|
||||||
|
// Save uploaded files to disk (uploads/patients/<name>/) and record their paths
|
||||||
const claimFilesMeta: ClaimFileMeta[] = mergeWithExistingAttachments(
|
const claimFilesMeta: ClaimFileMeta[] = mergeWithExistingAttachments(
|
||||||
(uploadedFiles || []).map((file) => ({
|
uploadedFiles?.length ? await uploadAttachmentsToLocalFolder(uploadedFiles) : [],
|
||||||
filename: file.name,
|
|
||||||
mimeType: file.type,
|
|
||||||
})),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const selectedNpiProviderId = npiProvider?.npiNumber
|
const selectedNpiProviderId = npiProvider?.npiNumber
|
||||||
@@ -1216,6 +1214,7 @@ export function ClaimForm({
|
|||||||
appointmentId: appointmentIdToUse,
|
appointmentId: appointmentIdToUse,
|
||||||
insuranceSiteKey: "CCA",
|
insuranceSiteKey: "CCA",
|
||||||
claimId: createdClaim.id,
|
claimId: createdClaim.id,
|
||||||
|
skipAppointmentAttachmentMerge: !!autoSubmit && !!uploadedFiles?.length,
|
||||||
});
|
});
|
||||||
|
|
||||||
onClose();
|
onClose();
|
||||||
|
|||||||
Reference in New Issue
Block a user