From 4d931e137cc590d5d930e2fa7abc344af8cabd7e Mon Sep 17 00:00:00 2001 From: Vineet Sharma Date: Sat, 2 Nov 2024 17:20:36 +0530 Subject: [PATCH 1/7] (refactor) Remove the dependency of using `patientUuid` from the URL (#2080) * Introduce patient chart store for handling patient chart related state * Replace instances of getPatientUuidFromUrl * Update function name --- .../patient-chart/patient-chart.component.tsx | 12 +++++++ .../src/get-patient-uuid-from-url.ts | 9 ++++- packages/esm-patient-common-lib/src/index.ts | 1 + .../src/orders/postOrders.ts | 4 +-- .../src/orders/useOrderBasket.ts | 8 ++--- .../src/store/patient-chart-store.ts | 33 +++++++++++++++++++ .../esm-patient-common-lib/src/workspaces.ts | 7 ++-- .../drug-order-form.component.tsx | 4 ++- .../order-basket-search-results.component.tsx | 5 +-- .../order-basket-action-button.test.tsx | 8 +++-- .../add-lab-order/add-lab-order.test.tsx | 7 ++-- .../add-lab-order/add-lab-order.workspace.tsx | 4 ++- .../grouped-timeline/useObstreeData.ts | 5 +-- .../individual-results-table.component.tsx | 4 +-- .../test-results/panel-timeline/helpers.tsx | 4 +-- 15 files changed, 91 insertions(+), 24 deletions(-) create mode 100644 packages/esm-patient-common-lib/src/store/patient-chart-store.ts diff --git a/packages/esm-patient-chart-app/src/patient-chart/patient-chart.component.tsx b/packages/esm-patient-chart-app/src/patient-chart/patient-chart.component.tsx index 63bba2e81..4443bc0d7 100644 --- a/packages/esm-patient-chart-app/src/patient-chart/patient-chart.component.tsx +++ b/packages/esm-patient-chart-app/src/patient-chart/patient-chart.component.tsx @@ -17,6 +17,7 @@ import Loader from '../loader/loader.component'; import styles from './patient-chart.scss'; import VisitHeader from '../visit-header/visit-header.component'; import SideMenuPanel from '../side-nav/side-menu.component'; +import { getPatientChartStore } from '@openmrs/esm-patient-common-lib'; const PatientChart: React.FC = () => { const { patientUuid, view: encodedView } = useParams(); @@ -41,6 +42,17 @@ const PatientChart: React.FC = () => { }; }, [patientUuid]); + useEffect(() => { + getPatientChartStore().setState({ + patientUuid, + }); + return () => { + getPatientChartStore().setState({ + patientUuid: null, + }); + }; + }, [patientUuid]); + const leftNavBasePath = useMemo(() => spaBasePath.replace(':patientUuid', patientUuid), [patientUuid]); useEffect(() => { setLeftNav({ name: 'patient-chart-dashboard-slot', basePath: leftNavBasePath }); diff --git a/packages/esm-patient-common-lib/src/get-patient-uuid-from-url.ts b/packages/esm-patient-common-lib/src/get-patient-uuid-from-url.ts index 12c1357f8..be4c1399b 100644 --- a/packages/esm-patient-common-lib/src/get-patient-uuid-from-url.ts +++ b/packages/esm-patient-common-lib/src/get-patient-uuid-from-url.ts @@ -1,4 +1,11 @@ +import { getPatientUuidFromStore } from './store/patient-chart-store'; + +/** + * @deprecated This function is now replaced with `getPatientUuidFromStore`. This function will be removed in upcoming releases. + * @returns {string} patientUuid + */ export function getPatientUuidFromUrl(): string { const match = /\/patient\/([a-zA-Z0-9\-]+)\/?/.exec(location.pathname); - return match && match[1]; + const patientUuidFromUrl = match && match[1]; + return patientUuidFromUrl || getPatientUuidFromStore(); } diff --git a/packages/esm-patient-common-lib/src/index.ts b/packages/esm-patient-common-lib/src/index.ts index 76537159b..e35a3031c 100644 --- a/packages/esm-patient-common-lib/src/index.ts +++ b/packages/esm-patient-common-lib/src/index.ts @@ -20,3 +20,4 @@ export * from './types'; export * from './useAllowedFileExtensions'; export * from './useSystemVisitSetting'; export * from './workspaces'; +export * from './store/patient-chart-store'; diff --git a/packages/esm-patient-common-lib/src/orders/postOrders.ts b/packages/esm-patient-common-lib/src/orders/postOrders.ts index 2bbe92944..992886176 100644 --- a/packages/esm-patient-common-lib/src/orders/postOrders.ts +++ b/packages/esm-patient-common-lib/src/orders/postOrders.ts @@ -1,5 +1,5 @@ import { openmrsFetch, type OpenmrsResource, parseDate, restBaseUrl, type Visit } from '@openmrs/esm-framework'; -import { getPatientUuidFromUrl } from '../get-patient-uuid-from-url'; +import { getPatientUuidFromStore } from '../store/patient-chart-store'; import { type OrderBasketStore, orderBasketStore } from './store'; import { type ExtractedOrderErrorObject, type OrderBasketItem, type OrderErrorObject, type OrderPost } from './types'; @@ -55,7 +55,7 @@ export async function postOrdersOnNewEncounter( } export async function postOrders(encounterUuid: string, abortController: AbortController) { - const patientUuid = getPatientUuidFromUrl(); + const patientUuid = getPatientUuidFromStore(); const { items, postDataPrepFunctions }: OrderBasketStore = orderBasketStore.getState(); const patientItems = items[patientUuid]; diff --git a/packages/esm-patient-common-lib/src/orders/useOrderBasket.ts b/packages/esm-patient-common-lib/src/orders/useOrderBasket.ts index 625afb2c7..843035e98 100644 --- a/packages/esm-patient-common-lib/src/orders/useOrderBasket.ts +++ b/packages/esm-patient-common-lib/src/orders/useOrderBasket.ts @@ -1,6 +1,6 @@ import { useStoreWithActions } from '@openmrs/esm-framework'; import type { OrderBasketItem, PostDataPrepFunction } from './types'; -import { getPatientUuidFromUrl } from '../get-patient-uuid-from-url'; +import { getPatientUuidFromStore } from '../store/patient-chart-store'; import { useEffect } from 'react'; import { type OrderBasketStore, orderBasketStore } from './store'; @@ -10,7 +10,7 @@ const orderBasketStoreActions = { grouping: string, value: Array | (() => Array), ) { - const patientUuid = getPatientUuidFromUrl(); + const patientUuid = getPatientUuidFromStore(); if (!Object.keys(state.postDataPrepFunctions).includes(grouping)) { console.warn(`Programming error: You must register a postDataPrepFunction for grouping ${grouping} `); } @@ -35,7 +35,7 @@ const orderBasketStoreActions = { }; function getOrderItems(items: OrderBasketStore['items'], grouping?: string | null): Array { - const patientUuid = getPatientUuidFromUrl(); + const patientUuid = getPatientUuidFromStore(); const patientItems = items?.[patientUuid] ?? {}; return grouping ? patientItems[grouping] ?? [] : Object.values(patientItems).flat(); } @@ -46,7 +46,7 @@ export interface ClearOrdersOptions { function clearOrders(options?: ClearOrdersOptions) { const exceptThoseMatchingFcn = options?.exceptThoseMatching ?? (() => false); - const patientUuid = getPatientUuidFromUrl(); + const patientUuid = getPatientUuidFromStore(); const items = orderBasketStore.getState().items; const patientItems = items[patientUuid] ?? {}; const newPatientItems = Object.fromEntries( diff --git a/packages/esm-patient-common-lib/src/store/patient-chart-store.ts b/packages/esm-patient-common-lib/src/store/patient-chart-store.ts new file mode 100644 index 000000000..1b9f401e1 --- /dev/null +++ b/packages/esm-patient-common-lib/src/store/patient-chart-store.ts @@ -0,0 +1,33 @@ +import { createGlobalStore, useStore } from '@openmrs/esm-framework'; + +export interface PatientChartStore { + patientUuid: string; +} + +const patientChartStoreName = 'patient-chart-global-store'; + +const patientChartStore = createGlobalStore(patientChartStoreName, { + patientUuid: '', +}); + +/** + * This function returns the patient chart store. + * + * The patient chart store is used to store all global variables used in the patient chart. + * In the recent requirements, patient chart is now not only bound with `/patient/{patientUuid}/` path. + */ +export function getPatientChartStore() { + return patientChartStore; +} + +export function usePatientChartStore() { + return useStore(patientChartStore); +} + +/** + * This function will get the patient UUID from either URL, or will look into the patient chart store. + * @returns {string} patientUuid + */ +export function getPatientUuidFromStore(): string { + return patientChartStore.getState()?.patientUuid; +} diff --git a/packages/esm-patient-common-lib/src/workspaces.ts b/packages/esm-patient-common-lib/src/workspaces.ts index c202a6363..50ffb1dfd 100644 --- a/packages/esm-patient-common-lib/src/workspaces.ts +++ b/packages/esm-patient-common-lib/src/workspaces.ts @@ -4,18 +4,19 @@ import { navigateAndLaunchWorkspace, usePatient, } from '@openmrs/esm-framework'; -import { getPatientUuidFromUrl } from './get-patient-uuid-from-url'; +import { getPatientUuidFromStore } from './store/patient-chart-store'; import { useSystemVisitSetting } from './useSystemVisitSetting'; import { useVisitOrOfflineVisit } from './offline/visit'; import { useCallback } from 'react'; import { launchStartVisitPrompt } from './launchStartVisitPrompt'; +import { usePatientChartStore } from './store/patient-chart-store'; export interface DefaultPatientWorkspaceProps extends DefaultWorkspaceProps { patientUuid: string; } export function launchPatientWorkspace(workspaceName: string, additionalProps?: object) { - const patientUuid = getPatientUuidFromUrl(); + const patientUuid = getPatientUuidFromStore(); launchWorkspace(workspaceName, { patientUuid: patientUuid, ...additionalProps, @@ -42,7 +43,7 @@ export function launchPatientChartWithWorkspaceOpen({ } export function useLaunchWorkspaceRequiringVisit(workspaceName: string) { - const { patientUuid } = usePatient(); + const { patientUuid } = usePatientChartStore(); const { systemVisitEnabled } = useSystemVisitSetting(); const { currentVisit } = useVisitOrOfflineVisit(patientUuid); diff --git a/packages/esm-patient-medications-app/src/add-drug-order/drug-order-form.component.tsx b/packages/esm-patient-medications-app/src/add-drug-order/drug-order-form.component.tsx index 3480dc3d4..3226682fb 100644 --- a/packages/esm-patient-medications-app/src/add-drug-order/drug-order-form.component.tsx +++ b/packages/esm-patient-medications-app/src/add-drug-order/drug-order-form.component.tsx @@ -51,6 +51,7 @@ import type { } from '../types'; import { useRequireOutpatientQuantity } from '../api'; import styles from './drug-order-form.scss'; +import { usePatientChartStore } from '@openmrs/esm-patient-common-lib'; export interface DrugOrderFormProps { initialOrderBasketItem: DrugOrderBasketItem; @@ -354,7 +355,8 @@ export function DrugOrderForm({ initialOrderBasketItem, onSave, onCancel, prompt }, []); const [showStickyMedicationHeader, setShowMedicationHeader] = useState(false); - const { patient, isLoading: isLoadingPatientDetails } = usePatient(); + const { patientUuid } = usePatientChartStore(); + const { patient, isLoading: isLoadingPatientDetails } = usePatient(patientUuid); const patientName = patient ? getPatientName(patient) : ''; const { maxDispenseDurationInDays } = useConfig(); diff --git a/packages/esm-patient-medications-app/src/add-drug-order/drug-search/order-basket-search-results.component.tsx b/packages/esm-patient-medications-app/src/add-drug-order/drug-search/order-basket-search-results.component.tsx index b0664dd89..7264d85b4 100644 --- a/packages/esm-patient-medications-app/src/add-drug-order/drug-search/order-basket-search-results.component.tsx +++ b/packages/esm-patient-medications-app/src/add-drug-order/drug-search/order-basket-search-results.component.tsx @@ -24,6 +24,7 @@ import { } from './drug-search.resource'; import type { DrugOrderBasketItem } from '../../types'; import styles from './order-basket-search-results.scss'; +import { usePatientChartStore } from '@openmrs/esm-patient-common-lib'; export interface OrderBasketSearchResultsProps { searchTerm: string; @@ -114,8 +115,8 @@ export default function OrderBasketSearchResults({ const DrugSearchResultItem: React.FC = ({ drug, openOrderForm }) => { const isTablet = useLayoutType() === 'tablet'; const { orders, setOrders } = useOrderBasket('medications', prepMedicationOrderPostData); - const patient = usePatient(); - const { data: activeOrders, isLoading: isLoadingActiveOrders } = usePatientOrders(patient.patientUuid); + const { patientUuid } = usePatientChartStore(); + const { data: activeOrders, isLoading: isLoadingActiveOrders } = usePatientOrders(patientUuid); const drugAlreadyInBasket = useMemo( () => orders?.some((order) => ordersEqual(order, getTemplateOrderBasketItem(drug))), [orders, drug], diff --git a/packages/esm-patient-orders-app/src/order-basket-action-button/order-basket-action-button.test.tsx b/packages/esm-patient-orders-app/src/order-basket-action-button/order-basket-action-button.test.tsx index b2d061e74..43505b357 100644 --- a/packages/esm-patient-orders-app/src/order-basket-action-button/order-basket-action-button.test.tsx +++ b/packages/esm-patient-orders-app/src/order-basket-action-button/order-basket-action-button.test.tsx @@ -47,6 +47,7 @@ jest.mock('@openmrs/esm-patient-common-lib', () => { return { ...originalModule, getPatientUuidFromUrl: () => mockGetPatientUuidFromUrl(), + getPatientUuidFromStore: () => mockGetPatientUuidFromUrl(), launchPatientWorkspace: (arg) => mockLaunchPatientWorkspace(arg), }; }); @@ -61,8 +62,11 @@ jest.mock('@openmrs/esm-patient-common-lib/src/launchStartVisitPrompt', () => { return { launchStartVisitPrompt: () => mockLaunchStartVisitPrompt() }; }); -jest.mock('@openmrs/esm-patient-common-lib/src/get-patient-uuid-from-url', () => { - return { getPatientUuidFromUrl: () => mockGetPatientUuidFromUrl() }; +jest.mock('@openmrs/esm-patient-common-lib/src/store/patient-chart-store', () => { + return { + getPatientUuidFromStore: () => mockGetPatientUuidFromUrl(), + usePatientChartStore: () => ({ patientUuid: mockPatient.id }), + }; }); jest.mock('@openmrs/esm-patient-common-lib/src/offline/visit', () => { diff --git a/packages/esm-patient-tests-app/src/lab-orders/add-lab-order/add-lab-order.test.tsx b/packages/esm-patient-tests-app/src/lab-orders/add-lab-order/add-lab-order.test.tsx index 115aff7af..de8bf12cc 100644 --- a/packages/esm-patient-tests-app/src/lab-orders/add-lab-order/add-lab-order.test.tsx +++ b/packages/esm-patient-tests-app/src/lab-orders/add-lab-order/add-lab-order.test.tsx @@ -64,8 +64,11 @@ jest.mock('@openmrs/esm-patient-common-lib', () => ({ launchPatientWorkspace: (...args) => mockLaunchPatientWorkspace(...args), })); -jest.mock('@openmrs/esm-patient-common-lib/src/get-patient-uuid-from-url', () => ({ - getPatientUuidFromUrl: jest.fn(() => ptUuid), +jest.mock('@openmrs/esm-patient-common-lib/src/store/patient-chart-store', () => ({ + getPatientUuidFromStore: jest.fn(() => ptUuid), + usePatientChartStore: jest.fn(() => ({ + patientUuid: ptUuid, + })), })); function renderAddLabOrderWorkspace() { diff --git a/packages/esm-patient-tests-app/src/lab-orders/add-lab-order/add-lab-order.workspace.tsx b/packages/esm-patient-tests-app/src/lab-orders/add-lab-order/add-lab-order.workspace.tsx index eedcd6601..7c9070d42 100644 --- a/packages/esm-patient-tests-app/src/lab-orders/add-lab-order/add-lab-order.workspace.tsx +++ b/packages/esm-patient-tests-app/src/lab-orders/add-lab-order/add-lab-order.workspace.tsx @@ -17,6 +17,7 @@ import { type OrderBasketItem, type LabOrderBasketItem, launchPatientWorkspace, + usePatientChartStore, } from '@openmrs/esm-patient-common-lib'; import { LabOrderForm } from './lab-order-form.component'; import { TestTypeSearch } from './test-type-search.component'; @@ -37,7 +38,8 @@ export default function AddLabOrderWorkspace({ }: AddLabOrderWorkspace) { const { t } = useTranslation(); const isTablet = useLayoutType() === 'tablet'; - const { patient, isLoading: isLoadingPatient, patientUuid } = usePatient(); + const { patientUuid } = usePatientChartStore(); + const { patient, isLoading: isLoadingPatient } = usePatient(patientUuid); const [currentLabOrder, setCurrentLabOrder] = useState(initialOrder as LabOrderBasketItem); const patientName = patient ? getPatientName(patient) : ''; diff --git a/packages/esm-patient-tests-app/src/test-results/grouped-timeline/useObstreeData.ts b/packages/esm-patient-tests-app/src/test-results/grouped-timeline/useObstreeData.ts index 4281aba00..fc66502b5 100644 --- a/packages/esm-patient-tests-app/src/test-results/grouped-timeline/useObstreeData.ts +++ b/packages/esm-patient-tests-app/src/test-results/grouped-timeline/useObstreeData.ts @@ -3,6 +3,7 @@ import useSWR from 'swr'; import useSWRInfinite from 'swr/infinite'; import { usePatient, openmrsFetch, restBaseUrl, type FetchResponse } from '@openmrs/esm-framework'; import { assessValue, exist } from '../loadPatientTestData/helpers'; +import { usePatientChartStore } from '@openmrs/esm-patient-common-lib'; export const getName = (prefix: string | undefined, name: string) => { return prefix ? `${prefix}-${name}` : name; @@ -43,7 +44,7 @@ const augmentObstreeData = (node: ObsTreeNode, prefix: string | undefined) => { }; const useGetObstreeData = (conceptUuid: string) => { - const { patientUuid } = usePatient(); + const { patientUuid } = usePatientChartStore(); const response = useSWR, Error>( `${restBaseUrl}/obstree?patient=${patientUuid}&concept=${conceptUuid}`, openmrsFetch, @@ -65,7 +66,7 @@ const useGetObstreeData = (conceptUuid: string) => { }; const useGetManyObstreeData = (uuidArray: Array) => { - const { patientUuid } = usePatient(); + const { patientUuid } = usePatientChartStore(); const getObstreeUrl = (index: number) => { if (index < uuidArray.length && patientUuid) { return `${restBaseUrl}/obstree?patient=${patientUuid}&concept=${uuidArray[index]}`; diff --git a/packages/esm-patient-tests-app/src/test-results/individual-results-table/individual-results-table.component.tsx b/packages/esm-patient-tests-app/src/test-results/individual-results-table/individual-results-table.component.tsx index 934c784ee..efcc95772 100644 --- a/packages/esm-patient-tests-app/src/test-results/individual-results-table/individual-results-table.component.tsx +++ b/packages/esm-patient-tests-app/src/test-results/individual-results-table/individual-results-table.component.tsx @@ -14,7 +14,7 @@ import { TableRow, } from '@carbon/react'; import { ArrowRightIcon, showModal, useLayoutType, isDesktop, formatDate } from '@openmrs/esm-framework'; -import { getPatientUuidFromUrl, type OBSERVATION_INTERPRETATION } from '@openmrs/esm-patient-common-lib'; +import { getPatientUuidFromStore, type OBSERVATION_INTERPRETATION } from '@openmrs/esm-patient-common-lib'; import { type RowData } from '../filter/filter-types'; import styles from './individual-results-table.scss'; @@ -56,7 +56,7 @@ const getClasses = (interpretation: OBSERVATION_INTERPRETATION) => { const IndividualResultsTable: React.FC = ({ isLoading, parent, subRows, index }) => { const { t } = useTranslation(); const layout = useLayoutType(); - const patientUuid = getPatientUuidFromUrl(); + const patientUuid = getPatientUuidFromStore(); const headerTitle = t(parent.display); diff --git a/packages/esm-patient-tests-app/src/test-results/panel-timeline/helpers.tsx b/packages/esm-patient-tests-app/src/test-results/panel-timeline/helpers.tsx index 82d0fea26..ed3b72ed3 100644 --- a/packages/esm-patient-tests-app/src/test-results/panel-timeline/helpers.tsx +++ b/packages/esm-patient-tests-app/src/test-results/panel-timeline/helpers.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import classNames from 'classnames'; import { formatDate, formatTime, parseDate, showModal } from '@openmrs/esm-framework'; -import { type OBSERVATION_INTERPRETATION, getPatientUuidFromUrl } from '@openmrs/esm-patient-common-lib'; +import { type OBSERVATION_INTERPRETATION, getPatientUuidFromStore } from '@openmrs/esm-patient-common-lib'; import { type ParsedTimeType } from '../filter/filter-types'; import type { ObsRecord } from '../../types'; import styles from './timeline.scss'; @@ -121,7 +121,7 @@ export const TimelineCell: React.FC<{ }; export const RowStartCell = ({ title, range, units, shadow = false, testUuid, isString = false }) => { - const patientUuid = getPatientUuidFromUrl(); + const patientUuid = getPatientUuidFromStore(); const launchResultsDialog = (patientUuid: string, title: string, testUuid: string) => { const dispose = showModal('timeline-results-modal', { closeDeleteModal: () => dispose(), From 11a4f2f3eb0729c7cc708022c369279c2bea7ab1 Mon Sep 17 00:00:00 2001 From: CynthiaKamau Date: Mon, 4 Nov 2024 14:58:33 +0300 Subject: [PATCH 2/7] (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 && (