mirror of
https://github.com/bitbaum/vitareba.git
synced 2026-12-06 02:48:37 +01:00
fix(weekly-digest): only show pending/confirmed bookings as next consultation
Bookings query was fetching the most recent booking regardless of status. Patients who had completed or cancelled their latest booking would see "Your next consultation is attended" in the weekly digest email — confusing and inaccurate. Filter to pending/confirmed only so the booking section is omitted when there is no upcoming appointment. Also replace raw <a href="/admin/patients/..."> in reports page adherence table with <Link> + ADMIN_ROUTES.patients for SSOT consistency (same URL was already using ADMIN_ROUTES on line 332 of the same file). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
a3add5b5ad
commit
2fa7290976
2 files changed
+6
-2
No files matched your search
@@ -387,9 +387,9 @@ export default async function ReportsPage() {
|
||||
return (
|
||||
<tr key={id} className={styles.adherenceRow}>
|
||||
<td className={styles.adherenceName}>
|
||||
<a href={`/admin/patients/${id}`} className={styles.adherenceLink}>
|
||||
<Link href={`${ADMIN_ROUTES.patients}/${id}`} className={styles.adherenceLink}>
|
||||
{name}
|
||||
</a>
|
||||
</Link>
|
||||
</td>
|
||||
<td className={styles.adherenceSignalCell}>
|
||||
<span className={styles.signalBadge} data-signal={signal}>
|
||||
|
||||
@@ -12,6 +12,7 @@ import { formatDateISO, displayName } from "@/lib/utils/format";
|
||||
import { USER_ROLE } from "@/lib/config/auth";
|
||||
import { requireCron } from "@/lib/auth/guards";
|
||||
import { CHECKIN_METRICS, type MetricKey } from "@/lib/config/portal";
|
||||
import { BOOKING_STATUS } from "@/lib/config/booking-status";
|
||||
|
||||
function avgMetrics(checkins: Array<Record<MetricKey, number>>): Record<MetricKey, number> | null {
|
||||
if (checkins.length === 0) return null;
|
||||
@@ -47,7 +48,10 @@ export async function GET(req: Request) {
|
||||
orderBy: [desc(assessmentResults.completedAt)],
|
||||
limit: 1,
|
||||
},
|
||||
// Only fetch pending/confirmed bookings — attended/cancelled are past and
|
||||
// must not appear as "your next consultation" in the weekly digest.
|
||||
bookings: {
|
||||
where: inArray(bookings.status, [BOOKING_STATUS.pending, BOOKING_STATUS.confirmed]),
|
||||
orderBy: [desc(bookings.createdAt)],
|
||||
limit: 1,
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user