From 11a4f2f3eb0729c7cc708022c369279c2bea7ab1 Mon Sep 17 00:00:00 2001 From: CynthiaKamau Date: Mon, 4 Nov 2024 14:58:33 +0300 Subject: [PATCH] (feat) O3-3839 Allowing of printing lab request (#2063) --- .../src/components/order-details-table.scss | 15 ++++ .../orders-details-table.component.tsx | 82 ++++++++++++------- .../src/config-schema.ts | 7 ++ .../orders-summary.component.tsx | 9 +- .../translations/en.json | 2 + 5 files changed, 83 insertions(+), 32 deletions(-) diff --git a/packages/esm-patient-orders-app/src/components/order-details-table.scss b/packages/esm-patient-orders-app/src/components/order-details-table.scss index cea68c18c..7c4ef3007 100644 --- a/packages/esm-patient-orders-app/src/components/order-details-table.scss +++ b/packages/esm-patient-orders-app/src/components/order-details-table.scss @@ -161,3 +161,18 @@ .helperText { @include type.type-style('helper-text-02'); } + +.printButton { + margin-left: 1.25rem; +} + +@media print { + html, + body { + margin: 0 !important; + width: fit-content; + padding: 0 !important; + overflow: hidden; + page-break-inside: avoid; + } +} diff --git a/packages/esm-patient-orders-app/src/components/orders-details-table.component.tsx b/packages/esm-patient-orders-app/src/components/orders-details-table.component.tsx index 80df0067a..7d19f57e0 100644 --- a/packages/esm-patient-orders-app/src/components/orders-details-table.component.tsx +++ b/packages/esm-patient-orders-app/src/components/orders-details-table.component.tsx @@ -177,6 +177,14 @@ const OrderDetailsTable: React.FC = ({ patientUuid, showAddBu }, ]; + if (isPrinting) { + tableHeaders.push({ + key: 'dosage', + header: t('dosage', 'Dosage'), + isSortable: true, + }); + } + const tableRows = useMemo( () => allOrders?.map((order) => ({ @@ -184,7 +192,15 @@ const OrderDetailsTable: React.FC = ({ patientUuid, showAddBu dateActivated: order.dateActivated, orderNumber: order.orderNumber, dateOfOrder:
{formatDate(new Date(order.dateActivated))}
, - orderType: capitalize(order.orderType?.display ?? '--'), + orderType: capitalize(order.orderType?.display ?? '-'), + dosage: + order.type === 'drugorder' ? ( +
{`${t('indication', 'Indication').toUpperCase()} + ${order.orderReasonNonCoded} ${'-'} ${t('quantity', 'Quantity').toUpperCase()} ${order.quantity} ${order + ?.quantityUnits?.display} `}
+ ) : ( + '--' + ), order: order.display, priority: (
@@ -255,15 +271,15 @@ const OrderDetailsTable: React.FC = ({ patientUuid, showAddBu if (isPrinting && onBeforeGetContentResolve.current) { onBeforeGetContentResolve.current(); } - }, [isPrinting, onBeforeGetContentResolve]); + }, [isPrinting]); const handlePrint = useReactToPrint({ content: () => contentToPrintRef.current, documentTitle: `OpenMRS - ${patientDetails.name} - ${title}`, - onBeforeGetContent: () => + onBeforeGetContent: (): Promise => new Promise((resolve) => { - if (patient && patient?.patient && title) { - onBeforeGetContentResolve.current = resolve; + if (patient && title) { + onBeforeGetContentResolve.current = resolve(); setIsPrinting(true); } }), @@ -347,8 +363,8 @@ const OrderDetailsTable: React.FC = ({ patientUuid, showAddBu {showPrintButton && (