"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.FindAppointmentFieldSchema = exports.appointmentSchema = exports.statusSchema = exports.statusEnum = void 0;
const extensions_core_1 = require("@awell-health/extensions-core");
const lodash_1 = require("lodash");
const z = __importStar(require("zod"));
exports.statusEnum = z.enum([
    'Scheduled',
    'Confirmed',
    'Checked Out',
    'Cancelled',
    'With Doctor',
    'In Room',
    'Checked In',
    'In Room - Vitals Taken',
    'Not Seen',
    'Billed',
]);
exports.statusSchema = z.object({
    status: exports.statusEnum,
    room: z.string().optional(),
});
const statusReturnSchema = exports.statusSchema.extend({
    status_date: z.string().datetime(),
    status_detail: z.string(),
});
exports.appointmentSchema = z
    .object({
    scheduled_date: extensions_core_1.DateTimeSchema,
    duration: z.coerce.number().int().min(1).max(1440).optional(),
    reason: z.string().max(50).nonempty(),
    description: z.string().max(500).optional(),
    status: z.union([statusReturnSchema, exports.statusSchema]).optional(),
    service_location: z.coerce.number().int().min(1).optional(),
    telehealth_details: z.string().optional(),
    patient: extensions_core_1.NumericIdSchema,
    physician: extensions_core_1.NumericIdSchema,
    practice: extensions_core_1.NumericIdSchema,
    metadata: z.object({}).passthrough().nullish(),
})
    .strict();
exports.FindAppointmentFieldSchema = z
    .object({
    patientId: z.number(),
    physicianId: z.number().optional(),
    practiceId: z.number().optional(),
    from_date: z.string().datetime().optional(),
    to_date: z.string().datetime().optional(),
    event_type: z.literal('appointment').optional(),
})
    .transform((data) => {
    return {
        patient: data.patientId,
        ...(!(0, lodash_1.isNil)(data.practiceId) && { practice: data.practiceId }),
        ...(!(0, lodash_1.isNil)(data.physicianId) && { physician: data.physicianId }),
        ...(!(0, lodash_1.isNil)(data.from_date) && { from_date: data.from_date }),
        ...(!(0, lodash_1.isNil)(data.to_date) && { to_date: data.to_date }),
        ...(!(0, lodash_1.isNil)(data.event_type) && { event_type: 'appointment' }),
    };
});
//# sourceMappingURL=appointment.zod.js.map