Skip to content

Commit

Permalink
Patient Detail Tabs: Org List Access (#10121)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacobjeevan authored Jan 29, 2025
1 parent 9b6dcbd commit dcf2bb9
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 23 deletions.
1 change: 1 addition & 0 deletions public/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1368,6 +1368,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",
Expand Down
14 changes: 12 additions & 2 deletions src/Routers/routes/PatientRoutes.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -19,13 +22,20 @@ const PatientRoutes: AppRoutes = {
<VerifyPatient facilityId={facilityId} />
),
"/patient/:id": ({ id }) => <PatientHome id={id} page="demography" />,
"/patient/:id/update": ({ id }) => <PatientRegistration patientId={id} />,
...patientTabs.reduce((acc: AppRoutes, tab) => {
acc["/patient/:id/" + tab.route] = ({ id }) => (
<PatientHome id={id} page={tab.route} />
);
return acc;
}, {}),
"/facility/:facilityId/patient/create": ({ facilityId }) => (
<PatientRegistration facilityId={facilityId} />
),
"/facility/:facilityId/patient/:id": ({ facilityId, id }) => (
<PatientHome facilityId={facilityId} id={id} page="demography" />
),
...patientTabs.reduce((acc: AppRoutes, tab) => {
...facilityPatientTabs.reduce((acc: AppRoutes, tab) => {
acc["/facility/:facilityId/patient/:id/" + tab.route] = ({
facilityId,
id,
Expand Down
10 changes: 7 additions & 3 deletions src/components/Patient/PatientDetailsTab/Demography.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down
31 changes: 31 additions & 0 deletions src/components/Patient/PatientDetailsTab/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,37 @@ export interface PatientProps {
}

export const patientTabs = [
{
route: "demography",
component: Demography,
},
{
route: "encounters",
component: EncounterHistory,
},
{
route: "health-profile",
component: HealthProfileSummary,
},
{
route: "updates",
component: Updates,
},
{
route: "resource_requests",
component: ResourceRequests,
},
{
route: "users",
component: PatientUsers,
},
{
route: "files",
component: PatientFilesTab,
},
];

export const facilityPatientTabs = [
{
route: "demography",
component: Demography,
Expand Down
35 changes: 23 additions & 12 deletions src/components/Patient/PatientHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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;

Expand All @@ -40,7 +43,9 @@ export const PatientHome = (props: {
return <Loading />;
}

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 <div>{t("patient_not_found")}</div>;
Expand All @@ -51,13 +56,15 @@ export const PatientHome = (props: {
title={t("patient_details")}
options={
<>
<Button asChild variant="primary">
<Link
href={`/facility/${facilityId}/patient/${id}/book-appointment`}
>
{t("schedule_appointment")}
</Link>
</Button>
{facilityId && (
<Button asChild variant="primary">
<Link
href={`/facility/${facilityId}/patient/${id}/book-appointment`}
>
{t("schedule_appointment")}
</Link>
</Button>
)}
</>
}
>
Expand Down Expand Up @@ -99,10 +106,14 @@ export const PatientHome = (props: {
role="navigation"
>
<div className="flex flex-row" role="tablist">
{patientTabs.map((tab) => (
{tabs.map((tab) => (
<Link
key={tab.route}
href={`/facility/${facilityId}/patient/${id}/${tab.route}`}
href={
facilityId
? `/facility/${facilityId}/patient/${id}/${tab.route}`
: `/patient/${id}/${tab.route}`
}
className={`whitespace-nowrap px-4 py-2 text-sm font-medium ${
page === tab.route
? "border-b-4 border-green-800 text-green-800 md:border-b-2"
Expand Down
14 changes: 8 additions & 6 deletions src/components/Patient/PatientRegistration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ import { PatientModel } from "@/types/emr/patient";
import { Organization } from "@/types/organization/organization";

interface PatientRegistrationPageProps {
facilityId: string;
facilityId?: string;
patientId?: string;
}

Expand Down Expand Up @@ -219,11 +219,13 @@ export default function PatientRegistration(
return;
}

createPatient({
...values,
facility: facilityId,
ward_old: undefined,
});
if (facilityId) {
createPatient({
...values,
facility: facilityId,
ward_old: undefined,
});
}
}

const sidebarItems = [
Expand Down

0 comments on commit dcf2bb9

Please sign in to comment.