fix: remove auto appointment creation from claim submission
Claims no longer auto-create a schedule appointment when submitted — appointmentId is now optional. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -39,12 +39,10 @@ import {
|
||||
ClaimFormData,
|
||||
ClaimPreAuthData,
|
||||
InputServiceLine,
|
||||
InsertAppointment,
|
||||
MissingTeethStatus,
|
||||
NpiProvider,
|
||||
Patient,
|
||||
Staff,
|
||||
UpdateAppointment,
|
||||
UpdatePatient,
|
||||
} from "@repo/db/types";
|
||||
import { Decimal } from "decimal.js";
|
||||
@@ -89,9 +87,6 @@ interface ClaimFormProps {
|
||||
/** When true: form saves to AppointmentProcedure (Select Procedures flow), shows only Save button */
|
||||
proceduresOnly?: boolean;
|
||||
onSubmit: (data: ClaimFormData) => Promise<Claim>;
|
||||
onHandleAppointmentSubmit: (
|
||||
appointmentData: InsertAppointment | UpdateAppointment,
|
||||
) => Promise<number | { id: number }>;
|
||||
onHandleUpdatePatient: (patient: UpdatePatient & { id: number }) => void;
|
||||
onHandleForMHSeleniumClaim: (data: ClaimFormData) => void;
|
||||
onHandleForMHSeleniumClaimPreAuth: (data: ClaimPreAuthData) => void;
|
||||
@@ -114,7 +109,6 @@ export function ClaimForm({
|
||||
initialTab,
|
||||
autoSubmitPreauth,
|
||||
proceduresOnly = false,
|
||||
onHandleAppointmentSubmit,
|
||||
onHandleUpdatePatient,
|
||||
onHandleForMHSeleniumClaim,
|
||||
onHandleForMHSeleniumClaimPreAuth,
|
||||
@@ -952,28 +946,7 @@ export function ClaimForm({
|
||||
return;
|
||||
}
|
||||
|
||||
// 1. Create or update appointment
|
||||
let appointmentIdToUse = appointmentId;
|
||||
|
||||
if (appointmentIdToUse == null) {
|
||||
const appointmentData = {
|
||||
patientId: patientId,
|
||||
date: serviceDate,
|
||||
staffId: appointmentStaffId ?? staff?.id ?? 1,
|
||||
title: serviceDate,
|
||||
startTime: "09:00",
|
||||
endTime: "09:30",
|
||||
type: "recall",
|
||||
status: "scheduled",
|
||||
};
|
||||
const created = await onHandleAppointmentSubmit(appointmentData);
|
||||
|
||||
if (typeof created === "number" && created > 0) {
|
||||
appointmentIdToUse = created;
|
||||
} else if (created && typeof (created as any).id === "number") {
|
||||
appointmentIdToUse = (created as any).id;
|
||||
}
|
||||
}
|
||||
const appointmentIdToUse = appointmentId;
|
||||
|
||||
// 3. Create Claim(if not)
|
||||
// Filter out empty service lines (empty procedureCode)
|
||||
@@ -999,7 +972,7 @@ export function ClaimForm({
|
||||
staffId: appointmentStaffId ?? Number(staff?.id),
|
||||
patientId: patientId,
|
||||
insuranceProvider: "MassHealth",
|
||||
appointmentId: appointmentIdToUse!,
|
||||
appointmentId: appointmentIdToUse,
|
||||
claimFiles: claimFilesMeta,
|
||||
...(selectedNpiProviderId ? { npiProviderId: selectedNpiProviderId } : {}),
|
||||
});
|
||||
@@ -1013,7 +986,7 @@ export function ClaimForm({
|
||||
npiProvider: f.npiProvider,
|
||||
patientId: patientId,
|
||||
insuranceProvider: "Mass Health",
|
||||
appointmentId: appointmentIdToUse!,
|
||||
appointmentId: appointmentIdToUse,
|
||||
insuranceSiteKey: "MH",
|
||||
claimId: createdClaim.id,
|
||||
});
|
||||
@@ -1112,25 +1085,7 @@ export function ClaimForm({
|
||||
return;
|
||||
}
|
||||
|
||||
// Create appointment if needed
|
||||
let appointmentIdToUse = appointmentId;
|
||||
if (appointmentIdToUse == null) {
|
||||
const created = await onHandleAppointmentSubmit({
|
||||
patientId,
|
||||
date: serviceDate,
|
||||
staffId: appointmentStaffId ?? staff?.id ?? 1,
|
||||
title: serviceDate,
|
||||
startTime: "09:00",
|
||||
endTime: "09:30",
|
||||
type: "recall",
|
||||
status: "scheduled",
|
||||
});
|
||||
if (typeof created === "number" && created > 0) {
|
||||
appointmentIdToUse = created;
|
||||
} else if (created && typeof (created as any).id === "number") {
|
||||
appointmentIdToUse = (created as any).id;
|
||||
}
|
||||
}
|
||||
const appointmentIdToUse = appointmentId;
|
||||
|
||||
const { uploadedFiles, insuranceSiteKey, npiProvider, ...formToCreateClaim } = f;
|
||||
const claimFilesMeta: ClaimFileMeta[] = (uploadedFiles || []).map((file) => ({
|
||||
@@ -1149,7 +1104,7 @@ export function ClaimForm({
|
||||
staffId: appointmentStaffId ?? Number(staff?.id),
|
||||
patientId,
|
||||
insuranceProvider: "CCA",
|
||||
appointmentId: appointmentIdToUse!,
|
||||
appointmentId: appointmentIdToUse,
|
||||
claimFiles: claimFilesMeta,
|
||||
...(selectedNpiProviderId ? { npiProviderId: selectedNpiProviderId } : {}),
|
||||
});
|
||||
@@ -1161,7 +1116,7 @@ export function ClaimForm({
|
||||
staffId: appointmentStaffId ?? Number(staff?.id),
|
||||
patientId,
|
||||
insuranceProvider: "CCA",
|
||||
appointmentId: appointmentIdToUse!,
|
||||
appointmentId: appointmentIdToUse,
|
||||
insuranceSiteKey: "CCA",
|
||||
claimId: createdClaim.id,
|
||||
});
|
||||
@@ -1197,24 +1152,7 @@ export function ClaimForm({
|
||||
return;
|
||||
}
|
||||
|
||||
let appointmentIdToUse = appointmentId;
|
||||
if (appointmentIdToUse == null) {
|
||||
const created = await onHandleAppointmentSubmit({
|
||||
patientId,
|
||||
date: serviceDate,
|
||||
staffId: appointmentStaffId ?? staff?.id ?? 1,
|
||||
title: serviceDate,
|
||||
startTime: "09:00",
|
||||
endTime: "09:30",
|
||||
type: "recall",
|
||||
status: "scheduled",
|
||||
});
|
||||
if (typeof created === "number" && created > 0) {
|
||||
appointmentIdToUse = created;
|
||||
} else if (created && typeof (created as any).id === "number") {
|
||||
appointmentIdToUse = (created as any).id;
|
||||
}
|
||||
}
|
||||
const appointmentIdToUse = appointmentId;
|
||||
|
||||
const { uploadedFiles, insuranceSiteKey, npiProvider, ...formToCreateClaim } = f;
|
||||
|
||||
@@ -1233,7 +1171,7 @@ export function ClaimForm({
|
||||
staffId: appointmentStaffId ?? Number(staff?.id),
|
||||
patientId,
|
||||
insuranceProvider: "Delta Dental MA",
|
||||
appointmentId: appointmentIdToUse!,
|
||||
appointmentId: appointmentIdToUse,
|
||||
claimFiles: claimFilesMeta,
|
||||
...(selectedNpiProviderId ? { npiProviderId: selectedNpiProviderId } : {}),
|
||||
});
|
||||
@@ -1244,7 +1182,7 @@ export function ClaimForm({
|
||||
staffId: appointmentStaffId ?? Number(staff?.id),
|
||||
patientId,
|
||||
insuranceProvider: "Delta Dental MA",
|
||||
appointmentId: appointmentIdToUse!,
|
||||
appointmentId: appointmentIdToUse,
|
||||
insuranceSiteKey: "DDMA",
|
||||
claimId: createdClaim.id,
|
||||
claimFiles: claimFilesMeta,
|
||||
@@ -1281,24 +1219,7 @@ export function ClaimForm({
|
||||
return;
|
||||
}
|
||||
|
||||
let appointmentIdToUse = appointmentId;
|
||||
if (appointmentIdToUse == null) {
|
||||
const created = await onHandleAppointmentSubmit({
|
||||
patientId,
|
||||
date: serviceDate,
|
||||
staffId: appointmentStaffId ?? staff?.id ?? 1,
|
||||
title: serviceDate,
|
||||
startTime: "09:00",
|
||||
endTime: "09:30",
|
||||
type: "recall",
|
||||
status: "scheduled",
|
||||
});
|
||||
if (typeof created === "number" && created > 0) {
|
||||
appointmentIdToUse = created;
|
||||
} else if (created && typeof (created as any).id === "number") {
|
||||
appointmentIdToUse = (created as any).id;
|
||||
}
|
||||
}
|
||||
const appointmentIdToUse = appointmentId;
|
||||
|
||||
const { uploadedFiles, insuranceSiteKey, npiProvider, ...formToCreateClaim } = f;
|
||||
|
||||
@@ -1316,7 +1237,7 @@ export function ClaimForm({
|
||||
staffId: appointmentStaffId ?? Number(staff?.id),
|
||||
patientId,
|
||||
insuranceProvider: "United/DentalHub",
|
||||
appointmentId: appointmentIdToUse!,
|
||||
appointmentId: appointmentIdToUse,
|
||||
claimFiles: claimFilesMeta,
|
||||
...(selectedNpiProviderId ? { npiProviderId: selectedNpiProviderId } : {}),
|
||||
});
|
||||
@@ -1327,7 +1248,7 @@ export function ClaimForm({
|
||||
staffId: appointmentStaffId ?? Number(staff?.id),
|
||||
patientId,
|
||||
insuranceProvider: "United/DentalHub",
|
||||
appointmentId: appointmentIdToUse!,
|
||||
appointmentId: appointmentIdToUse,
|
||||
insuranceSiteKey: "UNITED_SCO",
|
||||
claimId: createdClaim.id,
|
||||
claimFiles: claimFilesMeta,
|
||||
@@ -1364,24 +1285,7 @@ export function ClaimForm({
|
||||
return;
|
||||
}
|
||||
|
||||
let appointmentIdToUse = appointmentId;
|
||||
if (appointmentIdToUse == null) {
|
||||
const created = await onHandleAppointmentSubmit({
|
||||
patientId,
|
||||
date: serviceDate,
|
||||
staffId: appointmentStaffId ?? staff?.id ?? 1,
|
||||
title: serviceDate,
|
||||
startTime: "09:00",
|
||||
endTime: "09:30",
|
||||
type: "recall",
|
||||
status: "scheduled",
|
||||
});
|
||||
if (typeof created === "number" && created > 0) {
|
||||
appointmentIdToUse = created;
|
||||
} else if (created && typeof (created as any).id === "number") {
|
||||
appointmentIdToUse = (created as any).id;
|
||||
}
|
||||
}
|
||||
const appointmentIdToUse = appointmentId;
|
||||
|
||||
const { uploadedFiles, insuranceSiteKey, npiProvider, ...formToCreateClaim } = f;
|
||||
|
||||
@@ -1401,7 +1305,7 @@ export function ClaimForm({
|
||||
staffId: appointmentStaffId ?? Number(staff?.id),
|
||||
patientId,
|
||||
insuranceProvider: "Tufts SCO",
|
||||
appointmentId: appointmentIdToUse!,
|
||||
appointmentId: appointmentIdToUse,
|
||||
claimFiles: claimFilesMeta,
|
||||
...(selectedNpiProviderId ? { npiProviderId: selectedNpiProviderId } : {}),
|
||||
});
|
||||
@@ -1420,7 +1324,7 @@ export function ClaimForm({
|
||||
staffId: appointmentStaffId ?? Number(staff?.id),
|
||||
patientId,
|
||||
insuranceProvider: "Tufts SCO",
|
||||
appointmentId: appointmentIdToUse!,
|
||||
appointmentId: appointmentIdToUse,
|
||||
insuranceSiteKey: "TuftsSCO",
|
||||
claimId: createdClaim.id,
|
||||
claimFiles: claimFilesMeta,
|
||||
@@ -1650,26 +1554,7 @@ export function ClaimForm({
|
||||
return;
|
||||
}
|
||||
|
||||
let appointmentIdToUse = appointmentId;
|
||||
|
||||
if (appointmentIdToUse == null) {
|
||||
const appointmentData = {
|
||||
patientId: patientId,
|
||||
date: serviceDate,
|
||||
staffId: appointmentStaffId ?? staff?.id ?? 1,
|
||||
title: serviceDate,
|
||||
startTime: "09:00",
|
||||
endTime: "09:30",
|
||||
type: "recall",
|
||||
status: "scheduled",
|
||||
};
|
||||
const created = await onHandleAppointmentSubmit(appointmentData);
|
||||
if (typeof created === "number" && created > 0) {
|
||||
appointmentIdToUse = created;
|
||||
} else if (created && typeof (created as any).id === "number") {
|
||||
appointmentIdToUse = (created as any).id;
|
||||
}
|
||||
}
|
||||
const appointmentIdToUse = appointmentId;
|
||||
|
||||
const { uploadedFiles, insuranceSiteKey, npiProvider, ...formToSave } = form;
|
||||
|
||||
@@ -1689,7 +1574,7 @@ export function ClaimForm({
|
||||
staffId: appointmentStaffId ?? Number(staff?.id),
|
||||
patientId: patientId,
|
||||
insuranceProvider: "MassHealth",
|
||||
appointmentId: appointmentIdToUse!,
|
||||
appointmentId: appointmentIdToUse,
|
||||
claimFiles: claimFilesMeta,
|
||||
...(selectedNpiProviderId ? { npiProviderId: selectedNpiProviderId } : {}),
|
||||
isDraft: true,
|
||||
@@ -1806,24 +1691,7 @@ export function ClaimForm({
|
||||
return;
|
||||
}
|
||||
|
||||
let appointmentIdToUse = appointmentId;
|
||||
if (appointmentIdToUse == null) {
|
||||
const created = await onHandleAppointmentSubmit({
|
||||
patientId: patientId,
|
||||
date: serviceDate,
|
||||
staffId: appointmentStaffId ?? staff?.id ?? 1,
|
||||
title: serviceDate,
|
||||
startTime: "09:00",
|
||||
endTime: "09:30",
|
||||
type: "recall",
|
||||
status: "scheduled",
|
||||
});
|
||||
if (typeof created === "number" && created > 0) {
|
||||
appointmentIdToUse = created;
|
||||
} else if (created && typeof (created as any).id === "number") {
|
||||
appointmentIdToUse = (created as any).id;
|
||||
}
|
||||
}
|
||||
const appointmentIdToUse = appointmentId;
|
||||
|
||||
const { uploadedFiles, insuranceSiteKey, npiProvider, ...formToCreateClaim } = form;
|
||||
|
||||
@@ -1842,7 +1710,7 @@ export function ClaimForm({
|
||||
staffId: appointmentStaffId ?? Number(staff?.id),
|
||||
patientId: patientId,
|
||||
insuranceProvider: patient?.insuranceProvider || "MassHealth",
|
||||
appointmentId: appointmentIdToUse!,
|
||||
appointmentId: appointmentIdToUse,
|
||||
claimFiles: claimFilesMeta,
|
||||
...(selectedNpiProviderId ? { npiProviderId: selectedNpiProviderId } : {}),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user