Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes certain users from being unable to view an encounter from organizations patients #10688

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions public/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2374,6 +2374,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
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
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
8 changes: 5 additions & 3 deletions src/pages/Encounters/EncounterShow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ 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();

Expand All @@ -64,6 +65,7 @@ export const EncounterShow = (props: Props) => {
pathParams: { id: encounterId },
queryParams: {
facility: facilityId,
patient: patientId,
Copy link
Contributor

@Jacobjeevan Jacobjeevan Feb 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding the note here so we don't forget:

  • we will need to modify BE as adding patientId here bypasses current permissions.
  • currently when patientId is present, it's checking against patient permissions
    • if not, it checks if facilityId is present (and against encounter permissions).

},
}),
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
Loading