refactor(visits): build every link to a visit in one place

Seven surfaces spelled `/checkups?visit=<id>` by hand, some encoding
the id and some not. They now share `visitPath()` from
`src/lib/encounters/visit-links.ts`, the place the next fix extends.
No behaviour change: a cuid encodes to itself.
This commit is contained in:
Marc-André Bombeck committed 2026-10-21 12:22:22 +02:00
1 parent 421aacf457
commit 78bacb0d86
9 files changed
+41 -7

No files matched your search

@@ -50,6 +50,7 @@ import { queryKeys } from "@/lib/query-keys";
import type { EncounterDTO, EncounterListDTO } from "@/lib/encounters/dto";
import type { EncounterKind } from "@/generated/prisma/client";
import type { InboundDocumentDetailDto } from "@/lib/validations/inbound-documents";
import { visitPath } from "@/lib/encounters/visit-links";
type Translate = ReturnType<typeof useTranslations>["t"];
@@ -109,7 +110,7 @@ export async function fetchEncounterPage(
/** Where a visit opens: its sheet on the checkups page. */
function visitHref(encounterId: string): string {
return `/checkups?visit=${encodeURIComponent(encounterId)}`;
return visitPath(encounterId);
}
/** Where a dose opens: its sheet on the vaccinations page. */
+2 -1
View File
@@ -64,6 +64,7 @@ import type { IllnessEpisodeDTO } from "@/lib/illness/dto";
import type { RelatedLink } from "@/lib/links/related";
import type { EncounterKind } from "@/generated/prisma/client";
import { translateOrNull } from "@/lib/i18n/translate-code";
import { visitPath } from "@/lib/encounters/visit-links";
type Translate = ReturnType<typeof useTranslations>["t"];
type RelatedKind = RelatedLink["kind"];
@@ -311,7 +312,7 @@ function VisitPicker({ selected, onChange, anchor, known }: PickerProps) {
label: encounterKindText(t, visit.kind as EncounterKind),
meta: visit.practitioner?.name ?? null,
occurredAt: visit.occurredAt,
href: `/checkups?visit=${encodeURIComponent(visit.id)}`,
href: visitPath(visit.id),
})),
anchor,
{