- Add ConfirmDraftBody schema to shared types - Implement GET /api/labs/drafts/:id (retrieves draft with extracted data) - Implement POST /api/labs/drafts/:id/confirm (normalizes markers, inserts lab draw + biomarkers in transaction, marks draft confirmed) - Implement POST /api/labs/drafts/:id/discard (marks draft discarded) - Add comprehensive test suite with 3 new tests Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
47 lines
1.6 KiB
TypeScript
47 lines
1.6 KiB
TypeScript
import { z } from "zod";
|
|
|
|
export const HealthResponse = z.object({ ok: z.literal(true) });
|
|
export type HealthResponse = z.infer<typeof HealthResponse>;
|
|
|
|
export const PasswordBody = z.object({ password: z.string().min(8).max(200) });
|
|
export const MeResponse = z.object({ needsSetup: z.boolean(), authenticated: z.boolean() });
|
|
export type MeResponse = z.infer<typeof MeResponse>;
|
|
|
|
export const SettingsResponse = z.object({
|
|
llmBaseUrl: z.string(),
|
|
llmModel: z.string(),
|
|
llmKeyMasked: z.string().nullable(),
|
|
});
|
|
export type SettingsResponse = z.infer<typeof SettingsResponse>;
|
|
|
|
export const SettingsUpdate = z.object({
|
|
llmBaseUrl: z.string().url().optional(),
|
|
llmModel: z.string().min(1).optional(),
|
|
llmKey: z.string().min(1).optional(),
|
|
});
|
|
export type SettingsUpdate = z.infer<typeof SettingsUpdate>;
|
|
|
|
export const ExtractedMarker = z.object({
|
|
panel: z.string().nullable().default(null),
|
|
name: z.string().min(1),
|
|
value: z.string().min(1),
|
|
unit: z.string().nullable().default(null),
|
|
referenceRange: z.string().nullable().default(null),
|
|
flagged: z.boolean().default(false),
|
|
});
|
|
export type ExtractedMarker = z.infer<typeof ExtractedMarker>;
|
|
|
|
export const ExtractedDraft = z.object({
|
|
collectedDate: z.string().nullable().default(null),
|
|
labName: z.string().nullable().default(null),
|
|
markers: z.array(ExtractedMarker).default([]),
|
|
});
|
|
export type ExtractedDraft = z.infer<typeof ExtractedDraft>;
|
|
|
|
export const ConfirmDraftBody = z.object({
|
|
collectedDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/),
|
|
labName: z.string().nullable().default(null),
|
|
markers: z.array(ExtractedMarker).min(1),
|
|
});
|
|
export type ConfirmDraftBody = z.infer<typeof ConfirmDraftBody>;
|