fix(encounters): name the practice address on an appointment nudge again

Sealing the practitioner's address left the appointment arm reading the old
readable column, which is now empty, so a booked visit's push lost the address
on booking, rescheduling and restoring a deleted visit.

The reminder no longer keeps its own copy of the address. The reminder tick
resolves it from the owning visit's practitioner when it builds the push and
decrypts it there, so an edit of the address also reaches a nudge that is
already booked. MeasurementReminder.location stays NULL on appointment rows:
booking writes none, a re-anchor clears one an earlier release wrote, and a
backup neither carries nor restores one. A checkup's own free-text location is
unchanged.
This commit is contained in:
Marc-André Bombeck committed 2026-09-27 13:07:10 +02:00
1 parent 9892088620
commit 3482581ce1
10 files changed
+310 -21

No files matched your search

@@ -70,7 +70,6 @@ export const POST = apiHandler(
userId: user.id,
occurredAt: existing.occurredAt,
practitionerName: existing.practitioner?.name ?? null,
practitionerLocation: existing.practitioner?.location ?? null,
kindLabel: encounterKindLabel(existing.kind, locale),
},
timezone,
-5
View File
@@ -130,7 +130,6 @@ export const PATCH = apiHandler(
const visible = await actingDomainVisibility(tx, grantId);
let practitionerId = existing.practitionerId;
let practitionerName: string | null = null;
let practitionerLocation: string | null = null;
if (entry.practitionerId !== undefined) {
if (entry.practitionerId === null) {
@@ -144,7 +143,6 @@ export const PATCH = apiHandler(
if (!resolved) return "unknown-practitioner" as const;
practitionerId = resolved.id;
practitionerName = resolved.name;
practitionerLocation = resolved.location;
}
} else if (practitionerId) {
const resolved = await resolveOwnedPractitioner(
@@ -153,7 +151,6 @@ export const PATCH = apiHandler(
practitionerId,
);
practitionerName = resolved?.name ?? null;
practitionerLocation = resolved?.location ?? null;
}
const data: Prisma.EncounterUpdateInput = {};
@@ -206,7 +203,6 @@ export const PATCH = apiHandler(
userId: user.id,
occurredAt: nextOccurredAt,
practitionerName,
practitionerLocation,
kindLabel: encounterKindLabel(entry.kind ?? existing.kind, locale),
status: nextStatus,
existingReminderId: ownAppointmentReminderId,
@@ -222,7 +218,6 @@ export const PATCH = apiHandler(
userId: user.id,
occurredAt: nextOccurredAt,
practitionerName,
practitionerLocation,
kindLabel: encounterKindLabel(entry.kind ?? existing.kind, locale),
status: nextStatus,
existingReminderId: ownAppointmentReminderId,
+1 -3
View File
@@ -195,8 +195,7 @@ async function postEncounter(request: NextRequest): Promise<Response> {
// A practitioner the caller does not own is a refusal rather than a
// silently dropped field: the person named a practice and would otherwise
// see the visit save without it.
let practitioner:
{ id: string; name: string; location: string | null } | undefined;
let practitioner: { id: string; name: string } | undefined;
if (entry.practitionerId) {
practitioner = await resolveOwnedPractitioner(
tx,
@@ -241,7 +240,6 @@ async function postEncounter(request: NextRequest): Promise<Response> {
userId: user.id,
occurredAt,
practitionerName: practitioner?.name ?? null,
practitionerLocation: practitioner?.location ?? null,
kindLabel: encounterKindLabel(entry.kind, locale),
status: entry.status,
existingReminderId: null,