feat: Select Procedures flow, batch-column NPI provider fix, auto PDF save

- Add 'Select Procedures' right-click option on appointment page (separate from Claims/PreAuth)
- Select Procedures form saves CDT codes + NPI provider to AppointmentProcedure storage
- Remove Save button from insurance claim form; Claims/PreAuth opens for insurance submission only
- Claims/PreAuth auto-prefills from saved procedures including NPI provider
- Batch-column: procedures npiProviderId takes priority over stale claim npiProviderId
- Batch-column: auto-save PDF to patient Documents after successful submission (no socket needed)
- Add npiProviderId column to AppointmentProcedure table (prisma db push)
- Fix 'invalid db creation invocation': guard staffId, npiProviderId, procedureDate as Date object, totalBilled NaN guard
- Add full error logging to batch-column catch block

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Gitead
2026-04-27 00:25:24 -04:00
parent a279a3e7c1
commit 3e899376c3
838 changed files with 28488 additions and 773 deletions

View File

@@ -13,7 +13,19 @@ export interface IAppointmentProceduresStorage {
appointment: Appointment;
patient: Patient;
procedures: AppointmentProcedure[];
npiProviderId: number | null;
} | null>;
saveForAppointment(params: {
appointmentId: number;
patientId: number;
npiProviderId: number | null;
procedures: Array<{
procedureCode: string;
fee?: number | null;
toothNumber?: string | null;
toothSurface?: string | null;
}>;
}): Promise<number>;
createProcedure(
data: InsertAppointmentProcedure
@@ -52,13 +64,34 @@ export const appointmentProceduresStorage: IAppointmentProceduresStorage = {
return null;
}
const npiProviderId = appointment.procedures[0]?.npiProviderId ?? null;
return {
appointment,
patient: appointment.patient,
procedures: appointment.procedures,
npiProviderId,
};
},
async saveForAppointment({ appointmentId, patientId, npiProviderId, procedures }) {
await db.appointmentProcedure.deleteMany({ where: { appointmentId } });
if (!procedures.length) return 0;
const result = await db.appointmentProcedure.createMany({
data: procedures.map((p) => ({
appointmentId,
patientId,
npiProviderId: npiProviderId ?? null,
procedureCode: p.procedureCode,
fee: p.fee != null ? p.fee : null,
toothNumber: p.toothNumber || null,
toothSurface: p.toothSurface || null,
source: "MANUAL" as const,
})),
});
return result.count;
},
async createProcedure(
data: InsertAppointmentProcedure
): Promise<AppointmentProcedure> {

View File

@@ -22,6 +22,11 @@ export interface IStorage {
appointment: UpdateAppointment
): Promise<Appointment>;
deleteAppointment(id: number): Promise<void>;
getPatientAppointmentByDateAndStaff(
patientId: number,
date: Date,
staffId: number
): Promise<Appointment | undefined>;
getPatientAppointmentByDateTime(
patientId: number,
date: Date,
@@ -127,6 +132,19 @@ export const appointmentsStorage: IStorage = {
}
},
async getPatientAppointmentByDateAndStaff(
patientId: number,
date: Date,
staffId: number
): Promise<Appointment | undefined> {
return (
(await db.appointment.findFirst({
where: { patientId, date, staffId },
orderBy: { createdAt: "desc" },
})) ?? undefined
);
},
async getPatientAppointmentByDateTime(
patientId: number,
date: Date,