types updated

This commit is contained in:
2025-08-10 18:21:38 +05:30
parent 31ed4cd1da
commit 4b1ee273e4
44 changed files with 2049 additions and 1263 deletions

View File

@@ -135,7 +135,7 @@ model ServiceLine {
oralCavityArea String?
toothNumber String?
toothSurface String?
billedAmount Float
totalBilled Decimal @db.Decimal(10, 2)
totalPaid Decimal @default(0.00) @db.Decimal(10, 2)
totalAdjusted Decimal @default(0.00) @db.Decimal(10, 2)
totalDue Decimal @default(0.00) @db.Decimal(10, 2)
@@ -212,9 +212,9 @@ model Payment {
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
claim Claim @relation(fields: [claimId], references: [id], onDelete: Cascade)
patient Patient @relation(fields: [patientId], references: [id], onDelete: Cascade)
updatedBy User? @relation("PaymentUpdatedBy", fields: [updatedById], references: [id])
claim Claim @relation(fields: [claimId], references: [id], onDelete: Cascade)
patient Patient @relation(fields: [patientId], references: [id], onDelete: Cascade)
updatedBy User? @relation("PaymentUpdatedBy", fields: [updatedById], references: [id])
serviceLineTransactions ServiceLineTransaction[]
@@index([id])

View File

@@ -0,0 +1,22 @@
import { AppointmentUncheckedCreateInputObjectSchema } from "@repo/db/usedSchemas";
import {z} from "zod";
export type Appointment = z.infer<typeof AppointmentUncheckedCreateInputObjectSchema>;
export const insertAppointmentSchema = (
AppointmentUncheckedCreateInputObjectSchema as unknown as z.ZodObject<any>
).omit({
id: true,
createdAt: true,
});
export type InsertAppointment = z.infer<typeof insertAppointmentSchema>;
export const updateAppointmentSchema = (
AppointmentUncheckedCreateInputObjectSchema as unknown as z.ZodObject<any>
)
.omit({
id: true,
createdAt: true,
})
.partial();
export type UpdateAppointment = z.infer<typeof updateAppointmentSchema>;

View File

@@ -0,0 +1,59 @@
import { ClaimStatusSchema, ClaimUncheckedCreateInputObjectSchema } from "@repo/db/usedSchemas";
import {z} from "zod";
import { Decimal } from "decimal.js";
import { Staff } from "@repo/db/types";
export const insertClaimSchema = (
ClaimUncheckedCreateInputObjectSchema as unknown as z.ZodObject<any>
).omit({
id: true,
createdAt: true,
updatedAt: true,
});
export type InsertClaim = z.infer<typeof insertClaimSchema>;
export const updateClaimSchema = (
ClaimUncheckedCreateInputObjectSchema as unknown as z.ZodObject<any>
)
.omit({
id: true,
createdAt: true,
updatedAt: true,
})
.partial();
export type UpdateClaim = z.infer<typeof updateClaimSchema>;
export type Claim = z.infer<typeof ClaimUncheckedCreateInputObjectSchema>;
export type ClaimStatus = z.infer<typeof ClaimStatusSchema>;
//used in claim-form
export interface InputServiceLine {
procedureCode: string;
procedureDate: string; // YYYY-MM-DD
oralCavityArea?: string;
toothNumber?: string;
toothSurface?: string;
totalBilled: Decimal;
totalPaid?: Decimal;
totalAdjusted?: Decimal;
}
// Claim model with embedded service lines
export type ClaimWithServiceLines = Claim & {
serviceLines: {
id: number;
claimId: number;
procedureCode: string;
procedureDate: Date;
oralCavityArea: string | null;
toothNumber: string | null;
toothSurface: string | null;
totalBilled: Decimal;
totalPaid: Decimal;
totalAdjusted: Decimal;
status: string;
}[];
staff?: Staff | null;
};

View File

@@ -1,2 +1,8 @@
export * from "./appointment-types";
export * from "./claim-types";
export * from "./insurance-types";
export * from "./patient-types";;
export * from "./payment-types";
export * from "./pdf-types";
export * from "./staff-types";
export * from "./user-types";

View File

@@ -0,0 +1,14 @@
import { InsuranceCredentialUncheckedCreateInputObjectSchema } from "@repo/db/usedSchemas";
import {z} from "zod";
export type InsuranceCredential = z.infer<
typeof InsuranceCredentialUncheckedCreateInputObjectSchema
>;
export const insertInsuranceCredentialSchema = (
InsuranceCredentialUncheckedCreateInputObjectSchema as unknown as z.ZodObject<any>
).omit({ id: true });
export type InsertInsuranceCredential = z.infer<
typeof insertInsuranceCredentialSchema
>;

View File

@@ -0,0 +1,24 @@
import { PatientUncheckedCreateInputObjectSchema } from "@repo/db/usedSchemas";
import {z} from "zod";
export type Patient = z.infer<typeof PatientUncheckedCreateInputObjectSchema>;
export const insertPatientSchema = (
PatientUncheckedCreateInputObjectSchema as unknown as z.ZodObject<any>
).omit({
id: true,
createdAt: true,
});
export type InsertPatient = z.infer<typeof insertPatientSchema>;
export const updatePatientSchema = (
PatientUncheckedCreateInputObjectSchema as unknown as z.ZodObject<any>
)
.omit({
id: true,
createdAt: true,
userId: true,
})
.partial();
export type UpdatePatient = z.infer<typeof updatePatientSchema>;

View File

@@ -91,38 +91,18 @@ export type PaymentWithExtras = Prisma.PaymentGetPayload<{
paymentMethod: string;
};
// Claim model with embedded service lines
export type Claim = z.infer<typeof ClaimUncheckedCreateInputObjectSchema>;
export type ClaimStatus = z.infer<typeof ClaimStatusSchema>;
export type Staff = z.infer<typeof StaffUncheckedCreateInputObjectSchema>;
export type ClaimWithServiceLines = Claim & {
serviceLines: {
id: number;
claimId: number;
procedureCode: string;
procedureDate: Date;
oralCavityArea: string | null;
toothNumber: string | null;
toothSurface: string | null;
billedAmount: number;
status: string;
}[];
staff: Staff | null;
};
export type NewTransactionPayload = {
paymentId: number;
amount: number;
method: PaymentMethod;
payerName?: string;
notes?: string;
receivedDate: Date;
status: PaymentStatus;
serviceLineTransactions: {
serviceLineId: number;
transactionId?: string;
paidAmount: number;
adjustedAmount: number;
adjustedAmount?: number;
method: PaymentMethod;
receivedDate: Date;
payerName?: string;
notes?: string;
}[];
};

View File

@@ -0,0 +1,12 @@
import { PdfCategorySchema, PdfFileUncheckedCreateInputObjectSchema, PdfGroupUncheckedCreateInputObjectSchema } from "@repo/db/usedSchemas";
import {z} from "zod";
export type PdfGroup = z.infer<typeof PdfGroupUncheckedCreateInputObjectSchema>;
export type PdfFile = z.infer<typeof PdfFileUncheckedCreateInputObjectSchema>;
export type PdfCategory = z.infer<typeof PdfCategorySchema>;
export interface ClaimPdfMetadata {
id: number;
filename: string;
uploadedAt: Date;
}

View File

@@ -0,0 +1,4 @@
import { StaffUncheckedCreateInputObjectSchema } from "@repo/db/usedSchemas";
import {z} from "zod";
export type Staff = z.infer<typeof StaffUncheckedCreateInputObjectSchema>;

View File

@@ -0,0 +1,36 @@
import { UserUncheckedCreateInputObjectSchema } from "@repo/db/usedSchemas";
import {z} from "zod";
export type User = z.infer<typeof UserUncheckedCreateInputObjectSchema>;
export const insertUserSchema = (
UserUncheckedCreateInputObjectSchema as unknown as z.ZodObject<any>
).pick({
username: true,
password: true,
});
export const loginSchema = (insertUserSchema as unknown as z.ZodObject<any>).extend({
rememberMe: z.boolean().optional(),
});
export const registerSchema = (insertUserSchema as unknown as z.ZodObject<any>)
.extend({
confirmPassword: z.string().min(6, {
message: "Password must be at least 6 characters long",
}),
agreeTerms: z.literal(true, {
errorMap: () => ({
message: "You must agree to the terms and conditions",
}),
}),
})
.refine((data: any) => data.password === data.confirmPassword, {
message: "Passwords don't match",
path: ["confirmPassword"],
});
export type InsertUser = z.infer<typeof insertUserSchema>;
export type LoginFormValues = z.infer<typeof loginSchema>;
export type RegisterFormValues = z.infer<typeof registerSchema>;