Skip to content

Commit

Permalink
(feat) O3-3816 Add tab for rejected orders and prevent further action…
Browse files Browse the repository at this point in the history
…s on Declined Tests (#102)

Co-authored-by: Pius Rubangakene <[email protected]>
  • Loading branch information
CynthiaKamau and pirupius authored Dec 16, 2024
1 parent 2fb2e89 commit 47004c0
Show file tree
Hide file tree
Showing 9 changed files with 165 additions and 132 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"react-router-dom": "6.x"
},
"devDependencies": {
"@openmrs/esm-framework": "next",
"@openmrs/esm-framework": "^5.8.2-pre.2512",
"@openmrs/esm-patient-common-lib": "next",
"@swc/cli": "^0.1.62",
"@swc/core": "^1.3.62",
Expand Down Expand Up @@ -87,7 +87,7 @@
"jest-cli": "^28.1.3",
"jest-environment-jsdom": "^28.1.3",
"lint-staged": "^14.0.1",
"openmrs": "next",
"openmrs": "^5.8.2-pre.2512",
"prettier": "^2.8.8",
"pretty-quick": "^3.1.3",
"raw-loader": "^4.0.2",
Expand Down
19 changes: 6 additions & 13 deletions src/components/orders-table/list-order-details.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,6 @@ const ListOrderDetails: React.FC<ListOrdersDetailsProps> = (props) => {
<span className={styles.orderDate}>
{t('orderDate', 'Order Date:')} {row.dateActivated}
</span>
</div>
<div className={styles.orderStatus}>
{t('orderStatus', 'Status:')}
<Tag size="lg" type={row.fulfillerStatus ? 'green' : 'red'}>
{row.fulfillerStatus || t('orderNotPicked', 'Order not picked')}
</Tag>
</div>
<div>
<div className={styles.orderUrgency}>
<span className={styles.urgencyStatus}>
{t('urgencyStatus', 'Urgency: ')} {capitalize(row.urgency)}
</span>
</div>
<StructuredListWrapper>
<StructuredListBody>
<StructuredListRow>
Expand Down Expand Up @@ -86,6 +73,12 @@ const ListOrderDetails: React.FC<ListOrdersDetailsProps> = (props) => {
</AccordionItem>
</Accordion>
)}
{row.fulfillerStatus === 'DECLINED' && (
<StructuredListRow>
<StructuredListCell> {t('reasonForDecline', 'Reason for decline:')}</StructuredListCell>
<StructuredListCell>{row.fulfillerComment}</StructuredListCell>
</StructuredListRow>
)}
<StructuredListRow>
<StructuredListCell>
<span className={styles.nameOrder}>
Expand Down
1 change: 0 additions & 1 deletion src/components/orders-table/list-order-details.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
.nameOrder {
// TODO: Prefer type styles over scales as mentioned here: https://carbondesignsystem.com/elements/typography/code/#type-scale
font-size: type.type-scale(2);
margin-left: layout.$spacing-04;
}

.testOrder {
Expand Down
5 changes: 5 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ export const completedLabRequestsTable = getAsyncLifecycle(
options,
);

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

// t('Worklist', 'Worklist')
export const worklistTile = getAsyncLifecycle(
() => import('./lab-tiles/in-progress-lab-requests-tile.component'),
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 { type Order } from '@openmrs/esm-patient-common-lib';
import {
type Config,
restBaseUrl,
showNotification,
showSnackbar,
useAbortController,
useConfig,
} from '@openmrs/esm-framework';
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-tile-component",
"slot": "lab-panels-slot",
"component": "declinedLabRequestsTable",
"meta": {
"name": "declinedPanel",
"title": "Declined tests"
}
},
{
"name": "pick-lab-request-action",
"component": "pickupLabRequestAction",
Expand Down
4 changes: 1 addition & 3 deletions translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,17 @@
"Ordered tests": "Ordered tests",
"ordererName": "Orderer Name: ",
"orderInStruction": "Instructions: ",
"orderNotPicked": "Order not picked",
"orderNumbers": "Order number:",
"orderPickedSuccessfully": "You have successfully picked an order",
"orders": "Orders",
"orderStatus": "Status:",
"patient": "Patient",
"pickedAnOrder": "Picked an order",
"pickLabRequest": "Pick Lab Request",
"pickRequest": "Pick lab request",
"pickRequestConfirmationText": "Continuing will update the request status to \"In Progress\" and advance it to the next stage. Are you sure you want to proceed?",
"pickupLabRequest": "Pick up lab request",
"previousPage": "Previous page",
"reasonForDecline": "Reason for decline",
"receivedStatus": "RECEIVED",
"Referred tests": "Referred tests",
"reject": "Reject",
Expand All @@ -57,7 +56,6 @@
"testsOrdered": "Tests ordered",
"testType": "Test type",
"totalOrders": "Total orders",
"urgencyStatus": "Urgency: ",
"viewTestResults": "View test results",
"worklist": "Worklist",
"Worklist": "Worklist"
Expand Down
Loading

0 comments on commit 47004c0

Please sign in to comment.