fix: normalize postgres birth dates
This commit is contained in:
@@ -13,7 +13,7 @@ import type {
|
|||||||
} from "./birth-time-journey-service.ts";
|
} from "./birth-time-journey-service.ts";
|
||||||
|
|
||||||
const profileSchema = z.object({
|
const profileSchema = z.object({
|
||||||
birth_date: z.string(),
|
birth_date: z.union([z.string(), z.date().transform((value) => value.toISOString().slice(0, 10))]),
|
||||||
reported_birth_time: z.string().nullable().optional(),
|
reported_birth_time: z.string().nullable().optional(),
|
||||||
birth_time_source: z.enum([
|
birth_time_source: z.enum([
|
||||||
"hospital_record",
|
"hospital_record",
|
||||||
|
|||||||
@@ -30,6 +30,19 @@ test("birth time profile adapter parses an exact hospital declaration", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("birth time profile adapter normalizes PostgreSQL date values", () => {
|
||||||
|
const assessment = parseBirthTimeProfile({
|
||||||
|
birth_date: new Date("1993-04-17T00:00:00.000Z"),
|
||||||
|
reported_birth_time: "08:16:00",
|
||||||
|
birth_time_source: "hospital_record",
|
||||||
|
uncertainty_before_minutes: 2,
|
||||||
|
uncertainty_after_minutes: 2,
|
||||||
|
...coordinates,
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.equal(assessment.date, "1993-04-17");
|
||||||
|
});
|
||||||
|
|
||||||
test("birth time profile adapter parses a period without inventing a time", () => {
|
test("birth time profile adapter parses a period without inventing a time", () => {
|
||||||
const assessment = parseBirthTimeProfile({
|
const assessment = parseBirthTimeProfile({
|
||||||
birth_date: "1993-04-17",
|
birth_date: "1993-04-17",
|
||||||
|
|||||||
Reference in New Issue
Block a user