diff --git a/src/components/Common/PrintTable.tsx b/src/components/Common/PrintTable.tsx index a411f44bfb3..4f6128dd9f7 100644 --- a/src/components/Common/PrintTable.tsx +++ b/src/components/Common/PrintTable.tsx @@ -14,19 +14,61 @@ import { type HeaderRow = { key: string; width?: number; + className?: string; }; type TableRowType = Record; + +type CellConfig = { + value?: string; + className?: string; + render?: (value: string | undefined) => React.ReactNode; +}; + interface GenericTableProps { headers: HeaderRow[]; rows: TableRowType[] | undefined; + className?: string; + classNameCell?: string; + cellConfig?: Record; + renderCell?: ( + key: string, + value: string | undefined, + rowIndex: number, + ) => React.ReactNode; } -export default function PrintTable({ headers, rows }: GenericTableProps) { +export default function PrintTable({ + headers, + rows, + className, + classNameCell, + cellConfig, + renderCell, +}: GenericTableProps) { const { t } = useTranslation(); + const getCellContent = ( + key: string, + value: string | undefined, + rowIndex: number, + ) => { + // Priority 1: Custom renderCell function + if (renderCell) { + return renderCell(key, value, rowIndex); + } + + // Priority 2: Cell-specific render function from cellConfig + if (cellConfig?.[key]?.render) { + return cellConfig[key].render(value); + } + + // Priority 3: Default value or "-" + return value || "-"; + }; + return ( -
+
@@ -49,14 +91,21 @@ export default function PrintTable({ headers, rows }: GenericTableProps) { rows.map((row, index) => ( {headers.map(({ key }) => ( - {row[key] || "-"} + {getCellContent(key, row[key], index)} ))} diff --git a/src/components/Prescription/PrescriptionPreview.tsx b/src/components/Prescription/PrescriptionPreview.tsx index 2a344b1fce4..aeae3fada8f 100644 --- a/src/components/Prescription/PrescriptionPreview.tsx +++ b/src/components/Prescription/PrescriptionPreview.tsx @@ -44,7 +44,7 @@ const PrescriptionContent = ({ prescription }: PrescriptionContentProps) => { return (
{/* Prescription Symbol */} -
+

{t("℞")}

{formatDateTime( @@ -87,6 +87,10 @@ const PrescriptionContent = ({ prescription }: PrescriptionContentProps) => { instructions: `${remarks || "-"}${notes ? ` (${t("note")}: ${notes})` : ""}`, }; })} + className="text-xs font-semibold whitespace-break-spaces text-gray-950" + cellConfig={{ + medicine: { className: "text-left font-semibold" }, + }} />

)} @@ -123,13 +127,17 @@ const PrescriptionContent = ({ prescription }: PrescriptionContentProps) => { instructions: `${remarks || "-"}${notes ? ` (${t("note")}: ${notes})` : ""}`, }; })} + className="text-xs font-semibold whitespace-break-spaces text-gray-950" + cellConfig={{ + medicine: { className: "text-left font-semibold" }, + }} />
)} {/* Doctor's Signature */}
-

{t("prescribed_by")}

+

{t("prescribed_by")}

{formatName( prescription.prescription?.prescribed_by || @@ -187,12 +195,12 @@ export const PrescriptionPreview = ({

-

{facility?.name}

+

{facility?.name}

{facility?.address && ( -
+
{facility.address} {facility.phone_number && ( -

+

{t("phone")}: {facility.phone_number}

)} @@ -240,11 +248,8 @@ export const PrescriptionPreview = ({ label={t("date")} value={ encounter?.period?.start - ? format( - new Date(encounter.period.start), - "dd MMM yyyy, EEEE", - ) - : format(new Date(), "dd MMM yyyy, EEEE") + ? format(new Date(encounter.period.start), "dd/MM/yy") + : format(new Date(), "dd/MM/yy") } isStrong /> @@ -264,7 +269,10 @@ export const PrescriptionPreview = ({ ))} {/* Footer */} - +
diff --git a/src/pages/Facility/services/pharmacy/MedicationBillForm.tsx b/src/pages/Facility/services/pharmacy/MedicationBillForm.tsx index 64836132fb1..e5355bcbcb9 100644 --- a/src/pages/Facility/services/pharmacy/MedicationBillForm.tsx +++ b/src/pages/Facility/services/pharmacy/MedicationBillForm.tsx @@ -243,10 +243,9 @@ const AddMedicationSheet = ({ const isConsumable = selectedProduct?.product_type === "consumable"; - // TODO: bring this back, after debugging what's causing it. B, P, E, T (and more?) can't be typed. - // useShortcutSubContext("patient:search:-global", { - // ignoreInputFields: true, - // }); + useShortcutSubContext("patient:search:-global", { + ignoreInputFields: true, + }); // Update local state when the sheet opens or when editing a different item useEffect(() => { @@ -728,7 +727,6 @@ export default function MedicationBillForm({ patientId, prescriptionId, }: Props) { - useShortcutSubContext("facility:general"); const { t } = useTranslation(); const queryClient = useQueryClient(); const { facilityId } = useCurrentFacility();