"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.appointmentWithIdSchema = exports.appointmentSchema = void 0;
const extensions_core_1 = require("@awell-health/extensions-core");
const zod_1 = require("zod");
const reference_zod_1 = require("./reference.zod");
const reasonCodeSchema = zod_1.z.object({
    coding: zod_1.z.array(zod_1.z.object({
        system: zod_1.z.literal('INTERNAL'),
        code: zod_1.z.string(),
        display: zod_1.z.string(),
    })),
    text: zod_1.z.string(),
});
const participantSchema = zod_1.z.object({
    actor: zod_1.z.object({
        reference: zod_1.z.union([
            (0, reference_zod_1.createReferenceSchema)('Practitioner'),
            (0, reference_zod_1.createReferenceSchema)('Patient'),
        ]),
    }),
    status: zod_1.z.literal('accepted'),
});
const containedSchema = zod_1.z.object({
    resourceType: zod_1.z.literal('Endpoint'),
    id: zod_1.z.string(),
    status: zod_1.z.string(),
    connectionType: zod_1.z.object({
        code: zod_1.z.string(),
    }),
    payloadType: zod_1.z.array(zod_1.z.object({
        coding: zod_1.z.array(zod_1.z.object({
            code: zod_1.z.string(),
        })),
    })),
    address: zod_1.z.string(),
});
exports.appointmentSchema = zod_1.z.object({
    resourceType: zod_1.z.literal('Appointment'),
    reasonCode: zod_1.z.array(reasonCodeSchema).optional(),
    description: zod_1.z.string().optional(),
    participant: zod_1.z.array(participantSchema).optional(),
    appointmentType: zod_1.z.object({
        coding: zod_1.z.array(zod_1.z.object({
            system: zod_1.z.literal('http://snomed.info/sct'),
            // Note: https://docs.canvasmedical.com/reference/appointment-create#appointmenttype,
            code: zod_1.z.string(),
            display: zod_1.z.string(),
        })),
    }),
    start: extensions_core_1.DateTimeSchema,
    end: extensions_core_1.DateTimeSchema,
    supportingInformation: zod_1.z.array(zod_1.z.union([
        zod_1.z.object({
            reference: (0, reference_zod_1.createReferenceSchema)('Location'),
        }),
        zod_1.z.object({
            reference: zod_1.z.literal('#appointment-meeting-endpoint'),
            type: zod_1.z.literal('Endpoint'),
        }),
    ])),
    contained: zod_1.z.array(containedSchema).optional(),
    status: zod_1.z.literal('proposed').optional(),
});
exports.appointmentWithIdSchema = exports.appointmentSchema.extend({
    id: zod_1.z.string(),
});
//# sourceMappingURL=appointment.zod.js.map