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,
|
ClaimFormData,
|
||||||
ClaimPreAuthData,
|
ClaimPreAuthData,
|
||||||
InputServiceLine,
|
InputServiceLine,
|
||||||
InsertAppointment,
|
|
||||||
MissingTeethStatus,
|
MissingTeethStatus,
|
||||||
NpiProvider,
|
NpiProvider,
|
||||||
Patient,
|
Patient,
|
||||||
Staff,
|
Staff,
|
||||||
UpdateAppointment,
|
|
||||||
UpdatePatient,
|
UpdatePatient,
|
||||||
} from "@repo/db/types";
|
} from "@repo/db/types";
|
||||||
import { Decimal } from "decimal.js";
|
import { Decimal } from "decimal.js";
|
||||||
@@ -89,9 +87,6 @@ interface ClaimFormProps {
|
|||||||
/** When true: form saves to AppointmentProcedure (Select Procedures flow), shows only Save button */
|
/** When true: form saves to AppointmentProcedure (Select Procedures flow), shows only Save button */
|
||||||
proceduresOnly?: boolean;
|
proceduresOnly?: boolean;
|
||||||
onSubmit: (data: ClaimFormData) => Promise<Claim>;
|
onSubmit: (data: ClaimFormData) => Promise<Claim>;
|
||||||
onHandleAppointmentSubmit: (
|
|
||||||
appointmentData: InsertAppointment | UpdateAppointment,
|
|
||||||
) => Promise<number | { id: number }>;
|
|
||||||
onHandleUpdatePatient: (patient: UpdatePatient & { id: number }) => void;
|
onHandleUpdatePatient: (patient: UpdatePatient & { id: number }) => void;
|
||||||
onHandleForMHSeleniumClaim: (data: ClaimFormData) => void;
|
onHandleForMHSeleniumClaim: (data: ClaimFormData) => void;
|
||||||
onHandleForMHSeleniumClaimPreAuth: (data: ClaimPreAuthData) => void;
|
onHandleForMHSeleniumClaimPreAuth: (data: ClaimPreAuthData) => void;
|
||||||
@@ -114,7 +109,6 @@ export function ClaimForm({
|
|||||||
initialTab,
|
initialTab,
|
||||||
autoSubmitPreauth,
|
autoSubmitPreauth,
|
||||||
proceduresOnly = false,
|
proceduresOnly = false,
|
||||||
onHandleAppointmentSubmit,
|
|
||||||
onHandleUpdatePatient,
|
onHandleUpdatePatient,
|
||||||
onHandleForMHSeleniumClaim,
|
onHandleForMHSeleniumClaim,
|
||||||
onHandleForMHSeleniumClaimPreAuth,
|
onHandleForMHSeleniumClaimPreAuth,
|
||||||
@@ -952,28 +946,7 @@ export function ClaimForm({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1. Create or update appointment
|
const appointmentIdToUse = appointmentId;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. Create Claim(if not)
|
// 3. Create Claim(if not)
|
||||||
// Filter out empty service lines (empty procedureCode)
|
// Filter out empty service lines (empty procedureCode)
|
||||||
@@ -999,7 +972,7 @@ export function ClaimForm({
|
|||||||
staffId: appointmentStaffId ?? Number(staff?.id),
|
staffId: appointmentStaffId ?? Number(staff?.id),
|
||||||
patientId: patientId,
|
patientId: patientId,
|
||||||
insuranceProvider: "MassHealth",
|
insuranceProvider: "MassHealth",
|
||||||
appointmentId: appointmentIdToUse!,
|
appointmentId: appointmentIdToUse,
|
||||||
claimFiles: claimFilesMeta,
|
claimFiles: claimFilesMeta,
|
||||||
...(selectedNpiProviderId ? { npiProviderId: selectedNpiProviderId } : {}),
|
...(selectedNpiProviderId ? { npiProviderId: selectedNpiProviderId } : {}),
|
||||||
});
|
});
|
||||||
@@ -1013,7 +986,7 @@ export function ClaimForm({
|
|||||||
npiProvider: f.npiProvider,
|
npiProvider: f.npiProvider,
|
||||||
patientId: patientId,
|
patientId: patientId,
|
||||||
insuranceProvider: "Mass Health",
|
insuranceProvider: "Mass Health",
|
||||||
appointmentId: appointmentIdToUse!,
|
appointmentId: appointmentIdToUse,
|
||||||
insuranceSiteKey: "MH",
|
insuranceSiteKey: "MH",
|
||||||
claimId: createdClaim.id,
|
claimId: createdClaim.id,
|
||||||
});
|
});
|
||||||
@@ -1112,25 +1085,7 @@ export function ClaimForm({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create appointment if needed
|
const appointmentIdToUse = appointmentId;
|
||||||
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 { uploadedFiles, insuranceSiteKey, npiProvider, ...formToCreateClaim } = f;
|
const { uploadedFiles, insuranceSiteKey, npiProvider, ...formToCreateClaim } = f;
|
||||||
const claimFilesMeta: ClaimFileMeta[] = (uploadedFiles || []).map((file) => ({
|
const claimFilesMeta: ClaimFileMeta[] = (uploadedFiles || []).map((file) => ({
|
||||||
@@ -1149,7 +1104,7 @@ export function ClaimForm({
|
|||||||
staffId: appointmentStaffId ?? Number(staff?.id),
|
staffId: appointmentStaffId ?? Number(staff?.id),
|
||||||
patientId,
|
patientId,
|
||||||
insuranceProvider: "CCA",
|
insuranceProvider: "CCA",
|
||||||
appointmentId: appointmentIdToUse!,
|
appointmentId: appointmentIdToUse,
|
||||||
claimFiles: claimFilesMeta,
|
claimFiles: claimFilesMeta,
|
||||||
...(selectedNpiProviderId ? { npiProviderId: selectedNpiProviderId } : {}),
|
...(selectedNpiProviderId ? { npiProviderId: selectedNpiProviderId } : {}),
|
||||||
});
|
});
|
||||||
@@ -1161,7 +1116,7 @@ export function ClaimForm({
|
|||||||
staffId: appointmentStaffId ?? Number(staff?.id),
|
staffId: appointmentStaffId ?? Number(staff?.id),
|
||||||
patientId,
|
patientId,
|
||||||
insuranceProvider: "CCA",
|
insuranceProvider: "CCA",
|
||||||
appointmentId: appointmentIdToUse!,
|
appointmentId: appointmentIdToUse,
|
||||||
insuranceSiteKey: "CCA",
|
insuranceSiteKey: "CCA",
|
||||||
claimId: createdClaim.id,
|
claimId: createdClaim.id,
|
||||||
});
|
});
|
||||||
@@ -1197,24 +1152,7 @@ export function ClaimForm({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let appointmentIdToUse = appointmentId;
|
const 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 { uploadedFiles, insuranceSiteKey, npiProvider, ...formToCreateClaim } = f;
|
const { uploadedFiles, insuranceSiteKey, npiProvider, ...formToCreateClaim } = f;
|
||||||
|
|
||||||
@@ -1233,7 +1171,7 @@ export function ClaimForm({
|
|||||||
staffId: appointmentStaffId ?? Number(staff?.id),
|
staffId: appointmentStaffId ?? Number(staff?.id),
|
||||||
patientId,
|
patientId,
|
||||||
insuranceProvider: "Delta Dental MA",
|
insuranceProvider: "Delta Dental MA",
|
||||||
appointmentId: appointmentIdToUse!,
|
appointmentId: appointmentIdToUse,
|
||||||
claimFiles: claimFilesMeta,
|
claimFiles: claimFilesMeta,
|
||||||
...(selectedNpiProviderId ? { npiProviderId: selectedNpiProviderId } : {}),
|
...(selectedNpiProviderId ? { npiProviderId: selectedNpiProviderId } : {}),
|
||||||
});
|
});
|
||||||
@@ -1244,7 +1182,7 @@ export function ClaimForm({
|
|||||||
staffId: appointmentStaffId ?? Number(staff?.id),
|
staffId: appointmentStaffId ?? Number(staff?.id),
|
||||||
patientId,
|
patientId,
|
||||||
insuranceProvider: "Delta Dental MA",
|
insuranceProvider: "Delta Dental MA",
|
||||||
appointmentId: appointmentIdToUse!,
|
appointmentId: appointmentIdToUse,
|
||||||
insuranceSiteKey: "DDMA",
|
insuranceSiteKey: "DDMA",
|
||||||
claimId: createdClaim.id,
|
claimId: createdClaim.id,
|
||||||
claimFiles: claimFilesMeta,
|
claimFiles: claimFilesMeta,
|
||||||
@@ -1281,24 +1219,7 @@ export function ClaimForm({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let appointmentIdToUse = appointmentId;
|
const 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 { uploadedFiles, insuranceSiteKey, npiProvider, ...formToCreateClaim } = f;
|
const { uploadedFiles, insuranceSiteKey, npiProvider, ...formToCreateClaim } = f;
|
||||||
|
|
||||||
@@ -1316,7 +1237,7 @@ export function ClaimForm({
|
|||||||
staffId: appointmentStaffId ?? Number(staff?.id),
|
staffId: appointmentStaffId ?? Number(staff?.id),
|
||||||
patientId,
|
patientId,
|
||||||
insuranceProvider: "United/DentalHub",
|
insuranceProvider: "United/DentalHub",
|
||||||
appointmentId: appointmentIdToUse!,
|
appointmentId: appointmentIdToUse,
|
||||||
claimFiles: claimFilesMeta,
|
claimFiles: claimFilesMeta,
|
||||||
...(selectedNpiProviderId ? { npiProviderId: selectedNpiProviderId } : {}),
|
...(selectedNpiProviderId ? { npiProviderId: selectedNpiProviderId } : {}),
|
||||||
});
|
});
|
||||||
@@ -1327,7 +1248,7 @@ export function ClaimForm({
|
|||||||
staffId: appointmentStaffId ?? Number(staff?.id),
|
staffId: appointmentStaffId ?? Number(staff?.id),
|
||||||
patientId,
|
patientId,
|
||||||
insuranceProvider: "United/DentalHub",
|
insuranceProvider: "United/DentalHub",
|
||||||
appointmentId: appointmentIdToUse!,
|
appointmentId: appointmentIdToUse,
|
||||||
insuranceSiteKey: "UNITED_SCO",
|
insuranceSiteKey: "UNITED_SCO",
|
||||||
claimId: createdClaim.id,
|
claimId: createdClaim.id,
|
||||||
claimFiles: claimFilesMeta,
|
claimFiles: claimFilesMeta,
|
||||||
@@ -1364,24 +1285,7 @@ export function ClaimForm({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let appointmentIdToUse = appointmentId;
|
const 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 { uploadedFiles, insuranceSiteKey, npiProvider, ...formToCreateClaim } = f;
|
const { uploadedFiles, insuranceSiteKey, npiProvider, ...formToCreateClaim } = f;
|
||||||
|
|
||||||
@@ -1401,7 +1305,7 @@ export function ClaimForm({
|
|||||||
staffId: appointmentStaffId ?? Number(staff?.id),
|
staffId: appointmentStaffId ?? Number(staff?.id),
|
||||||
patientId,
|
patientId,
|
||||||
insuranceProvider: "Tufts SCO",
|
insuranceProvider: "Tufts SCO",
|
||||||
appointmentId: appointmentIdToUse!,
|
appointmentId: appointmentIdToUse,
|
||||||
claimFiles: claimFilesMeta,
|
claimFiles: claimFilesMeta,
|
||||||
...(selectedNpiProviderId ? { npiProviderId: selectedNpiProviderId } : {}),
|
...(selectedNpiProviderId ? { npiProviderId: selectedNpiProviderId } : {}),
|
||||||
});
|
});
|
||||||
@@ -1420,7 +1324,7 @@ export function ClaimForm({
|
|||||||
staffId: appointmentStaffId ?? Number(staff?.id),
|
staffId: appointmentStaffId ?? Number(staff?.id),
|
||||||
patientId,
|
patientId,
|
||||||
insuranceProvider: "Tufts SCO",
|
insuranceProvider: "Tufts SCO",
|
||||||
appointmentId: appointmentIdToUse!,
|
appointmentId: appointmentIdToUse,
|
||||||
insuranceSiteKey: "TuftsSCO",
|
insuranceSiteKey: "TuftsSCO",
|
||||||
claimId: createdClaim.id,
|
claimId: createdClaim.id,
|
||||||
claimFiles: claimFilesMeta,
|
claimFiles: claimFilesMeta,
|
||||||
@@ -1650,26 +1554,7 @@ export function ClaimForm({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let appointmentIdToUse = appointmentId;
|
const 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 { uploadedFiles, insuranceSiteKey, npiProvider, ...formToSave } = form;
|
const { uploadedFiles, insuranceSiteKey, npiProvider, ...formToSave } = form;
|
||||||
|
|
||||||
@@ -1689,7 +1574,7 @@ export function ClaimForm({
|
|||||||
staffId: appointmentStaffId ?? Number(staff?.id),
|
staffId: appointmentStaffId ?? Number(staff?.id),
|
||||||
patientId: patientId,
|
patientId: patientId,
|
||||||
insuranceProvider: "MassHealth",
|
insuranceProvider: "MassHealth",
|
||||||
appointmentId: appointmentIdToUse!,
|
appointmentId: appointmentIdToUse,
|
||||||
claimFiles: claimFilesMeta,
|
claimFiles: claimFilesMeta,
|
||||||
...(selectedNpiProviderId ? { npiProviderId: selectedNpiProviderId } : {}),
|
...(selectedNpiProviderId ? { npiProviderId: selectedNpiProviderId } : {}),
|
||||||
isDraft: true,
|
isDraft: true,
|
||||||
@@ -1806,24 +1691,7 @@ export function ClaimForm({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let appointmentIdToUse = appointmentId;
|
const 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 { uploadedFiles, insuranceSiteKey, npiProvider, ...formToCreateClaim } = form;
|
const { uploadedFiles, insuranceSiteKey, npiProvider, ...formToCreateClaim } = form;
|
||||||
|
|
||||||
@@ -1842,7 +1710,7 @@ export function ClaimForm({
|
|||||||
staffId: appointmentStaffId ?? Number(staff?.id),
|
staffId: appointmentStaffId ?? Number(staff?.id),
|
||||||
patientId: patientId,
|
patientId: patientId,
|
||||||
insuranceProvider: patient?.insuranceProvider || "MassHealth",
|
insuranceProvider: patient?.insuranceProvider || "MassHealth",
|
||||||
appointmentId: appointmentIdToUse!,
|
appointmentId: appointmentIdToUse,
|
||||||
claimFiles: claimFilesMeta,
|
claimFiles: claimFilesMeta,
|
||||||
...(selectedNpiProviderId ? { npiProviderId: selectedNpiProviderId } : {}),
|
...(selectedNpiProviderId ? { npiProviderId: selectedNpiProviderId } : {}),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -26,8 +26,6 @@ import { QK_APPOINTMENTS_BASE } from "@/pages/appointments-page";
|
|||||||
import ClaimsOfPatientModal from "@/components/claims/claims-of-patient-table";
|
import ClaimsOfPatientModal from "@/components/claims/claims-of-patient-table";
|
||||||
import {
|
import {
|
||||||
Claim,
|
Claim,
|
||||||
InsertAppointment,
|
|
||||||
UpdateAppointment,
|
|
||||||
UpdatePatient,
|
UpdatePatient,
|
||||||
} from "@repo/db/types";
|
} from "@repo/db/types";
|
||||||
import ClaimDocumentsUploadMultiple from "@/components/claims/claim-document-upload-modal";
|
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
|
// create claim mutation
|
||||||
const createClaimMutation = useMutation({
|
const createClaimMutation = useMutation({
|
||||||
mutationFn: async (claimData: any) => {
|
mutationFn: async (claimData: any) => {
|
||||||
@@ -347,38 +315,6 @@ export default function ClaimsPage() {
|
|||||||
};
|
};
|
||||||
}, [location, search, newPatient]);
|
}, [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)
|
// 2. Update Patient ( for insuranceId and Insurance Provider)
|
||||||
const handleUpdatePatient = (patient: UpdatePatient & { id?: number }) => {
|
const handleUpdatePatient = (patient: UpdatePatient & { id?: number }) => {
|
||||||
if (patient) {
|
if (patient) {
|
||||||
@@ -1097,7 +1033,6 @@ export default function ClaimsPage() {
|
|||||||
proceduresOnly={mode === "procedures"}
|
proceduresOnly={mode === "procedures"}
|
||||||
onClose={closeClaim}
|
onClose={closeClaim}
|
||||||
onSubmit={handleClaimSubmit}
|
onSubmit={handleClaimSubmit}
|
||||||
onHandleAppointmentSubmit={handleAppointmentSubmit}
|
|
||||||
onHandleUpdatePatient={handleUpdatePatient}
|
onHandleUpdatePatient={handleUpdatePatient}
|
||||||
onHandleForMHSeleniumClaim={handleMHClaimSubmitSelenium}
|
onHandleForMHSeleniumClaim={handleMHClaimSubmitSelenium}
|
||||||
onHandleForMHSeleniumClaimPreAuth={handleMHClaimPreAuthSubmitSelenium}
|
onHandleForMHSeleniumClaimPreAuth={handleMHClaimPreAuthSubmitSelenium}
|
||||||
|
|||||||
7
packages/db/types/claim-types.d.ts
vendored
7
packages/db/types/claim-types.d.ts
vendored
@@ -79,11 +79,16 @@ export type ClaimWithServiceLines = Claim & {
|
|||||||
}[];
|
}[];
|
||||||
staff?: Staff | null;
|
staff?: Staff | null;
|
||||||
claimFiles?: ClaimFileMeta[] | null;
|
claimFiles?: ClaimFileMeta[] | null;
|
||||||
|
npiProvider?: {
|
||||||
|
id: number;
|
||||||
|
npiNumber: string;
|
||||||
|
providerName: string;
|
||||||
|
} | null;
|
||||||
};
|
};
|
||||||
export type MissingTeethStatus = "No_missing" | "endentulous" | "Yes_missing";
|
export type MissingTeethStatus = "No_missing" | "endentulous" | "Yes_missing";
|
||||||
export interface ClaimFormData {
|
export interface ClaimFormData {
|
||||||
patientId: number;
|
patientId: number;
|
||||||
appointmentId: number;
|
appointmentId?: number | null;
|
||||||
userId: number;
|
userId: number;
|
||||||
staffId: number;
|
staffId: number;
|
||||||
patientName: string;
|
patientName: string;
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ export type MissingTeethStatus = "No_missing" | "endentulous" | "Yes_missing";
|
|||||||
|
|
||||||
export interface ClaimFormData {
|
export interface ClaimFormData {
|
||||||
patientId: number;
|
patientId: number;
|
||||||
appointmentId: number;
|
appointmentId?: number | null;
|
||||||
userId: number;
|
userId: number;
|
||||||
staffId: number;
|
staffId: number;
|
||||||
patientName: string;
|
patientName: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user