From cd23b661f3ef08e9e58c93fd449004ae51bd0019 Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Mon, 4 Mar 2024 19:09:06 +0530 Subject: [PATCH] Adds support for viewing discharged patients of a facility (#7148) * chore: fix type errors * Implements Discharged Patients List route * Add discharged patients view button in facility home * hide live/discharged switch tab for non state admins --- src/Components/Common/components/Menu.tsx | 2 +- .../Facility/DischargedPatientsList.tsx | 102 ++++++++++++++++++ src/Components/Facility/FacilityHome.tsx | 13 +++ src/Components/Patient/ManagePatients.tsx | 17 +-- src/Redux/api.tsx | 7 +- src/Routers/routes/FacilityRoutes.tsx | 4 + 6 files changed, 136 insertions(+), 9 deletions(-) create mode 100644 src/Components/Facility/DischargedPatientsList.tsx diff --git a/src/Components/Common/components/Menu.tsx b/src/Components/Common/components/Menu.tsx index 218e897d3e7..36b250c0423 100644 --- a/src/Components/Common/components/Menu.tsx +++ b/src/Components/Common/components/Menu.tsx @@ -14,7 +14,7 @@ interface DropdownMenuProps { variant?: ButtonVariant; size?: ButtonSize; icon?: JSX.Element | undefined; - children: JSX.Element | JSX.Element[]; + children: ReactNode | ReactNode[]; disabled?: boolean | undefined; className?: string | undefined; itemClassName?: string | undefined; diff --git a/src/Components/Facility/DischargedPatientsList.tsx b/src/Components/Facility/DischargedPatientsList.tsx new file mode 100644 index 00000000000..7ce4e9dc21d --- /dev/null +++ b/src/Components/Facility/DischargedPatientsList.tsx @@ -0,0 +1,102 @@ +import { Link, useQueryParams } from "raviger"; +import routes from "../../Redux/api"; +import Page from "../Common/components/Page"; +import PaginatedList from "../../CAREUI/misc/PaginatedList"; +import Loading from "../Common/Loading"; +import { PatientModel } from "../Patient/models"; +import useQuery from "../../Utils/request/useQuery"; +import { debounce } from "lodash-es"; +import SearchInput from "../Form/SearchInput"; +import { formatAge } from "../../Utils/utils"; +import { GENDER_TYPES } from "../../Common/constants"; +import CareIcon from "../../CAREUI/icons/CareIcon"; +import RecordMeta from "../../CAREUI/display/RecordMeta"; + +const DischargedPatientsList = ({ + facility_external_id, +}: { + facility_external_id: string; +}) => { + const facilityQuery = useQuery(routes.getAnyFacility, { + pathParams: { id: facility_external_id }, + }); + + const [search, setSearch] = useQueryParams(); + + return ( + setSearch({ [e.name]: e.value }), 300)} + /> + } + > + + {() => ( +
+ + No dischaged patients present in this facility + + + + + + + className="grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3"> + {(patient) => ( + + + + )} + + +
+ +
+
+ )} +
+
+ ); +}; + +export default DischargedPatientsList; + +const PatientListItem = ({ patient }: { patient: PatientModel }) => { + return ( +
+
+ +
+
+

{patient.name}

+ + {GENDER_TYPES.find((g) => g.id === patient.gender)?.text} -{" "} + {formatAge(patient.age, patient.date_of_birth)} + +
+ +
+
+ ); +}; diff --git a/src/Components/Facility/FacilityHome.tsx b/src/Components/Facility/FacilityHome.tsx index 4120f4a5469..1c6feee2383 100644 --- a/src/Components/Facility/FacilityHome.tsx +++ b/src/Components/Facility/FacilityHome.tsx @@ -428,6 +428,19 @@ export const FacilityHome = (props: any) => { View Patients + + navigate(`/facility/${facilityId}/discharged-patients`) + } + > + + View Discharged Patients +
diff --git a/src/Components/Patient/ManagePatients.tsx b/src/Components/Patient/ManagePatients.tsx index d853a5cf71a..220165e9e4c 100644 --- a/src/Components/Patient/ManagePatients.tsx +++ b/src/Components/Patient/ManagePatients.tsx @@ -751,13 +751,16 @@ export const PatientManager = () => {
- updateQuery({ is_active: "True" })} - onClickTab2={() => updateQuery({ is_active: "False" })} - isTab2Active={tabValue ? true : false} - /> + {(authUser.user_type === "StateAdmin" || + authUser.user_type === "StateReadOnlyAdmin") && ( + updateQuery({ is_active: "True" })} + onClickTab2={() => updateQuery({ is_active: "False" })} + isTab2Active={tabValue ? true : false} + /> + )} {showDoctorConnect && ( >(), + }, + //Profile checkUsername: { path: "/api/v1/users/{username}/check_availability/", method: "GET", diff --git a/src/Routers/routes/FacilityRoutes.tsx b/src/Routers/routes/FacilityRoutes.tsx index 77247df9189..2c711cf48cb 100644 --- a/src/Routers/routes/FacilityRoutes.tsx +++ b/src/Routers/routes/FacilityRoutes.tsx @@ -8,6 +8,7 @@ import ResourceCreate from "../../Components/Resource/ResourceCreate"; import CentralNursingStation from "../../Components/Facility/CentralNursingStation"; import FacilityLocationRoutes from "./FacilityLocationRoutes"; import FacilityInventoryRoutes from "./FacilityInventoryRoutes"; +import DischargedPatientsList from "../../Components/Facility/DischargedPatientsList"; export default { "/facility": () => , @@ -24,6 +25,9 @@ export default { "/facility/:facilityId": ({ facilityId }: any) => ( ), + "/facility/:id/discharged-patients": ({ id }: any) => ( + + ), "/facility/:facilityId/users": ({ facilityId }: any) => (