feat: add Dental Office Name to Lab RX form, pre-filled from office contact settings
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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 }) {
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div className="col-span-2 space-y-1">
|
||||
<Label className="text-xs text-gray-600">Dental Office Name</Label>
|
||||
<Input placeholder="e.g. Summit Dental Care" value={rx.officeName} onChange={(e) => setRx((r) => ({ ...r, officeName: e.target.value }))} className="h-9 text-sm" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -514,6 +528,7 @@ export function LabRxModal({ open, onClose, patient }) {
|
||||
<div className="grid grid-cols-2 gap-x-6 gap-y-1">
|
||||
<div><span className="text-gray-400 text-xs">Patient</span><p className="font-medium">{patientName}</p></div>
|
||||
<div><span className="text-gray-400 text-xs">Age</span><p>{rx.age || "—"}</p></div>
|
||||
{rx.officeName && <div className="col-span-2"><span className="text-gray-400 text-xs">Dental Office</span><p className="font-medium">{rx.officeName}</p></div>}
|
||||
<div className="col-span-2 mt-1 border-t pt-2"><span className="text-gray-400 text-xs">Lab</span><p className="font-medium">{rxTemplate.labName || "—"}</p></div>
|
||||
<div><span className="text-gray-400 text-xs">Phone</span><p>{rxTemplate.labPhone || "—"}</p></div>
|
||||
{rxTemplate.labFax && <div><span className="text-gray-400 text-xs">Fax</span><p>{rxTemplate.labFax}</p></div>}
|
||||
@@ -552,6 +567,7 @@ export function LabRxModal({ open, onClose, patient }) {
|
||||
<div className="row">
|
||||
<div className="field"><label>Patient Name</label><span>{patientName}</span></div>
|
||||
<div className="field"><label>Age</label><span>{rx.age}</span></div>
|
||||
<div className="field"><label>Dental Office</label><span>{rx.officeName}</span></div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="section">
|
||||
|
||||
@@ -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<LabRxTemplate[]>({
|
||||
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) {
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div className="col-span-2 space-y-1">
|
||||
<Label className="text-xs text-gray-600">Dental Office Name</Label>
|
||||
<Input placeholder="e.g. Summit Dental Care" value={rx.officeName} onChange={(e) => setRx((r) => ({ ...r, officeName: e.target.value }))} className="h-9 text-sm" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -559,6 +574,7 @@ export function LabRxModal({ open, onClose, patient }: Props) {
|
||||
<div className="grid grid-cols-2 gap-x-6 gap-y-1">
|
||||
<div><span className="text-gray-400 text-xs">Patient</span><p className="font-medium">{patientName}</p></div>
|
||||
<div><span className="text-gray-400 text-xs">Age</span><p>{rx.age || "—"}</p></div>
|
||||
{rx.officeName && <div className="col-span-2"><span className="text-gray-400 text-xs">Dental Office</span><p className="font-medium">{rx.officeName}</p></div>}
|
||||
<div className="col-span-2 mt-1 border-t pt-2"><span className="text-gray-400 text-xs">Lab</span><p className="font-medium">{rxTemplate.labName || "—"}</p></div>
|
||||
<div><span className="text-gray-400 text-xs">Phone</span><p>{rxTemplate.labPhone || "—"}</p></div>
|
||||
{rxTemplate.labFax && <div><span className="text-gray-400 text-xs">Fax</span><p>{rxTemplate.labFax}</p></div>}
|
||||
@@ -597,6 +613,7 @@ export function LabRxModal({ open, onClose, patient }: Props) {
|
||||
<div className="row">
|
||||
<div className="field"><label>Patient Name</label><span>{patientName}</span></div>
|
||||
<div className="field"><label>Age</label><span>{rx.age}</span></div>
|
||||
<div className="field"><label>Dental Office</label><span>{rx.officeName}</span></div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="section">
|
||||
|
||||
Reference in New Issue
Block a user