Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/ohcnetwork/care_fe into …
Browse files Browse the repository at this point in the history
…quest-ui-redesign
  • Loading branch information
amjithtitus09 committed Feb 20, 2025
2 parents e52aa6c + 0d089c3 commit 3a65239
Show file tree
Hide file tree
Showing 13 changed files with 555 additions and 103 deletions.
522 changes: 474 additions & 48 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "care_fe",
"version": "3.2.0",
"version": "3.3.0",
"description": "Care is a Digital Public Good enabling TeleICU & Decentralised Administration of Healthcare Capacity across States.",
"private": true,
"repository": {
Expand Down Expand Up @@ -95,7 +95,7 @@
"i18next-http-backend": "^3.0.1",
"i18next-resources-to-backend": "^1.2.1",
"input-otp": "^1.4.2",
"jspdf": "^2.5.2",
"jspdf": "^3.0.0",
"libphonenumber-js": "^1.11.18",
"lucide-react": "^0.475.0",
"markdown-it": "^14.1.0",
Expand Down
1 change: 1 addition & 0 deletions public/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2383,6 +2383,7 @@
"view_consultation_and_log_updates": "View Consultation / Log Updates",
"view_dashboard": "View Dashboard",
"view_details": "View Details",
"view_encounter": "View Encounter",
"view_facility": "View Facility",
"view_files": "View Files",
"view_patient": "View Patient",
Expand Down
7 changes: 5 additions & 2 deletions src/PluginEngine.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable i18next/no-literal-string */
import React, { Suspense } from "react";

import ErrorBoundary from "@/components/Common/ErrorBoundary";
Expand Down Expand Up @@ -52,7 +51,11 @@ export function PLUGIN_Component<K extends keyof SupportedPluginComponents>({
return null;
}

return <Component {...props} key={plugin.plugin} />;
return (
<React.Suspense key={plugin.plugin} fallback={<div>Loading...</div>}>
<Component {...props} />
</React.Suspense>
);
})}
</>
);
Expand Down
69 changes: 34 additions & 35 deletions src/Routers/routes/ConsultationRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,50 @@ const consultationRoutes: AppRoutes = {
({ facilityId, encounterId }) => (
<TreatmentSummary facilityId={facilityId} encounterId={encounterId} />
),
"/facility/:facilityId/encounter/:encounterId/:tab": ({
facilityId,
encounterId,
tab,
}) => (
<EncounterShow
facilityId={facilityId}
encounterId={encounterId}
tab={tab}
/>
),
"/facility/:facilityId/encounter/:encounterId/:tab/:subPage": ({
"/facility/:facilityId/patient/:patientId/encounter/:encounterId/questionnaire":
({ facilityId, encounterId, patientId }) => (
<EncounterQuestionnaire
facilityId={facilityId}
encounterId={encounterId}
patientId={patientId}
/>
),
"/facility/:facilityId/patient/:patientId/encounter/:encounterId/questionnaire/:slug":
({ facilityId, encounterId, slug, patientId }) => (
<EncounterQuestionnaire
facilityId={facilityId}
encounterId={encounterId}
questionnaireSlug={slug}
patientId={patientId}
/>
),
"/facility/:facilityId/patient/:patientId/encounter/:encounterId/questionnaire_response/:id":
({ patientId, id }) => (
<QuestionnaireResponseView responseId={id} patientId={patientId} />
),
"/facility/:facilityId/patient/:patientId/encounter/:encounterId/:tab": ({
facilityId,
patientId,
encounterId,
tab,
subPage,
}) => (
<EncounterShow
facilityId={facilityId}
patientId={patientId}
encounterId={encounterId}
tab={tab}
subPage={subPage}
/>
),
"/facility/:facilityId/patient/:patientId/encounter/:encounterId/:tab/:subPage":
({ facilityId, encounterId, patientId, tab, subPage }) => (
<EncounterShow
facilityId={facilityId}
patientId={patientId}
encounterId={encounterId}
tab={tab}
subPage={subPage}
/>
),
"/facility/:facilityId/patient/:patientId/consultation": ({
facilityId,
patientId,
Expand All @@ -63,27 +83,6 @@ const consultationRoutes: AppRoutes = {
subjectType="patient"
/>
),
"/facility/:facilityId/patient/:patientId/encounter/:encounterId/questionnaire":
({ facilityId, encounterId, patientId }) => (
<EncounterQuestionnaire
facilityId={facilityId}
encounterId={encounterId}
patientId={patientId}
/>
),
"/facility/:facilityId/patient/:patientId/encounter/:encounterId/questionnaire/:slug":
({ facilityId, encounterId, slug, patientId }) => (
<EncounterQuestionnaire
facilityId={facilityId}
encounterId={encounterId}
questionnaireSlug={slug}
patientId={patientId}
/>
),
"/facility/:facilityId/patient/:patientId/encounter/:encounterId/questionnaire_response/:id":
({ patientId, id }) => (
<QuestionnaireResponseView responseId={id} patientId={patientId} />
),
};

export default consultationRoutes;
4 changes: 3 additions & 1 deletion src/components/Encounter/CreateEncounterForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ export default function CreateEncounterForm({
form.reset();
queryClient.invalidateQueries({ queryKey: ["encounters", patientId] });
onSuccess?.();
navigate(`/facility/${facilityId}/encounter/${data.id}/updates`);
navigate(
`/facility/${facilityId}/patient/${patientId}/encounter/${data.id}/updates`,
);
},
onError: (error) => {
const errorData = error.cause as { errors: { msg: string[] } };
Expand Down
4 changes: 2 additions & 2 deletions src/components/Facility/EncounterCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ export const EncounterCard = (props: EncounterCardProps) => {
</div>

<Link
href={`/facility/${encounter.facility.id}/encounter/${encounter.id}/updates`}
href={`/facility/${encounter.facility.id}/patient/${encounter.patient.id}/encounter/${encounter.id}/updates`}
className={cn(
buttonVariants({ variant: "secondary" }),
"mt-2 shadow-none border border-secondary-300",
!encounter.period.start && "pointer-events-none opacity-50",
)}
>
<CareIcon icon="l-plus-circle" />
{t("View Encounter")}
{t("view_encounter")}
</Link>
</div>
</>
Expand Down
4 changes: 2 additions & 2 deletions src/components/Files/FilesTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -655,15 +655,15 @@ export const FilesTab = (props: FilesTabProps) => {
<TabsTrigger value="all" asChild>
<Link
className="text-gray-600"
href={`/facility/${encounter?.facility.id}/encounter/${encounter?.id}/files/all`}
href={`/facility/${encounter?.facility.id}/patient/${patientId}/encounter/${encounter?.id}/files/all`}
>
{t("all")}
</Link>
</TabsTrigger>
<TabsTrigger value="discharge_summary" asChild>
<Link
className="text-gray-600"
href={`/facility/${encounter?.facility.id}/encounter/${encounter?.id}/files/discharge_summary`}
href={`/facility/${encounter?.facility.id}/patient/${patientId}/encounter/${encounter?.id}/files/discharge_summary`}
>
{t("discharge_summary")}
</Link>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Patient/EncounterQuestionnaire.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default function EncounterQuestionnaire({
onSubmit={() => {
if (encounterId) {
navigate(
`/facility/${facilityId}/encounter/${encounterId}/updates`,
`/facility/${facilityId}/patient/${patientId}/encounter/${encounterId}/updates`,
);
} else {
navigate(`/patient/${patientId}/updates`);
Expand Down
2 changes: 1 addition & 1 deletion src/components/Patient/PatientInfoCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ export default function PatientInfoCard(props: PatientInfoCardProps) {
</DropdownMenuItem>
<DropdownMenuItem asChild>
<Link
href={`/facility/${encounter.facility.id}/encounter/${encounter.id}/files/discharge_summary`}
href={`/facility/${encounter.facility.id}/patient/${patient.id}/encounter/${encounter.id}/files/discharge_summary`}
className="cursor-pointer text-gray-800"
>
{t("discharge_summary")}
Expand Down
25 changes: 22 additions & 3 deletions src/hooks/useCareApps.ts → src/hooks/useCareApps.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createContext, useContext } from "react";
import { Suspense, createContext, useContext } from "react";

import { EncounterTabProps } from "@/pages/Encounters/EncounterShow";
import { PluginManifest } from "@/pluginTypes";

export const CareAppsContext = createContext<PluginManifest[]>([]);
Expand All @@ -22,11 +23,29 @@ export const useCareApps = () => {
// return navItems;
// };

export const useCareAppConsultationTabs = () => {
const withSuspense = (Component: React.ComponentType<EncounterTabProps>) => {
// eslint-disable-next-line react/display-name
return (props: EncounterTabProps) => {
return (
<Suspense fallback={<div>Loading...</div>}>
<Component {...props} />
</Suspense>
);
};
};

export const useCareAppEncounterTabs = () => {
const careApps = useCareApps();

return careApps.reduce((acc, app) => {
return { ...acc, ...(app.encounterTabs ?? {}) };
const appTabs = Object.entries(app.encounterTabs ?? {}).reduce(
(acc, [key, Component]) => {
return { ...acc, [key]: withSuspense(Component) };
},
{},
);

return { ...acc, ...appTabs };
}, {});
};

Expand Down
2 changes: 1 addition & 1 deletion src/pages/Encounters/EncounterList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ export function EncounterList({
</div>
<Separator className="my-2" />
<Link
href={`/facility/${facilityId}/encounter/${encounter.id}/updates`}
href={`/facility/${facilityId}/patient/${encounter.patient.id}/encounter/${encounter.id}/updates`}
className="text-sm text-primary hover:underline text-right flex items-center justify-end group-hover:translate-x-1 transition-transform"
>
View Details
Expand Down
12 changes: 7 additions & 5 deletions src/pages/Encounters/EncounterShow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import PageTitle from "@/components/Common/PageTitle";
import ErrorPage from "@/components/ErrorPages/DefaultErrorPage";
import PatientInfoCard from "@/components/Patient/PatientInfoCard";

import { useCareAppConsultationTabs } from "@/hooks/useCareApps";
import { useCareAppEncounterTabs } from "@/hooks/useCareApps";

import routes from "@/Utils/request/api";
import query from "@/Utils/request/query";
Expand Down Expand Up @@ -42,16 +42,17 @@ const defaultTabs = {
} as Record<string, React.FC<EncounterTabProps>>;

interface Props {
encounterId: string;
facilityId: string;
patientId: string;
encounterId: string;
tab?: string;
subPage?: string;
}

export const EncounterShow = (props: Props) => {
const { facilityId, encounterId, subPage } = props;
const { facilityId, encounterId, patientId, subPage } = props;
const { t } = useTranslation();
const pluginTabs = useCareAppConsultationTabs();
const pluginTabs = useCareAppEncounterTabs();

const tabs: Record<string, React.FC<EncounterTabProps>> = {
...defaultTabs,
Expand All @@ -64,6 +65,7 @@ export const EncounterShow = (props: Props) => {
pathParams: { id: encounterId },
queryParams: {
facility: facilityId,
patient: patientId,
},
}),
enabled: !!encounterId,
Expand Down Expand Up @@ -169,7 +171,7 @@ export const EncounterShow = (props: Props) => {
<Link
key={tab}
className={tabButtonClasses(props.tab === tab)}
href={`/facility/${facilityId}/encounter/${encounterData.id}/${tab}`}
href={`/facility/${facilityId}/patient/${patientId}/encounter/${encounterData.id}/${tab}`}
>
{t(`ENCOUNTER_TAB__${tab}`)}
</Link>
Expand Down

0 comments on commit 3a65239

Please sign in to comment.