Skip to content

Commit

Permalink
Enhanced :removed the start button under worklist tab (#89)
Browse files Browse the repository at this point in the history
* removed the start button under in progress tab

* renamed displayposition to order
  • Loading branch information
FelixKiprotich350 authored Aug 8, 2024
1 parent e28a92e commit f7de99a
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 125 deletions.
102 changes: 4 additions & 98 deletions src/radiology-tabs/common/listOrderDetails.component.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import React, { useMemo, useState } from "react";
import React, { useMemo } from "react";
import styles from "./listOrderDetails.scss";

import { useTranslation } from "react-i18next";
import {
formatDate,
openmrsFetch,
parseDate,
restBaseUrl,
showModal,
showSnackbar,
} from "@openmrs/esm-framework";
import { formatDate, parseDate, showModal } from "@openmrs/esm-framework";
import { ListOrdersDetailsProps } from "./radiologyProps.resource";
import { launchOverlay } from "../../components/overlay/hook";
import ProcedureReportForm from "../../results/result-form.component";
Expand Down Expand Up @@ -40,87 +33,6 @@ const ListOrderDetails: React.FC<ListOrdersDetailsProps> = (props) => {
}));
}, [orders]);

const StartOrder = ({ order }) => {
const [buttonStyle, setButtonStyle] = useState({
backgroundColor: "#cccccc",
width: "10%",
height: "2%",
});
const [isButtonDisabled, setIsButtonDisabled] = useState(false);

const handleStartClick = async () => {
const body = {
fulfillerComment: "",
fulfillerStatus: "IN_PROGRESS",
};

try {
const response = await openmrsFetch(
`${restBaseUrl}/order/${order.uuid}/fulfillerdetails`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(body),
}
);

if (response.status === 201) {
// Check for successful POST
showSnackbar({
isLowContrast: true,
title: t(
"statusUpdatedSuccessfully",
"Status updated successfully"
),
kind: "success",
});

// Update button style on successful POST
setButtonStyle({
backgroundColor: "#90EE90",
width: "10%",
height: "2%",
});

setIsButtonDisabled(true);
} else {
const errorData = await response.json();
showSnackbar({
isLowContrast: true,
title: t("errorUpdatingStatus", "Error updating status"),
subtitle: t("failedtoupdatestatus", "Failed to Update the Status"),
kind: "error",
});
}
} catch (error) {
showSnackbar({
isLowContrast: true,
title: t("errorUpdatingStatus", "Error updating status"),
subtitle:
t("failedtoupdatestatus", "Failed to Update the Status: ") +
error.message,
kind: "error",
});
}
};

return (
<div>
<Button
kind="primary"
size="small"
onClick={handleStartClick}
style={buttonStyle}
disabled={isButtonDisabled} // Set the button's disabled status
>
START
</Button>
</div>
);
};

return (
<div className={styles.ordersContainer}>
{orderrows.map((row) => (
Expand All @@ -130,8 +42,8 @@ const ListOrderDetails: React.FC<ListOrdersDetailsProps> = (props) => {
{props.actions
.sort((a, b) => {
// Replace 'property' with the actual property you want to sort by
if (a.displayPosition < b.displayPosition) return -1;
if (a.displayPosition > b.displayPosition) return 1;
if (a.order < b.order) return -1;
if (a.order > b.order) return 1;
return 0;
})
.map((action) => {
Expand Down Expand Up @@ -272,12 +184,6 @@ const ListOrderDetails: React.FC<ListOrdersDetailsProps> = (props) => {
label={t("instructions", "Instructions").toUpperCase()}
value={row.instructions}
/>

{props.showStartButton && (
<div>
<StartOrder order={row} />
</div>
)}
</div>
</Tile>
))}
Expand Down
2 changes: 1 addition & 1 deletion src/radiology-tabs/common/radiologyProps.resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ export interface ListOrdersDetailsProps {

export interface OrderAction {
actionName: string;
displayPosition: 0 | number;
order: 0 | number;
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const OrdersNotDone: React.FC<NotDoneProps> = ({ fulfillerStatus }) => {
actions={[
{
actionName: "radiology-reject-reason-modal",
displayPosition: 1,
order: 1,
},
]}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ export const Review: React.FC = () => {
showStartButton={false}
showActions={true}
showOrderType={true}
actions={[
{ actionName: "review-radilogy-report-dialog", displayPosition: 1 },
]}
actions={[{ actionName: "review-radilogy-report-dialog", order: 1 }]}
/>
</div>
);
Expand Down
38 changes: 18 additions & 20 deletions src/radiology-tabs/test-ordered/tests-ordered.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,22 @@ export const TestsOrdered: React.FC = () => {
if (isLoading) {
return <DataTableSkeleton />;
}
if (workListEntries.length > 0) {
return (
<div>
<GroupedOrdersTable
orders={workListEntries}
showStatus={true}
showStartButton={false}
showActions={true}
showOrderType={false}
actions={[
{
actionName: "add-radiology-to-worklist-dialog",
displayPosition: 1,
},
{ actionName: "reject-radiology-order-dialog", displayPosition: 2 },
]}
/>
</div>
);
}
return (
<div>
<GroupedOrdersTable
orders={workListEntries}
showStatus={true}
showStartButton={false}
showActions={true}
showOrderType={false}
actions={[
{
actionName: "add-radiology-to-worklist-dialog",
order: 1,
},
{ actionName: "reject-radiology-order-dialog", order: 2 },
]}
/>
</div>
);
};
4 changes: 2 additions & 2 deletions src/radiology-tabs/work-list/work-list.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ const WorkList: React.FC<WorklistProps> = ({ fulfillerStatus }) => {
showActions={true}
showOrderType={false}
actions={[
{ actionName: "procedureReportForm", displayPosition: 1 },
{ actionName: "procedureReportForm", order: 1 },
{
actionName: "reject-radiology-order-dialog",
displayPosition: 2,
order: 2,
},
]}
/>
Expand Down

0 comments on commit f7de99a

Please sign in to comment.