Skip to content

Commit 077659d

Browse files
committed
(feat) O3-3816 Add tab for rejected orders and prevent further actions on Declined Tests
1 parent b7ee40d commit 077659d

File tree

9 files changed

+165
-132
lines changed

9 files changed

+165
-132
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"react-router-dom": "6.x"
5757
},
5858
"devDependencies": {
59-
"@openmrs/esm-framework": "next",
59+
"@openmrs/esm-framework": "^5.8.2-pre.2512",
6060
"@openmrs/esm-patient-common-lib": "next",
6161
"@swc/cli": "^0.1.62",
6262
"@swc/core": "^1.3.62",
@@ -87,7 +87,7 @@
8787
"jest-cli": "^28.1.3",
8888
"jest-environment-jsdom": "^28.1.3",
8989
"lint-staged": "^14.0.1",
90-
"openmrs": "next",
90+
"openmrs": "^5.8.2-pre.2512",
9191
"prettier": "^2.8.8",
9292
"pretty-quick": "^3.1.3",
9393
"raw-loader": "^4.0.2",

src/components/orders-table/list-order-details.component.tsx

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,6 @@ const ListOrderDetails: React.FC<ListOrdersDetailsProps> = (props) => {
3131
<span className={styles.orderDate}>
3232
{t('orderDate', 'Order Date:')} {row.dateActivated}
3333
</span>
34-
</div>
35-
<div className={styles.orderStatus}>
36-
{t('orderStatus', 'Status:')}
37-
<Tag size="lg" type={row.fulfillerStatus ? 'green' : 'red'}>
38-
{row.fulfillerStatus || t('orderNotPicked', 'Order not picked')}
39-
</Tag>
40-
</div>
41-
<div>
42-
<div className={styles.orderUrgency}>
43-
<span className={styles.urgencyStatus}>
44-
{t('urgencyStatus', 'Urgency: ')} {capitalize(row.urgency)}
45-
</span>
46-
</div>
4734
<StructuredListWrapper>
4835
<StructuredListBody>
4936
<StructuredListRow>
@@ -86,6 +73,12 @@ const ListOrderDetails: React.FC<ListOrdersDetailsProps> = (props) => {
8673
</AccordionItem>
8774
</Accordion>
8875
)}
76+
{row.fulfillerStatus === 'DECLINED' && (
77+
<StructuredListRow>
78+
<StructuredListCell> {t('reasonForDecline', 'Reason for decline:')}</StructuredListCell>
79+
<StructuredListCell>{row.fulfillerComment}</StructuredListCell>
80+
</StructuredListRow>
81+
)}
8982
<StructuredListRow>
9083
<StructuredListCell>
9184
<span className={styles.nameOrder}>

src/components/orders-table/list-order-details.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
.nameOrder {
1616
// TODO: Prefer type styles over scales as mentioned here: https://carbondesignsystem.com/elements/typography/code/#type-scale
1717
font-size: type.type-scale(2);
18-
margin-left: layout.$spacing-04;
1918
}
2019

2120
.testOrder {

src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ export const completedLabRequestsTable = getAsyncLifecycle(
5252
options,
5353
);
5454

55+
export const declinedLabRequestsTable = getAsyncLifecycle(
56+
() => import('./lab-tabs/data-table-extensions/declined-lab-requests-table-extension'),
57+
options,
58+
);
59+
5560
export const worklistTile = getAsyncLifecycle(
5661
() => import('./lab-tiles/in-progress-lab-requests-tile.component'),
5762
options,
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import React from 'react';
2+
import OrdersDataTable from '../../components/orders-table/orders-data-table.component';
3+
4+
const DeclinedLabRequestsTable: React.FC = () => {
5+
return (
6+
<OrdersDataTable
7+
fulfillerStatus="DECLINED"
8+
excludeColumns={[]}
9+
excludeCanceledAndDiscontinuedOrders={false}
10+
actions={[]}
11+
/>
12+
);
13+
};
14+
15+
export default DeclinedLabRequestsTable;

src/lab-tabs/modals/reject-lab-request-modal.component.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
import React, { useState } from 'react';
22
import { Button, Form, ModalBody, ModalFooter, ModalHeader, TextArea, Layer } from '@carbon/react';
33
import { useTranslation } from 'react-i18next';
4-
import { showNotification, showSnackbar, useAbortController } from '@openmrs/esm-framework';
54
import { type Order } from '@openmrs/esm-patient-common-lib';
5+
import {
6+
type Config,
7+
restBaseUrl,
8+
showNotification,
9+
showSnackbar,
10+
useAbortController,
11+
useConfig,
12+
} from '@openmrs/esm-framework';
613
import { rejectLabOrder } from '../../laboratory-resource';
714
import styles from './reject-lab-request-modal.scss';
8-
15+
import { mutate } from 'swr';
916
interface RejectLabRequestModalProps {
1017
order: Order;
1118
closeModal: () => void;
@@ -16,12 +23,19 @@ const RejectLabRequestModal: React.FC<RejectLabRequestModalProps> = ({ order, cl
1623
const [fulfillerComment, setFulfillerComment] = useState('');
1724
const abortController = useAbortController();
1825
const [isSubmitting, setIsSubmitting] = useState(false);
26+
const { laboratoryOrderTypeUuid } = useConfig<Config>();
1927

2028
const handleRejectOrder = async (event) => {
2129
event.preventDefault();
2230
setIsSubmitting(true);
2331
rejectLabOrder(order.uuid, fulfillerComment, abortController).then(
2432
() => {
33+
mutate(
34+
(key) =>
35+
typeof key === 'string' && key.startsWith(`${restBaseUrl}/order?orderTypes=${laboratoryOrderTypeUuid}`),
36+
undefined,
37+
{ revalidate: true },
38+
);
2539
setIsSubmitting(false);
2640
closeModal();
2741
showSnackbar({

src/routes.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@
8787
"title": "Referred Tests"
8888
}
8989
},
90+
{
91+
"name": "declined-tile-component",
92+
"slot": "lab-panels-slot",
93+
"component": "declinedLabRequestsTable",
94+
"meta": {
95+
"name": "declinedPanel",
96+
"title": "Declined tests"
97+
}
98+
},
9099
{
91100
"name": "pick-lab-request-action",
92101
"component": "pickupLabRequestAction",

translations/en.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,17 @@
2626
"orderDate": "Order Date:",
2727
"ordererName": "Orderer Name: ",
2828
"orderInStruction": "Instructions: ",
29-
"orderNotPicked": "Order not picked",
3029
"orderNumbers": "Order number:",
3130
"orderPickedSuccessfully": "You have successfully picked an order",
3231
"orders": "Orders",
33-
"orderStatus": "Status:",
3432
"patient": "Patient",
3533
"pickedAnOrder": "Picked an order",
3634
"pickLabRequest": "Pick Lab Request",
3735
"pickRequest": "Pick lab request",
3836
"pickRequestConfirmationText": "Continuing will update the request status to \"In Progress\" and advance it to the next stage. Are you sure you want to proceed?",
3937
"pickupLabRequest": "Pick up lab request",
4038
"previousPage": "Previous page",
39+
"reasonForDecline": "Reason for decline",
4140
"receivedStatus": "RECEIVED",
4241
"reject": "Reject",
4342
"rejectLabRequest": "Reject lab request",
@@ -50,7 +49,6 @@
5049
"testsOrdered": "Tests ordered",
5150
"testType": "Test type",
5251
"totalOrders": "Total orders",
53-
"urgencyStatus": "Urgency: ",
5452
"viewTestResults": "View test results",
5553
"worklist": "Worklist"
5654
}

0 commit comments

Comments
 (0)