Skip to content

Commit

Permalink
O3-3816 Add tab for rejected orders and prevent further actions on De…
Browse files Browse the repository at this point in the history
…clined Tests
  • Loading branch information
CynthiaKamau committed Nov 28, 2024
1 parent 5579a42 commit b2b81cf
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ export const completedLabRequestsTable = getAsyncLifecycle(
options,
);

export const declinedLabRequestsTable = getAsyncLifecycle(
() => import('./lab-tabs/data-table-extensions/declined-lab-requests-table-extension'),
options,
);

export const worklistTile = getAsyncLifecycle(
() => import('./lab-tiles/in-progress-lab-requests-tile.component'),
options,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import OrdersDataTable from '../../components/orders-table/orders-data-table.component';

const DeclinedLabRequestsTable: React.FC = () => {
return (
<OrdersDataTable
fulfillerStatus="DECLINED"
excludeColumns={[]}
excludeCanceledAndDiscontinuedOrders={false}
actions={[]}
/>
);
};

export default DeclinedLabRequestsTable;
18 changes: 16 additions & 2 deletions src/lab-tabs/modals/reject-lab-request-modal.component.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import React, { useState } from 'react';
import { Button, Form, ModalBody, ModalFooter, ModalHeader, TextArea, Layer } from '@carbon/react';
import { useTranslation } from 'react-i18next';
import { showNotification, showSnackbar, useAbortController } from '@openmrs/esm-framework';
import {
Config,
restBaseUrl,
showNotification,
showSnackbar,
useAbortController,
useConfig,
} from '@openmrs/esm-framework';
import { Order } from '@openmrs/esm-patient-common-lib';
import { rejectLabOrder } from '../../laboratory-resource';
import styles from './reject-lab-request-modal.scss';

import { mutate } from 'swr';
interface RejectLabRequestModalProps {
order: Order;
closeModal: () => void;
Expand All @@ -16,12 +23,19 @@ const RejectLabRequestModal: React.FC<RejectLabRequestModalProps> = ({ order, cl
const [fulfillerComment, setFulfillerComment] = useState('');
const abortController = useAbortController();
const [isSubmitting, setIsSubmitting] = useState(false);
const { laboratoryOrderTypeUuid } = useConfig<Config>();

const handleRejectOrder = async (event) => {
event.preventDefault();
setIsSubmitting(true);
rejectLabOrder(order.uuid, fulfillerComment, abortController).then(
() => {
mutate(
(key) =>
typeof key === 'string' && key.startsWith(`${restBaseUrl}/order?orderTypes=${laboratoryOrderTypeUuid}`),
undefined,
{ revalidate: true },
);
setIsSubmitting(false);
closeModal();
showSnackbar({
Expand Down
9 changes: 9 additions & 0 deletions src/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,15 @@
"title": "Referred Tests"
}
},
{
"name": "declined-lab-requests-table",
"slot": "lab-panels-slot",
"component": "declinedLabRequestsTable",
"meta": {
"name": "declinedPanel",
"title": "Declined"
}
},
{
"name": "pick-lab-request-action",
"component": "pickupLabRequestAction",
Expand Down

0 comments on commit b2b81cf

Please sign in to comment.