diff --git a/apps/Frontend/src/components/chart/lab-rx-modal.jsx b/apps/Frontend/src/components/chart/lab-rx-modal.jsx
index 91cd17a1..338e81cf 100644
--- a/apps/Frontend/src/components/chart/lab-rx-modal.jsx
+++ b/apps/Frontend/src/components/chart/lab-rx-modal.jsx
@@ -27,7 +27,17 @@ const EMPTY_TEMPLATE = {
name: "", labName: "", labPhone: "", labFax: "",
labAddress: "", labAccount: "", caseType: "", material: "", instructions: "Please make\nThank you!",
};
-const EMPTY_RX = { toothNumbers: "", shade: "", dueDate: "", doctorName: "", additionalNotes: "Please make\nThank you!" };
+const EMPTY_RX = { toothNumbers: "", shade: "", dueDate: "", doctorName: "", age: "", additionalNotes: "Please make\nThank you!" };
+
+const calcAge = (dob) => {
+ if (!dob) return "";
+ const birth = new Date(dob);
+ const today = new Date();
+ let age = today.getFullYear() - birth.getFullYear();
+ const m = today.getMonth() - birth.getMonth();
+ if (m < 0 || (m === 0 && today.getDate() < birth.getDate())) age--;
+ return String(age);
+};
const CASE_TYPES = ["Crown", "Bridge", "Veneer", "Inlay/Onlay", "Full Denture", "Partial Denture", "Night Guard", "Retainer", "Implant Crown", "Other"];
const MATERIALS = ["Zirconia", "PFM (Porcelain-Fused-to-Metal)", "E-Max", "Acrylic", "Cast Metal", "Composite", "PMMA", "Other"];
@@ -131,7 +141,7 @@ export function LabRxModal({ open, onClose, patient }) {
const openRx = (t) => {
if (renamingId !== null) return;
setRxTemplate(t);
- setRx({ ...EMPTY_RX, doctorName: providers[0]?.providerName ?? "" });
+ setRx({ ...EMPTY_RX, doctorName: providers[0]?.providerName ?? "", age: calcAge(patient.dateOfBirth) });
};
const startRename = (e, t) => {
@@ -451,6 +461,10 @@ export function LabRxModal({ open, onClose, patient }) {
setRx((r) => ({ ...r, shade: e.target.value }))} className="h-9 text-sm" />
+
+
+ setRx((r) => ({ ...r, age: e.target.value }))} className="h-9 text-sm" />
+
setRx((r) => ({ ...r, dueDate: e.target.value }))} className="h-9 text-sm" />
@@ -499,7 +513,7 @@ export function LabRxModal({ open, onClose, patient }) {
-
DOB{patient.dateOfBirth ? new Date(patient.dateOfBirth).toLocaleDateString("en-US") : "—"}
+
Lab{rxTemplate.labName || "—"}
Phone{rxTemplate.labPhone || "—"}
{rxTemplate.labFax &&
}
@@ -537,7 +551,7 @@ export function LabRxModal({ open, onClose, patient }) {
Patient Information
{patientName}
-
{patient.dateOfBirth ? new Date(patient.dateOfBirth).toLocaleDateString("en-US") : ""}
+
{rx.age}
diff --git a/apps/Frontend/src/components/chart/lab-rx-modal.tsx b/apps/Frontend/src/components/chart/lab-rx-modal.tsx
index e293dcf7..5b6c7153 100644
--- a/apps/Frontend/src/components/chart/lab-rx-modal.tsx
+++ b/apps/Frontend/src/components/chart/lab-rx-modal.tsx
@@ -55,6 +55,7 @@ type RxFields = {
shade: string;
dueDate: string;
doctorName: string;
+ age: string;
additionalNotes: string;
};
@@ -62,7 +63,17 @@ const EMPTY_TEMPLATE: TemplateFormState = {
name: "", labName: "", labPhone: "", labFax: "",
labAddress: "", labAccount: "", caseType: "", material: "", instructions: "Please make\nThank you!",
};
-const EMPTY_RX: RxFields = { toothNumbers: "", shade: "", dueDate: "", doctorName: "", additionalNotes: "Please make\nThank you!" };
+const EMPTY_RX: RxFields = { toothNumbers: "", shade: "", dueDate: "", doctorName: "", age: "", additionalNotes: "Please make\nThank you!" };
+
+const calcAge = (dob: string | Date | null | undefined): string => {
+ if (!dob) return "";
+ const birth = new Date(dob);
+ const today = new Date();
+ let age = today.getFullYear() - birth.getFullYear();
+ const m = today.getMonth() - birth.getMonth();
+ if (m < 0 || (m === 0 && today.getDate() < birth.getDate())) age--;
+ return String(age);
+};
const CASE_TYPES = ["Crown", "Bridge", "Veneer", "Inlay/Onlay", "Full Denture", "Partial Denture", "Night Guard", "Retainer", "Implant Crown", "Other"];
const MATERIALS = ["Zirconia", "PFM (Porcelain-Fused-to-Metal)", "E-Max", "Acrylic", "Cast Metal", "Composite", "PMMA", "Other"];
@@ -175,7 +186,7 @@ export function LabRxModal({ open, onClose, patient }: Props) {
const openRx = (t: LabRxTemplate) => {
if (renamingId !== null) return;
setRxTemplate(t);
- setRx({ ...EMPTY_RX, doctorName: providers[0]?.providerName ?? "" });
+ setRx({ ...EMPTY_RX, doctorName: providers[0]?.providerName ?? "", age: calcAge(patient.dateOfBirth) });
};
const startRename = (e: React.MouseEvent, t: LabRxTemplate) => {
@@ -495,6 +506,10 @@ export function LabRxModal({ open, onClose, patient }: Props) {
setRx((r) => ({ ...r, shade: e.target.value }))} className="h-9 text-sm" />
+
+
+ setRx((r) => ({ ...r, age: e.target.value }))} className="h-9 text-sm" />
+
setRx((r) => ({ ...r, dueDate: e.target.value }))} className="h-9 text-sm" />
@@ -543,7 +558,7 @@ export function LabRxModal({ open, onClose, patient }: Props) {
-
DOB{patient.dateOfBirth ? new Date(patient.dateOfBirth).toLocaleDateString("en-US") : "—"}
+
Lab{rxTemplate.labName || "—"}
Phone{rxTemplate.labPhone || "—"}
{rxTemplate.labFax &&
}
@@ -581,7 +596,7 @@ export function LabRxModal({ open, onClose, patient }: Props) {
Patient Information
{patientName}
-
{patient.dateOfBirth ? new Date(patient.dateOfBirth).toLocaleDateString("en-US") : ""}
+
{rx.age}