feat(db): lab_drafts, lab_draws, biomarkers tables

Refs PAI-91.
This commit is contained in:
marcuspaico
2026-08-17 15:17:37 -07:00
parent e3cfc6592e
commit bd4817cb77
5 changed files with 375 additions and 1 deletions

View 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");
});
});