mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-12 14:16:12 +00:00
fix(report): clamp a long report window in local days
The 730-day clamp subtracted 730 times 24 hours from the end, which lands an hour off local midnight when an odd number of clock changes lies in between. The start is now the end's wall clock 730 calendar days back in the account's zone.
This commit is contained in:
1 parent
46a1a5d320
commit
78611277fe
3 files changed
+80
-34
No files matched your search
@@ -146,7 +146,8 @@ export const POST = apiHandler(async (request: NextRequest) => {
|
||||
});
|
||||
}
|
||||
|
||||
const range = normaliseDateRange(input.range ?? undefined);
|
||||
const userTz = await resolveUserTimezone(user.id);
|
||||
const range = normaliseDateRange(input.range, undefined, userTz);
|
||||
const practiceName = sanitisePracticeName(input.practiceName);
|
||||
const includeCharts = input.includeCharts ?? true;
|
||||
|
||||
@@ -168,38 +169,36 @@ export const POST = apiHandler(async (request: NextRequest) => {
|
||||
input.germanAtc ??
|
||||
(GERMAN_ATC_DEFAULT_LOCALES as readonly string[]).includes(locale);
|
||||
|
||||
const [data, userTz, userRow, allergyRows, familyHistoryRows] =
|
||||
await Promise.all([
|
||||
collectDoctorReportData(user.id, range, selection, { practiceName }),
|
||||
resolveUserTimezone(user.id),
|
||||
prisma.user.findUnique({
|
||||
where: { id: user.id },
|
||||
select: {
|
||||
insuranceNumberEncrypted: true,
|
||||
timeFormat: true,
|
||||
// Issue #922 — the exported PDF is spelled the way the person
|
||||
// who exported it reads dates, not the locale default.
|
||||
dateFormat: true,
|
||||
},
|
||||
}),
|
||||
// Structured records are always-available reference data (not
|
||||
// time-windowed), so they ride alongside the report rather than through
|
||||
// the aggregator. Owner-scoped, live rows only — and each read is gated
|
||||
// on its own leaf, so a deselected section is not loaded, not merely
|
||||
// dropped later.
|
||||
selection.has("ALLERGIES")
|
||||
? prisma.allergy.findMany({
|
||||
where: { userId: user.id, deletedAt: null },
|
||||
orderBy: { createdAt: "desc" },
|
||||
})
|
||||
: Promise.resolve([]),
|
||||
selection.has("FAMILY_HISTORY")
|
||||
? prisma.familyHistoryEntry.findMany({
|
||||
where: { userId: user.id, deletedAt: null },
|
||||
orderBy: { createdAt: "desc" },
|
||||
})
|
||||
: Promise.resolve([]),
|
||||
]);
|
||||
const [data, userRow, allergyRows, familyHistoryRows] = await Promise.all([
|
||||
collectDoctorReportData(user.id, range, selection, { practiceName }),
|
||||
prisma.user.findUnique({
|
||||
where: { id: user.id },
|
||||
select: {
|
||||
insuranceNumberEncrypted: true,
|
||||
timeFormat: true,
|
||||
// Issue #922 — the exported PDF is spelled the way the person
|
||||
// who exported it reads dates, not the locale default.
|
||||
dateFormat: true,
|
||||
},
|
||||
}),
|
||||
// Structured records are always-available reference data (not
|
||||
// time-windowed), so they ride alongside the report rather than through
|
||||
// the aggregator. Owner-scoped, live rows only — and each read is gated
|
||||
// on its own leaf, so a deselected section is not loaded, not merely
|
||||
// dropped later.
|
||||
selection.has("ALLERGIES")
|
||||
? prisma.allergy.findMany({
|
||||
where: { userId: user.id, deletedAt: null },
|
||||
orderBy: { createdAt: "desc" },
|
||||
})
|
||||
: Promise.resolve([]),
|
||||
selection.has("FAMILY_HISTORY")
|
||||
? prisma.familyHistoryEntry.findMany({
|
||||
where: { userId: user.id, deletedAt: null },
|
||||
orderBy: { createdAt: "desc" },
|
||||
})
|
||||
: Promise.resolve([]),
|
||||
]);
|
||||
|
||||
const fhirRecords = {
|
||||
allergies: allergyRows.map(toAllergyDTO),
|
||||
|
||||
Reference in new issue
Block a user