"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAppointment = void 0;
const extensions_core_1 = require("@awell-health/extensions-core");
const config_1 = require("./config");
const helpers_1 = require("../../helpers");
const appointment_1 = require("../../api/schema/appointment");
exports.getAppointment = {
    key: 'getAppointment',
    category: extensions_core_1.Category.EHR_INTEGRATIONS,
    title: 'Get appointment',
    description: 'Retrieve appointment details from Athena',
    fields: config_1.fields,
    previewable: true,
    dataPoints: config_1.dataPoints,
    onActivityCreated: async (payload, onComplete, onError) => {
        const { fields: input, client, settings: { practiceId }, } = await (0, helpers_1.validatePayloadAndCreateClient)({
            fieldsSchema: config_1.FieldsValidationSchema,
            payload,
        });
        const res = await client.getAppointment({ ...input, practiceId });
        // Both validates and transforms some of the response data
        const appt = appointment_1.AppointmentSchema.parse(res);
        await onComplete({
            data_points: {
                patientId: appt.patientid,
                startTime: appt.starttime,
                status: appt.appointmentstatus,
                appointmentTypeName: appt.appointmenttype,
                appointmentTypeId: appt.appointmenttypeid,
                date: appt.date,
                duration: String(appt.duration),
            },
        });
    },
};
//# sourceMappingURL=getAppointment.js.map