feat: appointment type inference, procedure codes on cards, claim attachment fixes
- Add appointment type categories matching insurance claim form (recall, filling, pedo, dentures, implant, endo, crown, perio, extraction, ortho, consultation, emergency, other) - Auto-infer appointment type from CDT codes with priority rules (endo > implant > crown > ...) - typeLocked flag prevents auto-overwrite when user manually sets type - Show appointment type label and procedure codes on schedule cards - Background sync on /day route retroactively fixes stale appointment types - Fix PUT /api/claims/:id to save claimFiles (previously silently dropped) - Auto-link AppointmentFile records to ClaimFile when claim is created or updated - Fix D5750 (denture reline) CDT range to map correctly to dentures category - Fix typeLocked Zod rejection in appointment update route Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -47,6 +47,7 @@ export interface IAppointmentProceduresStorage {
|
||||
clearByAppointmentId(appointmentId: number): Promise<void>;
|
||||
getAppointmentFiles(appointmentId: number): Promise<AppointmentFileMeta[]>;
|
||||
getAppointmentIdsWithProcedures(ids: number[]): Promise<Set<number>>;
|
||||
getProcedureCodesByAppointmentIds(ids: number[]): Promise<Map<number, string[]>>;
|
||||
}
|
||||
|
||||
export const appointmentProceduresStorage: IAppointmentProceduresStorage = {
|
||||
@@ -171,6 +172,23 @@ export const appointmentProceduresStorage: IAppointmentProceduresStorage = {
|
||||
return new Set(rows.map((r: any) => r.appointmentId));
|
||||
},
|
||||
|
||||
async getProcedureCodesByAppointmentIds(ids: number[]): Promise<Map<number, string[]>> {
|
||||
if (!ids.length) return new Map();
|
||||
const rows = await db.appointmentProcedure.findMany({
|
||||
where: { appointmentId: { in: ids } },
|
||||
select: { appointmentId: true, procedureCode: true },
|
||||
orderBy: { createdAt: "asc" },
|
||||
});
|
||||
const map = new Map<number, string[]>();
|
||||
for (const r of rows as any[]) {
|
||||
if (!r.procedureCode) continue;
|
||||
const list = map.get(r.appointmentId) ?? [];
|
||||
list.push(r.procedureCode);
|
||||
map.set(r.appointmentId, list);
|
||||
}
|
||||
return map;
|
||||
},
|
||||
|
||||
async getAppointmentFiles(appointmentId: number): Promise<AppointmentFileMeta[]> {
|
||||
const rows = await db.appointmentFile.findMany({
|
||||
where: { appointmentId },
|
||||
|
||||
Reference in New Issue
Block a user