feat(db): lab_drafts, lab_draws, biomarkers tables
Refs PAI-91.
This commit is contained in:
21
server/test/db-labs.test.ts
Normal file
21
server/test/db-labs.test.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { mkdtempSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { openDb } from "../src/db";
|
||||
import { biomarkers, labDraws } from "../src/db/schema";
|
||||
|
||||
describe("labs schema", () => {
|
||||
test("draw + biomarker round-trip", async () => {
|
||||
const db = openDb(mkdtempSync(join(tmpdir(), "helios-")));
|
||||
await db.insert(labDraws).values({ id: "d1", collectedAt: "2026-01-15", labName: "Acme Lab", draftId: null, createdAt: 1 });
|
||||
await db.insert(biomarkers).values({
|
||||
drawId: "d1", panel: "lipids", name: "LDL Cholesterol", marker: "ldl", analyteKey: "ldl",
|
||||
value: "3.1", valueNum: 3.1, unit: "mmol/L", referenceRange: "< 3.4", flagged: 0,
|
||||
valueCanonical: 3.1, canonicalUnit: "mmol/L",
|
||||
});
|
||||
const rows = await db.select().from(biomarkers);
|
||||
expect(rows).toHaveLength(1);
|
||||
expect(rows[0].marker).toBe("ldl");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user