diff --git a/src/ordered-orders/laboratory-tabs.component.tsx b/src/ordered-orders/laboratory-tabs.component.tsx index 61135b95..041d1b30 100644 --- a/src/ordered-orders/laboratory-tabs.component.tsx +++ b/src/ordered-orders/laboratory-tabs.component.tsx @@ -6,7 +6,7 @@ import { } from "@openmrs/esm-framework"; import { Tab, Tabs, TabList, TabPanels, TabPanel, Search } from "@carbon/react"; import { useTranslation } from "react-i18next"; -import styles from "./laboratory-queue.scss"; +import styles from "./tests-ordered.scss"; import TestsOrderedList from "./tests-ordered-list.component"; import { ComponentContext } from "@openmrs/esm-framework/src/internal"; diff --git a/src/ordered-orders/tests-ordered-list.component.tsx b/src/ordered-orders/tests-ordered-list.component.tsx index 2b07a9c2..7f8c86fa 100644 --- a/src/ordered-orders/tests-ordered-list.component.tsx +++ b/src/ordered-orders/tests-ordered-list.component.tsx @@ -8,18 +8,32 @@ import { TableHead, TableHeader, TableRow, + Tag, + InlineLoading, + Tile, + Pagination, } from "@carbon/react"; import { useTranslation } from "react-i18next"; import { usePagination, useSession } from "@openmrs/esm-framework"; -import styles from "./laboratory-queue.scss"; +import styles from "./tests-ordered.scss"; import { usePatientQueuesList } from "./tests-ordered-list.resource"; +import { + formatWaitTime, + getTagColor, + trimVisitNumber, +} from "../utils/functions"; const TestsOrderedList: React.FC = () => { const { t } = useTranslation(); const session = useSession(); - const { patientQueueEntries, isLoading } = usePatientQueuesList( + const { + patientQueueEntries, + isLoading, + isError: error, + mutate, + } = usePatientQueuesList( session?.sessionLocation?.uuid, status, session.user.systemId @@ -33,74 +47,138 @@ const TestsOrderedList: React.FC = () => { currentPage, } = usePagination(patientQueueEntries, currentPageSize); - // get patients in queue - let columns = [ - { id: 0, header: t("visitId", "Visit ID"), key: "visitId" }, - { id: 1, header: t("patientNumber", "Patient No."), key: "patientNumber" }, - { id: 2, header: t("names", "Name"), key: "patient" }, - { id: 3, header: t("age", "Age"), key: "age" }, - { id: 4, header: t("orderedFrom", "Ordered From"), key: "orderedFrom" }, - { id: 5, header: t("waitingTime", "Waiting Time"), key: "waitingTime" }, - { - id: 6, - header: t("testsOrdered", "Test(s) Ordered"), - key: "testsOrdered", - }, - ]; + const tableHeaders = useMemo( + () => [ + { id: 0, header: t("visitId", "Visit ID"), key: "visitId" }, + { + id: 1, + header: t("patientNumber", "Patient No."), + key: "patientNumber", + }, + { id: 2, header: t("names", "Name"), key: "patient" }, + { id: 3, header: t("age", "Age"), key: "age" }, + { id: 4, header: t("orderedFrom", "Ordered From"), key: "orderedFrom" }, + { id: 5, header: t("waitingTime", "Waiting Time"), key: "waitingTime" }, + { + id: 6, + header: t("testsOrdered", "Test(s) Ordered"), + key: "testsOrdered", + }, + ], + [t] + ); const tableRows = useMemo(() => { - return paginatedQueueEntries.map((entry, index) => { - return { - ...entry, - visitId: entry?.uuid, - patientNumber: entry.patient?.identifiers[0].display, - names: entry?.patient?.display.split("-")[1], - age: "", - orderedFrom: "", - waitingTime: "", - testsOrdered: "", - }; - }); - }, []); + console.log( + "paginatedQueueEntries--->" + + JSON.stringify(paginatedQueueEntries, null, 2) + ); + return paginatedQueueEntries?.map((entry) => ({ + ...entry, + id: entry.id, + visitId: { + content: {trimVisitNumber(entry.visitNumber)}, + }, + patientNumber: { + content: {entry?.identifiers[0]?.display}, + }, + names: { + content: {entry?.name}, + }, + age: { + content: {entry?.patientAge}, + }, + orderedFrom: { + content: {entry?.locationFrom}, + }, + waitingTime: { + content: ( + + + {formatWaitTime(entry.waitTime, t)} + + + ), + }, + testsOrdered: "", + })); + }, [paginatedQueueEntries]); + + if (isLoading) { + return ; + } return ( - - {({ rows, headers, getHeaderProps, getTableProps, getRowProps }) => ( - - - - - {headers.map((header) => ( - - {header.header?.content ?? header.header} - - ))} - - - - {rows.map((row) => { - return ( - - - {row.cells.map((cell) => ( - - {cell.value?.content ?? cell.value} - - ))} - - - ); - })} - -
-
- )} -
+
+ + {({ rows, headers, getHeaderProps, getTableProps, getRowProps }) => ( + + + + + {headers.map((header) => ( + + {header.header} + + ))} + + + + {rows?.map((row) => { + return ( + + + {row.cells.map((cell) => ( + + {cell.value?.content ?? cell?.value} + + ))} + + + ); + })} + +
+ {rows.length === 0 ? ( +
+ +
+

+ {t("noPatientsToDisplay", "No patients to display")} +

+
+
+
+ ) : null} + { + if (pageSize !== currentPageSize) { + setPageSize(pageSize); + } + if (page !== currentPage) { + goTo(page); + } + }} + /> +
+ )} +
+
); }; diff --git a/src/ordered-orders/laboratory-queue.scss b/src/ordered-orders/tests-ordered.scss similarity index 97% rename from src/ordered-orders/laboratory-queue.scss rename to src/ordered-orders/tests-ordered.scss index e1c26255..0d0d7e85 100644 --- a/src/ordered-orders/laboratory-queue.scss +++ b/src/ordered-orders/tests-ordered.scss @@ -214,4 +214,13 @@ title { .single-line-display { white-space: nowrap; +} + +.statusContainer { + display: flex; + align-items: center; + + svg { + margin-right: 0.5rem; + } } \ No newline at end of file diff --git a/src/reject-order/rejected-tests-list.component.tsx b/src/reject-order/rejected-tests-list.component.tsx index fb218bc4..ab2e6489 100644 --- a/src/reject-order/rejected-tests-list.component.tsx +++ b/src/reject-order/rejected-tests-list.component.tsx @@ -19,7 +19,7 @@ import { import { useTranslation } from "react-i18next"; import { formatDate, parseDate, usePagination } from "@openmrs/esm-framework"; -import styles from "../tests-ordered/laboratory-queue.scss"; +import styles from "../ordered-orders/tests-ordered.scss"; import { useGetOrdersWorklist } from "../worklist-orders/work-list.resource"; import { useOrderDate } from "../utils/functions";