Skip to content

Commit

Permalink
adds feature flag and minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
pirupius committed Dec 2, 2023
1 parent 10619e9 commit 20be8d3
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 40 deletions.
6 changes: 3 additions & 3 deletions packages/esm-patient-chart-app/translations/km.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"appointmentUpdate": "ធ្វើបច្ចុប្បន្នភាពការណាត់ជួបនាពេលខាងមុខបានជោគជ័យ",
"Attachments dashboard": "ផ្ទាំងគ្រប់គ្រងឯកសារភ្ជាប់",
"cancel": "បោះបង់",
"cancelActiveVisitConfirmation": "តើ\u200bអ្នក\u200bពិតជា\u200bចង់\u200bបោះបង់ការពិនិត្យជំងឺ\u200bសកម្ម\u200bនេះទេ?",
"cancelActiveVisitConfirmation": "តើ​អ្នក​ពិតជា​ចង់​បោះបង់ការពិនិត្យជំងឺ​សកម្ម​នេះទេ?",
"cancellingVisit": "បោះបង់ការពិនិត្យជំងឺ",
"cancelVisit": "បោះបង់ការជួបពិនិត្យជំងឺ",
"cancelVisitExplainerMessage": "បោះបង់ការពិនិត្យជំងឺនេះនឹងលុបការមកពិនិត្យជំងឺដែលពាក់ព័ន្ធ។",
Expand Down Expand Up @@ -61,7 +61,7 @@
"errorDeletingVisit": "មានបញ្ហាបច្ចេកទេសក្នុងការលុបការពិនិត្យជំងឺ",
"errorEndingVisit": "មានបញ្ហាបច្ចេកទេសបញ្ចប់ការពិនិត្យជំងឺ",
"errorOccuredDeletingVisit": "មានបញ្ហាបច្ចេកទេសនៅពេលលុបការពិនិត្យជំងឺ",
"errorUpdatingVisitDetails": "មានបញ្ហាបច្ចេកទេស\u200bក្នុង\u200bការ\u200bធ្វើ\u200bបច្ចុប្បន្នភាព\u200bព័ត៌មាន\u200bលម្អិត\u200bនៃ\u200bការ\u200bពិនិត្យជំងឺ",
"errorUpdatingVisitDetails": "មានបញ្ហាបច្ចេកទេស​ក្នុង​ការ​ធ្វើ​បច្ចុប្បន្នភាព​ព័ត៌មាន​លម្អិត​នៃ​ការ​ពិនិត្យជំងឺ",
"errorWhenRestoringVisit": "មានបញ្ហាបច្ចេកទេសនៅពេលទាញមកវិញនូវ{{visit}}",
"failedDeleting": "មិនអាចលុបបានទេ",
"failedToLoadCurrentVisit": "ការទាញទិន្នន័យពិនិត្យជំងឺបច្ចុប្បន្នបរាជ័យ",
Expand Down Expand Up @@ -173,7 +173,7 @@
"visitEndSuccessfully": "បានបញ្ចប់ការមកពិនិត្យជំងឺបច្ចុប្បន្នដោយជោគជ័យ",
"visitLocation": "ទីតាំងការមកពិនិត្យជំងឺ",
"visitNotRestored": "ការពិនិត្យជំងឺមិនអាចទាញមកវិញបានទេ",
"visitRestored": "ការពិនិត្យជំងឺ\u200bបាន\u200bទាញមកវិញបាន",
"visitRestored": "ការពិនិត្យជំងឺ​បាន​ទាញមកវិញបាន",
"visitRestoredSuccessfully": "{{visit}} បានទាញមកវិញដោយជោគជ័យ",
"visits": "មកពិនិត្យជំងឺ",
"Visits": "មកពិនិត្យជំងឺ",
Expand Down
4 changes: 4 additions & 0 deletions packages/esm-patient-common-lib/src/orders/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ export interface Order {
type: string;
}

export interface OrderTypeFetchResponse {
results: Array<OrderType>;
}

export interface OrderType {
uuid: string;
display: string;
Expand Down
9 changes: 6 additions & 3 deletions packages/esm-patient-common-lib/src/orders/useOrders.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import useSWR, { mutate } from 'swr';
import { type FetchResponse, openmrsFetch, useConfig } from '@openmrs/esm-framework';
import { type FetchResponse, openmrsFetch } from '@openmrs/esm-framework';
import { useCallback, useMemo } from 'react';
import { type OrderBasketItem, type OrderPost, type PatientOrderFetchResponse } from '@openmrs/esm-patient-common-lib';
import { type OrderTypeFetchResponse, type PatientOrderFetchResponse } from '@openmrs/esm-patient-common-lib';

export const careSettingUuid = '6f0c9a92-6f24-11e3-af88-005056821db0';

Expand Down Expand Up @@ -38,7 +38,10 @@ export function usePatientOrders(patientUuid: string, status: 'ACTIVE' | 'any',

export function useOrderTypes() {
const orderTypesUrl = `/ws/rest/v1/ordertype`;
const { data, error, isLoading, isValidating } = useSWR<FetchResponse, Error>(orderTypesUrl, openmrsFetch);
const { data, error, isLoading, isValidating } = useSWR<FetchResponse<OrderTypeFetchResponse>, Error>(
orderTypesUrl,
openmrsFetch,
);

return {
data: data?.data?.results,
Expand Down
10 changes: 2 additions & 8 deletions packages/esm-patient-orders-app/src/api/api.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import { useCallback, useMemo } from 'react';
import useSWR, { mutate, useSWRConfig } from 'swr';
import useSWR, { useSWRConfig } from 'swr';
import { type FetchResponse, openmrsFetch, type OpenmrsResource, parseDate, type Visit } from '@openmrs/esm-framework';
import {
type OrderPost,
useVisitOrOfflineVisit,
useSystemVisitSetting,
type PatientOrderFetchResponse,
OrderType,
} from '@openmrs/esm-patient-common-lib';
import { type OrderPost, useVisitOrOfflineVisit, useSystemVisitSetting } from '@openmrs/esm-patient-common-lib';

export const careSettingUuid = '6f0c9a92-6f24-11e3-af88-005056821db0';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ import {
ErrorState,
usePatientOrders,
useOrderTypes,
} from '@openmrs/esm-patient-common-lib';
} from '../../../esm-patient-common-lib';
// } from '@openmrs/esm-patient-common-lib';
import { Add, User, Printer } from '@carbon/react/icons';
import { age, formatDate, useConfig, useLayoutType, usePagination, usePatient } from '@openmrs/esm-framework';
import { useTranslation } from 'react-i18next';
Expand All @@ -40,7 +41,6 @@ import { compare, orderPriorityToColor } from '../utils/utils';
import PrintComponent from '../print/print.component';
import { orderBy } from 'lodash-es';
import { Tooltip } from '@carbon/react';

interface OrderDetailsProps {
title?: string;
patientUuid: string;
Expand Down Expand Up @@ -130,7 +130,10 @@ const OrderDetailsTable: React.FC<OrderDetailsProps> = ({ title, patientUuid, sh
orderId: order.orderNumber,
dateOfOrder: formatDate(new Date(order.dateActivated)),
orderType: capitalize(order.orderType?.display ?? '--'),
order: <div>{order.display.length > 20 ? order.display.substring(0, 20).concat('...') : order.display}</div>,
order: order.display,
// order: (
// <div>{order.display.length > 20 ? <OrderDisplayTooltip orderDisplay={order.display} /> : order.display}</div>
// ),
priority: (
<div style={{ background: orderPriorityToColor(order.urgency), textAlign: 'center', borderRadius: '1rem' }}>
{capitalize(order.urgency)}
Expand Down Expand Up @@ -191,18 +194,13 @@ const OrderDetailsTable: React.FC<OrderDetailsProps> = ({ title, patientUuid, sh
};
}, [patient, t, excludePatientIdentifierCodeTypes?.uuids]);

// trigger a refetch to parent component if selectedOrderType changes
useEffect(() => {
// TODO: this is a hack to trigger a refetch of the parent component
}, [selectedOrderTypeUuid]);

const onBeforeGetContentResolve = useRef(null);

useEffect(() => {
if (isPrinting && onBeforeGetContentResolve.current) {
onBeforeGetContentResolve.current();
}
}, [isPrinting]);
}, [isPrinting, onBeforeGetContentResolve]);

const handlePrint = useReactToPrint({
content: () => contentToPrintRef.current,
Expand Down Expand Up @@ -312,7 +310,7 @@ const OrderDetailsTable: React.FC<OrderDetailsProps> = ({ title, patientUuid, sh
<TableRow className={styles.row} {...getRowProps({ row })}>
{row.cells.map((cell) => (
<TableCell className={styles.tableCell} key={cell.id}>
{cell.value?.content ?? cell.value}
<FormatCellDisplay rowDisplay={cell.value?.content ?? cell.value} />
</TableCell>
))}
{!isPrinting && (
Expand Down Expand Up @@ -353,12 +351,16 @@ const OrderDetailsTable: React.FC<OrderDetailsProps> = ({ title, patientUuid, sh
);
};

function OrderDisplayTooltip({ orderDisplay }: { orderDisplay: string }) {
function FormatCellDisplay({ rowDisplay }: { rowDisplay: string }) {
return (
<>
<Tooltip align="bottom" label={orderDisplay}>
{orderDisplay.substring(0, 20).concat('...')}
</Tooltip>
{typeof rowDisplay === 'string' && rowDisplay.length > 20 ? (
<Tooltip align="bottom" label={rowDisplay.concat(' test')}>
<>{rowDisplay.substring(0, 20).concat('...')}</>
</Tooltip>
) : (
rowDisplay
)}
</>
);
}
Expand Down
24 changes: 16 additions & 8 deletions packages/esm-patient-orders-app/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineConfigSchema, getAsyncLifecycle, getSyncLifecycle } from '@openmrs/esm-framework';
import { defineConfigSchema, getAsyncLifecycle, getSyncLifecycle, registerFeatureFlag } from '@openmrs/esm-framework';
import { createDashboardLink, registerWorkspace } from '@openmrs/esm-patient-common-lib';
import { configSchema } from './config-schema';
import orderBasketActionMenuComponent from './order-basket-action-button/order-basket-action-button.extension';
Expand Down Expand Up @@ -26,14 +26,22 @@ registerWorkspace({
canHide: true,
});

registerFeatureFlag(
'ordersSummary',
'Orders Summary',
'This feature introduces a navigation on the patient chart left nav called Orders and shows a history of patient orders within patient chart',
);

export const orderBasketActionMenu = getSyncLifecycle(orderBasketActionMenuComponent, options);

export const ordersDashboardLink = getSyncLifecycle(
createDashboardLink({
...ordersDashboardMeta,
moduleName,
}),
options,
);
export const ordersDashboardLink =
// t('Orders', 'Orders')
getSyncLifecycle(
createDashboardLink({
...ordersDashboardMeta,
moduleName,
}),
options,
);

export const ordersDashboard = getSyncLifecycle(OrdersSummary, options);
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ export interface OrdersSummaryProps {

const OrdersSummary: React.FC<OrdersSummaryProps> = ({ patientUuid }) => {
const { t } = useTranslation();
const ordersDisplayText = t('Orders', 'Orders');
const ordersDisplayText = t('orders', 'Orders');

return (
<div style={{ marginBottom: '1.5rem' }}>
<OrderDetailsTable
title={ordersDisplayText}
patientUuid={patientUuid}
showAddButton={true}
showPrintButton={false} // TODO: find out preferred way to print orders
showPrintButton={false}
/>
</div>
);
Expand Down
6 changes: 4 additions & 2 deletions packages/esm-patient-orders-app/src/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@
"path": "Orders",
"hideDashboardTitle": true
},
"order": 4
"order": 4,
"featureFlag": "ordersSummary"
},
{
"name": "patient-orders-dashboard",
"component": "ordersDashboard",
"slot": "patient-chart-orders-dashboard-slot",
"meta": {
"columnSpan": 4
}
},
"featureFlag": "ordersSummary"
}
]
}

0 comments on commit 20be8d3

Please sign in to comment.