"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.patientWithIdSchema = exports.patientSchema = void 0;
const zod_1 = require("zod");
const identifier_zod_1 = require("./identifier.zod");
const address_zod_1 = require("./address.zod");
const extension_zod_1 = require("./extension.zod");
const nameSchema = zod_1.z.object({
    use: zod_1.z.string(),
    family: zod_1.z.string().optional(),
    given: zod_1.z.array(zod_1.z.string()).min(1),
    prefix: zod_1.z.string().optional(),
    suffix: zod_1.z.string().optional(),
});
const telecomSchema = zod_1.z.object({
    id: zod_1.z.string().optional(),
    extension: zod_1.z
        .array(zod_1.z.object({
        url: zod_1.z.string(),
        valueBoolean: zod_1.z.boolean(),
    }))
        .optional(),
    system: zod_1.z.string(),
    value: zod_1.z.string(),
    use: zod_1.z.string().optional(),
    rank: zod_1.z.number().optional(),
});
const contactSchema = zod_1.z.object({
    name: zod_1.z.object({
        text: zod_1.z.string(),
    }),
    relationship: zod_1.z
        .array(zod_1.z.object({
        text: zod_1.z.string(),
    }))
        .optional(),
    telecom: zod_1.z
        .array(zod_1.z.object({
        system: zod_1.z.string(),
        value: zod_1.z.string(),
    }))
        .optional(),
    extension: zod_1.z
        .array(zod_1.z.object({
        url: zod_1.z.string(),
        valueBoolean: zod_1.z.boolean(),
    }))
        .optional(),
});
const photoSchema = zod_1.z.object({
    data: zod_1.z.string().optional(),
    url: zod_1.z.string().url().optional(),
});
exports.patientSchema = zod_1.z.object({
    resourceType: zod_1.z.literal('Patient'),
    extension: zod_1.z.array(extension_zod_1.extensionSchema).optional(),
    identifier: zod_1.z.array(identifier_zod_1.identifierSchema).optional(),
    active: zod_1.z.boolean().optional(),
    name: zod_1.z.array(nameSchema),
    telecom: zod_1.z.array(telecomSchema).optional(),
    gender: zod_1.z.enum(['male', 'female', 'other', 'unknown']).optional(),
    birthDate: zod_1.z.union([
        zod_1.z.string().regex(/^\d{4}$/),
        zod_1.z.string().regex(/^\d{4}-\d{2}$/),
        zod_1.z.string().regex(/^\d{4}-\d{2}-\d{2}$/),
    ]),
    contact: zod_1.z.array(contactSchema).optional(),
    address: zod_1.z.array(address_zod_1.addressSchema).optional(),
    deceased: zod_1.z.boolean().optional(),
    photo: zod_1.z.array(photoSchema).optional(),
});
exports.patientWithIdSchema = exports.patientSchema.extend({
    id: zod_1.z.string(),
});
//# sourceMappingURL=patient.zod.js.map