fix: fix remote browser socket connection and related updates
This commit is contained in:
@@ -7,6 +7,12 @@ import {
|
||||
} from "@repo/db/types";
|
||||
import { prisma as db } from "@repo/db/client";
|
||||
|
||||
export interface AppointmentFileMeta {
|
||||
filename: string;
|
||||
mimeType?: string | null;
|
||||
filePath?: string | null;
|
||||
}
|
||||
|
||||
export interface IAppointmentProceduresStorage {
|
||||
getByAppointmentId(appointmentId: number): Promise<AppointmentProcedure[]>;
|
||||
getPrefillDataByAppointmentId(appointmentId: number): Promise<{
|
||||
@@ -14,6 +20,7 @@ export interface IAppointmentProceduresStorage {
|
||||
patient: Patient;
|
||||
procedures: AppointmentProcedure[];
|
||||
npiProviderId: number | null;
|
||||
appointmentFiles: AppointmentFileMeta[];
|
||||
} | null>;
|
||||
saveForAppointment(params: {
|
||||
appointmentId: number;
|
||||
@@ -25,6 +32,7 @@ export interface IAppointmentProceduresStorage {
|
||||
toothNumber?: string | null;
|
||||
toothSurface?: string | null;
|
||||
}>;
|
||||
attachments?: AppointmentFileMeta[];
|
||||
}): Promise<number>;
|
||||
|
||||
createProcedure(
|
||||
@@ -37,6 +45,7 @@ export interface IAppointmentProceduresStorage {
|
||||
): Promise<AppointmentProcedure>;
|
||||
deleteProcedure(id: number): Promise<void>;
|
||||
clearByAppointmentId(appointmentId: number): Promise<void>;
|
||||
getAppointmentFiles(appointmentId: number): Promise<AppointmentFileMeta[]>;
|
||||
getAppointmentIdsWithProcedures(ids: number[]): Promise<Set<number>>;
|
||||
}
|
||||
|
||||
@@ -58,6 +67,9 @@ export const appointmentProceduresStorage: IAppointmentProceduresStorage = {
|
||||
procedures: {
|
||||
orderBy: { createdAt: "asc" },
|
||||
},
|
||||
files: {
|
||||
orderBy: { id: "asc" },
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -72,11 +84,28 @@ export const appointmentProceduresStorage: IAppointmentProceduresStorage = {
|
||||
patient: appointment.patient,
|
||||
procedures: appointment.procedures,
|
||||
npiProviderId,
|
||||
appointmentFiles: (appointment.files as any[]).map((f) => ({
|
||||
id: f.id,
|
||||
filename: f.filename,
|
||||
mimeType: f.mimeType,
|
||||
filePath: f.filePath,
|
||||
})),
|
||||
};
|
||||
},
|
||||
|
||||
async saveForAppointment({ appointmentId, patientId, npiProviderId, procedures }) {
|
||||
async saveForAppointment({ appointmentId, patientId, npiProviderId, procedures, attachments }) {
|
||||
await db.appointmentProcedure.deleteMany({ where: { appointmentId } });
|
||||
if (attachments?.length) {
|
||||
await db.appointmentFile.deleteMany({ where: { appointmentId } });
|
||||
await db.appointmentFile.createMany({
|
||||
data: attachments.map((a) => ({
|
||||
appointmentId,
|
||||
filename: a.filename,
|
||||
mimeType: a.mimeType ?? null,
|
||||
filePath: a.filePath ?? null,
|
||||
})),
|
||||
});
|
||||
}
|
||||
if (!procedures.length) return 0;
|
||||
const result = await db.appointmentProcedure.createMany({
|
||||
data: procedures.map((p) => ({
|
||||
@@ -139,6 +168,19 @@ export const appointmentProceduresStorage: IAppointmentProceduresStorage = {
|
||||
select: { appointmentId: true },
|
||||
distinct: ["appointmentId"],
|
||||
});
|
||||
return new Set(rows.map((r) => r.appointmentId));
|
||||
return new Set(rows.map((r: any) => r.appointmentId));
|
||||
},
|
||||
|
||||
async getAppointmentFiles(appointmentId: number): Promise<AppointmentFileMeta[]> {
|
||||
const rows = await db.appointmentFile.findMany({
|
||||
where: { appointmentId },
|
||||
orderBy: { id: "asc" },
|
||||
});
|
||||
return rows.map((f: any) => ({
|
||||
id: f.id,
|
||||
filename: f.filename,
|
||||
mimeType: f.mimeType,
|
||||
filePath: f.filePath,
|
||||
}));
|
||||
},
|
||||
};
|
||||
|
||||
@@ -60,7 +60,7 @@ export const claimsStorage: IStorage = {
|
||||
return db.claim.findFirst({
|
||||
where: {
|
||||
appointmentId,
|
||||
status: { notIn: ["CANCELLED", "VOID"] },
|
||||
status: { notIn: ["CANCELLED"] },
|
||||
},
|
||||
orderBy: { createdAt: "desc" },
|
||||
include: { serviceLines: true, claimFiles: true, staff: true },
|
||||
|
||||
Reference in New Issue
Block a user