diff --git a/apps/Frontend/src/components/chart/lab-rx-modal.jsx b/apps/Frontend/src/components/chart/lab-rx-modal.jsx index 338e81cf..2096fc5f 100644 --- a/apps/Frontend/src/components/chart/lab-rx-modal.jsx +++ b/apps/Frontend/src/components/chart/lab-rx-modal.jsx @@ -27,7 +27,7 @@ const EMPTY_TEMPLATE = { name: "", labName: "", labPhone: "", labFax: "", labAddress: "", labAccount: "", caseType: "", material: "", instructions: "Please make\nThank you!", }; -const EMPTY_RX = { toothNumbers: "", shade: "", dueDate: "", doctorName: "", age: "", additionalNotes: "Please make\nThank you!" }; +const EMPTY_RX = { toothNumbers: "", shade: "", dueDate: "", doctorName: "", age: "", officeName: "", additionalNotes: "Please make\nThank you!" }; const calcAge = (dob) => { if (!dob) return ""; @@ -67,6 +67,16 @@ export function LabRxModal({ open, onClose, patient }) { enabled: open, }); + const { data: officeContact } = useQuery({ + queryKey: ["/api/office-contact"], + queryFn: async () => { + const res = await apiRequest("GET", "/api/office-contact"); + if (!res.ok) return null; + return res.json(); + }, + enabled: open, + }); + const { data: templates = [], isLoading } = useQuery({ queryKey: ["/api/lab-rx/templates"], queryFn: async () => { @@ -141,7 +151,7 @@ export function LabRxModal({ open, onClose, patient }) { const openRx = (t) => { if (renamingId !== null) return; setRxTemplate(t); - setRx({ ...EMPTY_RX, doctorName: providers[0]?.providerName ?? "", age: calcAge(patient.dateOfBirth) }); + setRx({ ...EMPTY_RX, doctorName: providers[0]?.providerName ?? "", age: calcAge(patient.dateOfBirth), officeName: officeContact?.officeName ?? "" }); }; const startRename = (e, t) => { @@ -482,6 +492,10 @@ export function LabRxModal({ open, onClose, patient }) { +
+ + setRx((r) => ({ ...r, officeName: e.target.value }))} className="h-9 text-sm" /> +
@@ -514,6 +528,7 @@ export function LabRxModal({ open, onClose, patient }) {
Patient

{patientName}

Age

{rx.age || "—"}

+ {rx.officeName &&
Dental Office

{rx.officeName}

}
Lab

{rxTemplate.labName || "—"}

Phone

{rxTemplate.labPhone || "—"}

{rxTemplate.labFax &&
Fax

{rxTemplate.labFax}

} @@ -552,6 +567,7 @@ export function LabRxModal({ open, onClose, patient }) {
{patientName}
{rx.age}
+
{rx.officeName}
diff --git a/apps/Frontend/src/components/chart/lab-rx-modal.tsx b/apps/Frontend/src/components/chart/lab-rx-modal.tsx index 5b6c7153..2be9615f 100644 --- a/apps/Frontend/src/components/chart/lab-rx-modal.tsx +++ b/apps/Frontend/src/components/chart/lab-rx-modal.tsx @@ -56,6 +56,7 @@ type RxFields = { dueDate: string; doctorName: string; age: string; + officeName: string; additionalNotes: string; }; @@ -63,7 +64,7 @@ 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: "", age: "", additionalNotes: "Please make\nThank you!" }; +const EMPTY_RX: RxFields = { toothNumbers: "", shade: "", dueDate: "", doctorName: "", age: "", officeName: "", additionalNotes: "Please make\nThank you!" }; const calcAge = (dob: string | Date | null | undefined): string => { if (!dob) return ""; @@ -112,6 +113,16 @@ export function LabRxModal({ open, onClose, patient }: Props) { enabled: open, }); + const { data: officeContact } = useQuery<{ officeName?: string } | null>({ + queryKey: ["/api/office-contact"], + queryFn: async () => { + const res = await apiRequest("GET", "/api/office-contact"); + if (!res.ok) return null; + return res.json(); + }, + enabled: open, + }); + const { data: templates = [], isLoading } = useQuery({ queryKey: ["/api/lab-rx/templates"], queryFn: async () => { @@ -186,7 +197,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 ?? "", age: calcAge(patient.dateOfBirth) }); + setRx({ ...EMPTY_RX, doctorName: providers[0]?.providerName ?? "", age: calcAge(patient.dateOfBirth), officeName: officeContact?.officeName ?? "" }); }; const startRename = (e: React.MouseEvent, t: LabRxTemplate) => { @@ -527,6 +538,10 @@ export function LabRxModal({ open, onClose, patient }: Props) {
+
+ + setRx((r) => ({ ...r, officeName: e.target.value }))} className="h-9 text-sm" /> +
@@ -559,6 +574,7 @@ export function LabRxModal({ open, onClose, patient }: Props) {
Patient

{patientName}

Age

{rx.age || "—"}

+ {rx.officeName &&
Dental Office

{rx.officeName}

}
Lab

{rxTemplate.labName || "—"}

Phone

{rxTemplate.labPhone || "—"}

{rxTemplate.labFax &&
Fax

{rxTemplate.labFax}

} @@ -597,6 +613,7 @@ export function LabRxModal({ open, onClose, patient }: Props) {
{patientName}
{rx.age}
+
{rx.officeName}