Skip to content

Commit

Permalink
Order workspaces should have title according to their order type
Browse files Browse the repository at this point in the history
  • Loading branch information
vasharma05 committed Jan 10, 2025
1 parent 583aa07 commit 156f97f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { type ComponentProps, useCallback, useMemo, useRef, useState } from 'react';
import React, { type ComponentProps, useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { Button, Search } from '@carbon/react';
import { useTranslation } from 'react-i18next';
import {
Expand Down Expand Up @@ -43,14 +43,25 @@ const OrderableConceptSearchWorkspace: React.FC<OrderableConceptSearchWorkspaceP
closeWorkspace,
closeWorkspaceWithSavedChanges,
promptBeforeClosing,
setTitle,
}) => {
const { t } = useTranslation();
const isTablet = useLayoutType() === 'tablet';
const { orders } = useOrderBasket<OrderBasketItem>(orderTypeUuid, prepOrderPostData);
const { patientUuid } = usePatientChartStore();
const { orderTypes } = useConfig<ConfigObject>();

const [currentOrder, setCurrentOrder] = useState(initialOrder);
const { orderType } = useOrderType(orderTypeUuid);

useEffect(() => {
if (orderType) {
setTitle(
t(`addOrderableForOrderType`, 'Add {{orderTypeDisplay}}', {
orderTypeDisplay: orderType.display.toLocaleLowerCase(),
}),
);
}
}, [orderType, t, setTitle]);

const orderableConceptSets = useMemo(
() => orderTypes.find((orderType) => orderType.orderTypeUuid === orderTypeUuid).orderableConceptSets,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { type ComponentProps, useCallback, useMemo, useState } from 'react';
import React, { type ComponentProps, useCallback, useEffect, useMemo, useState } from 'react';
import classNames from 'classnames';
import { capitalize } from 'lodash-es';
import { useTranslation } from 'react-i18next';
Expand All @@ -17,6 +17,7 @@ import {
type DefaultPatientWorkspaceProps,
type OrderBasketItem,
launchPatientWorkspace,
useOrderType,
usePatientChartStore,
} from '@openmrs/esm-patient-common-lib';
import { LabOrderForm } from './test-order-form.component';
Expand All @@ -39,13 +40,25 @@ export default function AddLabOrderWorkspace({
closeWorkspace,
closeWorkspaceWithSavedChanges,
promptBeforeClosing,
setTitle,
}: AddLabOrderWorkspace) {
const { t } = useTranslation();
const isTablet = useLayoutType() === 'tablet';
const { patientUuid } = usePatientChartStore();
const { patient, isLoading: isLoadingPatient } = usePatient(patientUuid);
const [currentLabOrder, setCurrentLabOrder] = useState(initialOrder as TestOrderBasketItem);
const { additionalTestOrderTypes, orders } = useConfig<ConfigObject>();
const { orderType } = useOrderType(orderTypeUuid);

useEffect(() => {
if (orderType) {
setTitle(
t(`addOrderableForOrderType`, 'Add {{orderTypeDisplay}}', {
orderTypeDisplay: orderType.display.toLocaleLowerCase(),
}),
);
}
}, [orderType, t, setTitle]);

const orderableConceptSets = useMemo(() => {
const allOrderTypes: ConfigObject['additionalTestOrderTypes'] = [
Expand Down

0 comments on commit 156f97f

Please sign in to comment.