fix(body-sites): skip the site suggestions read without the visits section

A delegate who may keep the illness journal but not read the visits
would be refused by GET /api/body-sites on every open of the condition
form, and each refusal writes an access-denied row. The field now asks
only when the grant covers the visits' section, and the condition page
shows the site as text rather than a link in that case.

Refs #1025
This commit is contained in:
Marc-André Bombeck committed 2026-09-25 22:08:30 +02:00
1 parent 14f0fc4d4f
commit 645032ec97
4 files changed
+41 -7

No files matched your search

@@ -22,6 +22,7 @@ import { PageHeader } from "@/components/ui/page-header";
import { Skeleton } from "@/components/ui/skeleton";
import { useTranslations, useFormatters } from "@/lib/i18n/context";
import { bodySiteText } from "@/components/encounters/encounter-labels";
import { canReadBodySites } from "@/hooks/use-body-sites";
import { IllnessCorrelationCard } from "./illness-correlation-card";
import { IllnessDayTimeline } from "./illness-day-timeline";
@@ -46,7 +47,7 @@ export function IllnessEpisodeDetail({ episodeId }: { episodeId: string }) {
const { canManageDomain, sections } = useRecordCapabilities();
// The body-site view is read in the visits' section; a grant without it
// gets the site as text rather than a link that would be refused.
const canOpenBodySites = sections === null || sections.includes("profile");
const canOpenBodySites = canReadBodySites(sections);
const canManageIllness = canManageDomain("illness");
const fmt = useFormatters();
const {