Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

status:Filter lab orders by status #48

Merged
merged 4 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 53 additions & 15 deletions src/queue-list/laboratory-patient-list.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,16 @@ import {
TableBody,
TableCell,
TableContainer,
TableExpandHeader,
TableExpandRow,
OverflowMenuItem,
OverflowMenu,
TableHead,
TableHeader,
TableRow,
Dropdown,
TabPanel,
TableToolbar,
TableToolbarContent,
TableToolbarSearch,
Layer,
Tag,
TableExpandedRow,
Tile,
Button,
DatePicker,
Expand All @@ -35,9 +31,7 @@ import {
formatDate,
formatDatetime,
parseDate,
showModal,
usePagination,
useSession,
} from "@openmrs/esm-framework";
import styles from "./laboratory-queue.scss";
import { getStatusColor } from "../utils/functions";
Expand All @@ -53,21 +47,55 @@ interface RejectOrderProps {
const LaboratoryPatientList: React.FC<LaboratoryPatientListProps> = () => {
const { t } = useTranslation();

const OrderStatuses = [
"All",
"RECEIVED",
"IN_PROGRESS",
"COMPLETED",
"EXCEPTION",
"ON_HOLD",
"DECLINED",
];

const [activatedOnOrAfterDate, setActivatedOnOrAfterDate] = useState("");

const [filter, setFilter] = useState<
gitcliff marked this conversation as resolved.
Show resolved Hide resolved
| "All"
| "EXCEPTION"
| "RECEIVED"
| "COMPLETED"
| "IN_PROGRESS"
| "ON_HOLD"
| "DECLINED"
>("All");

const { workListEntries, isLoading } = useGetOrdersWorklist(
activatedOnOrAfterDate,
""
);

const filteredStatus = useMemo(() => {
if (!filter || filter == "All") {
return workListEntries;
}

if (filter) {
return workListEntries?.filter(
(order) => order.fulfillerStatus === filter
);
}

return workListEntries;
}, [filter, workListEntries]);

const pageSizes = [10, 20, 30, 40, 50];
const [currentPageSize, setPageSize] = useState(10);

const {
goTo,
results: paginatedWorklistQueueEntries,
currentPage,
} = usePagination(workListEntries, currentPageSize);
} = usePagination(filteredStatus, currentPageSize);
// get picked orders
let columns = [
{ id: 0, header: t("date", "Date"), key: "date" },
Expand All @@ -88,6 +116,8 @@ const LaboratoryPatientList: React.FC<LaboratoryPatientListProps> = () => {
{ id: 10, header: t("actions", "Actions"), key: "actions" },
];

const handleOrderStatusChange = ({ selectedItem }) => setFilter(selectedItem);

const tableRows = useMemo(() => {
return paginatedWorklistQueueEntries
?.filter((item) => item.action === "NEW")
Expand Down Expand Up @@ -187,6 +217,21 @@ const LaboratoryPatientList: React.FC<LaboratoryPatientListProps> = () => {
}}
>
<TableToolbarContent>
<Layer style={{ margin: "5px" }}>
<Dropdown
id="orderStatus"
initialSelectedItem={"All"}
label=""
titleText={
t("filterOrdersByStatus", "Filter Orders by status") +
":"
}
type="inline"
items={OrderStatuses}
onChange={handleOrderStatusChange}
/>
</Layer>

<Layer style={{ margin: "5px" }}>
<DatePicker dateFormat="Y-m-d" datePickerType="single">
<DatePickerInput
Expand All @@ -201,13 +246,6 @@ const LaboratoryPatientList: React.FC<LaboratoryPatientListProps> = () => {
/>
</DatePicker>
</Layer>
<Layer>
<TableToolbarSearch
onChange={onInputChange}
placeholder={t("searchThisList", "Search this list")}
size="sm"
/>
</Layer>
</TableToolbarContent>
</TableToolbar>
<Table
Expand Down
3 changes: 2 additions & 1 deletion translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
"waitingTime": "Waiting time",
"worklist": "Worklist",
"rejectOrder": "Reject Order",
"pickLabRequest": "Pick Lab Request"
"pickLabRequest": "Pick Lab Request",
"filterOrdersByStatus": "Filter Orders by status"
}
Loading