mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-18 16:12:11 +00:00
feat(doctor-report): mark screener totals answered in an unvalidated translation
The report data counts, per screener score type, how many of the window's results were answered in a translation that has not been validated (`screenerUnvalidatedTranslations`, read only when a screener total is in the report). The PDF marks such a row with an asterisk and says under the vitals table how many of how many read as orientation; the clinician share view says the same under the row. To keep the aggregator and the PDF section from growing, the wellness summary and the per-context glucose rows move into helpers; the size ratchets only fall.
This commit is contained in:
1 parent
02cc0631fa
commit
14273051db
22 files changed
+369
-85
No files matched your search
@@ -10,7 +10,9 @@
|
||||
* `unvalidated_translation`;
|
||||
* - the switch records `original_en`;
|
||||
* - English records `validated` whatever the switch says.
|
||||
* The PHQ-9 crisis signpost answers item 9 the same way in every wording.
|
||||
* The PHQ-9 crisis signpost answers item 9 the same way in every wording,
|
||||
* and the doctor report counts the totals answered in an unvalidated
|
||||
* translation per score type, so its renderers can mark them.
|
||||
*/
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
@@ -19,6 +21,8 @@ import {
|
||||
POST as createAssessment,
|
||||
} from "@/app/api/mental-health/assessments/route";
|
||||
import { GET as readAssessment } from "@/app/api/mental-health/assessments/[id]/route";
|
||||
import { collectDoctorReportData } from "@/lib/doctor-report-data";
|
||||
import { selectionFromLeaves } from "@/lib/report-selection/selection";
|
||||
|
||||
import { callRoute } from "../kit/call-route";
|
||||
import { makeSession, makeUser, type SessionFixture } from "../kit/factories";
|
||||
@@ -181,3 +185,39 @@ describe("the wording a check-in records", () => {
|
||||
expect(await getPrismaClient().mentalHealthAssessment.count()).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe("the doctor report", () => {
|
||||
it("counts the screener totals answered in an unvalidated translation, per score type", async () => {
|
||||
await submit({ instrument: "SCI", items: SCI, locale: "nl" });
|
||||
await submit({ instrument: "SCI", items: SCI, locale: "nl" });
|
||||
await submit({
|
||||
instrument: "SCI",
|
||||
items: SCI,
|
||||
locale: "nl",
|
||||
englishOriginal: true,
|
||||
});
|
||||
await submit({ instrument: "PHQ9", items: PHQ9_ITEM9, locale: "nl" });
|
||||
|
||||
const now = Date.now();
|
||||
const range = {
|
||||
start: new Date(now - 7 * 86_400_000),
|
||||
end: new Date(now + 60_000),
|
||||
days: 8,
|
||||
};
|
||||
const report = await collectDoctorReportData(
|
||||
session.userId,
|
||||
range,
|
||||
selectionFromLeaves(["SCI_SCORE", "PHQ9_SCORE"]),
|
||||
);
|
||||
expect(report.stats.SCI_SCORE?.count).toBe(3);
|
||||
expect(report.screenerUnvalidatedTranslations).toEqual({ SCI_SCORE: 2 });
|
||||
|
||||
// Without the screener leaves the table is not asked at all.
|
||||
const withoutScreeners = await collectDoctorReportData(
|
||||
session.userId,
|
||||
range,
|
||||
selectionFromLeaves(["WEIGHT"]),
|
||||
);
|
||||
expect(withoutScreeners.screenerUnvalidatedTranslations).toBeNull();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user