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:
@@ -26,8 +26,6 @@ import { QK_APPOINTMENTS_BASE } from "@/pages/appointments-page";
|
||||
import ClaimsOfPatientModal from "@/components/claims/claims-of-patient-table";
|
||||
import {
|
||||
Claim,
|
||||
InsertAppointment,
|
||||
UpdateAppointment,
|
||||
UpdatePatient,
|
||||
} from "@repo/db/types";
|
||||
import ClaimDocumentsUploadMultiple from "@/components/claims/claim-document-upload-modal";
|
||||
@@ -112,36 +110,6 @@ export default function ClaimsPage() {
|
||||
},
|
||||
});
|
||||
|
||||
// Create/upsert appointment mutation
|
||||
const createAppointmentMutation = useMutation({
|
||||
mutationFn: async (appointment: InsertAppointment) => {
|
||||
const res = await apiRequest(
|
||||
"POST",
|
||||
"/api/appointments/upsert",
|
||||
appointment
|
||||
);
|
||||
const data = await res.json();
|
||||
if (!res.ok) {
|
||||
throw new Error(data?.message || "Failed to create appointment");
|
||||
}
|
||||
return data;
|
||||
},
|
||||
onSuccess: (appointment) => {
|
||||
queryClient.invalidateQueries({ queryKey: QK_APPOINTMENTS_BASE });
|
||||
toast({
|
||||
title: "Appointment Scheduled",
|
||||
description: appointment.message || "Appointment created successfully.",
|
||||
});
|
||||
},
|
||||
onError: (error: Error) => {
|
||||
toast({
|
||||
title: "Error",
|
||||
description: `Failed to create appointment: ${error.message}`,
|
||||
variant: "destructive",
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
// create claim mutation
|
||||
const createClaimMutation = useMutation({
|
||||
mutationFn: async (claimData: any) => {
|
||||
@@ -347,38 +315,6 @@ export default function ClaimsPage() {
|
||||
};
|
||||
}, [location, search, newPatient]);
|
||||
|
||||
// 1. upsert appointment.
|
||||
const handleAppointmentSubmit = async (
|
||||
appointmentData: InsertAppointment | UpdateAppointment
|
||||
): Promise<number> => {
|
||||
return new Promise<number>((resolve, reject) => {
|
||||
createAppointmentMutation.mutate(
|
||||
{
|
||||
date: appointmentData.date,
|
||||
startTime: "09:00",
|
||||
endTime: "09:30",
|
||||
staffId: appointmentData.staffId,
|
||||
patientId: appointmentData.patientId,
|
||||
userId: user?.id,
|
||||
title: "Scheduled Appointment",
|
||||
type: "checkup",
|
||||
},
|
||||
{
|
||||
onSuccess: (appointment) => {
|
||||
if (!appointment?.id) {
|
||||
reject(new Error("Appointment was created but returned no ID"));
|
||||
return;
|
||||
}
|
||||
resolve(appointment.id);
|
||||
},
|
||||
onError: (error) => {
|
||||
reject(error);
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
// 2. Update Patient ( for insuranceId and Insurance Provider)
|
||||
const handleUpdatePatient = (patient: UpdatePatient & { id?: number }) => {
|
||||
if (patient) {
|
||||
@@ -1097,7 +1033,6 @@ export default function ClaimsPage() {
|
||||
proceduresOnly={mode === "procedures"}
|
||||
onClose={closeClaim}
|
||||
onSubmit={handleClaimSubmit}
|
||||
onHandleAppointmentSubmit={handleAppointmentSubmit}
|
||||
onHandleUpdatePatient={handleUpdatePatient}
|
||||
onHandleForMHSeleniumClaim={handleMHClaimSubmitSelenium}
|
||||
onHandleForMHSeleniumClaimPreAuth={handleMHClaimPreAuthSubmitSelenium}
|
||||
|
||||
Reference in New Issue
Block a user