From d2b668def2ca8dbf825a5d50c82daa0cc012c49e Mon Sep 17 00:00:00 2001 From: Jacob John Jeevan Date: Thu, 23 Jan 2025 17:21:17 +0530 Subject: [PATCH] rm appointments and render sep list for patients accessed from org --- public/locale/en.json | 1 + src/Routers/routes/PatientRoutes.tsx | 14 ++++++-- .../Patient/PatientDetailsTab/Demography.tsx | 10 ++++-- .../Patient/PatientDetailsTab/index.tsx | 17 ++++++--- src/components/Patient/PatientHome.tsx | 35 ++++++++++++------- .../Patient/PatientRegistration.tsx | 14 ++++---- 6 files changed, 63 insertions(+), 28 deletions(-) diff --git a/public/locale/en.json b/public/locale/en.json index ebc08cff712..3748ce6a985 100644 --- a/public/locale/en.json +++ b/public/locale/en.json @@ -1452,6 +1452,7 @@ "no_tests_taken": "No tests taken", "no_treating_physicians_available": "This facility does not have any home facility doctors. Please contact your admin.", "no_update_available": "No update available", + "no_updates_found": "No updates found", "no_user_assigned": "No User Assigned to this patient", "no_users_found": "No Users Found", "no_vitals_present": "No Vitals Monitor present in this location or facility", diff --git a/src/Routers/routes/PatientRoutes.tsx b/src/Routers/routes/PatientRoutes.tsx index 77ede2c44a9..77230f3ee76 100644 --- a/src/Routers/routes/PatientRoutes.tsx +++ b/src/Routers/routes/PatientRoutes.tsx @@ -1,5 +1,8 @@ import FileUploadPage from "@/components/Patient/FileUploadPage"; -import { patientTabs } from "@/components/Patient/PatientDetailsTab"; +import { + facilityPatientTabs, + patientTabs, +} from "@/components/Patient/PatientDetailsTab"; import { PatientHome } from "@/components/Patient/PatientHome"; import PatientIndex from "@/components/Patient/PatientIndex"; import PatientRegistration from "@/components/Patient/PatientRegistration"; @@ -19,13 +22,20 @@ const PatientRoutes: AppRoutes = { ), "/patient/:id": ({ id }) => , + "/patient/:id/update": ({ id }) => , + ...patientTabs.reduce((acc: AppRoutes, tab) => { + acc["/patient/:id/" + tab.route] = ({ id }) => ( + + ); + return acc; + }, {}), "/facility/:facilityId/patient/create": ({ facilityId }) => ( ), "/facility/:facilityId/patient/:id": ({ facilityId, id }) => ( ), - ...patientTabs.reduce((acc: AppRoutes, tab) => { + ...facilityPatientTabs.reduce((acc: AppRoutes, tab) => { acc["/facility/:facilityId/patient/:id/" + tab.route] = ({ facilityId, id, diff --git a/src/components/Patient/PatientDetailsTab/Demography.tsx b/src/components/Patient/PatientDetailsTab/Demography.tsx index aa00d2e1c27..83ab0dfe242 100644 --- a/src/components/Patient/PatientDetailsTab/Demography.tsx +++ b/src/components/Patient/PatientDetailsTab/Demography.tsx @@ -37,9 +37,13 @@ export const Demography = (props: PatientProps) => { }; const handleEditClick = (sectionId: string) => { - navigate( - `/facility/${facilityId}/patient/${id}/update?section=${sectionId}`, - ); + if (facilityId) { + navigate( + `/facility/${facilityId}/patient/${id}/update?section=${sectionId}`, + ); + } else { + navigate(`/patient/${id}/update?section=${sectionId}`); + } }; const hasEditPermission = () => { diff --git a/src/components/Patient/PatientDetailsTab/index.tsx b/src/components/Patient/PatientDetailsTab/index.tsx index 38d01b06870..e71875ab441 100644 --- a/src/components/Patient/PatientDetailsTab/index.tsx +++ b/src/components/Patient/PatientDetailsTab/index.tsx @@ -16,15 +16,11 @@ export interface PatientProps { patientData: Patient; } -export const patientTabs = [ +const commonTabs = [ { route: "demography", component: Demography, }, - { - route: "appointments", - component: Appointments, - }, { route: "encounters", component: EncounterHistory, @@ -50,3 +46,14 @@ export const patientTabs = [ component: PatientFilesTab, }, ]; + +export const facilityPatientTabs = [ + commonTabs[0], + { + route: "appointments", + component: Appointments, + }, + ...commonTabs.slice(1), +]; + +export const patientTabs = [...commonTabs]; diff --git a/src/components/Patient/PatientHome.tsx b/src/components/Patient/PatientHome.tsx index 4108d80eb34..9ef33229574 100644 --- a/src/components/Patient/PatientHome.tsx +++ b/src/components/Patient/PatientHome.tsx @@ -9,7 +9,10 @@ import { Button } from "@/components/ui/button"; import { Avatar } from "@/components/Common/Avatar"; import Loading from "@/components/Common/Loading"; import Page from "@/components/Common/Page"; -import { patientTabs } from "@/components/Patient/PatientDetailsTab"; +import { + facilityPatientTabs, + patientTabs, +} from "@/components/Patient/PatientDetailsTab"; import { PLUGIN_Component } from "@/PluginEngine"; import routes from "@/Utils/request/api"; @@ -20,7 +23,7 @@ import { Patient } from "@/types/emr/newPatient"; export const PatientHome = (props: { facilityId?: string; id: string; - page: (typeof patientTabs)[0]["route"]; + page: (typeof patientTabs | typeof facilityPatientTabs)[0]["route"]; }) => { const { facilityId, id, page } = props; @@ -40,7 +43,9 @@ export const PatientHome = (props: { return ; } - const Tab = patientTabs.find((t) => t.route === page)?.component; + const tabs = facilityId ? facilityPatientTabs : patientTabs; + + const Tab = tabs.find((t) => t.route === page)?.component; if (!patientData) { return
{t("patient_not_found")}
; @@ -51,13 +56,15 @@ export const PatientHome = (props: { title={t("patient_details")} options={ <> - + {facilityId && ( + + )} } > @@ -99,10 +106,14 @@ export const PatientHome = (props: { role="navigation" >
- {patientTabs.map((tab) => ( + {tabs.map((tab) => (