"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 utils_1 = require("../../utils");
const extractResourceId_1 = require("../../utils/extractResourceId/extractResourceId");
exports.getAppointment = {
    key: 'getAppointment',
    category: extensions_core_1.Category.EHR_INTEGRATIONS,
    title: 'Get appointment',
    description: 'Retrieve appointment details from Medplum',
    fields: config_1.fields,
    previewable: true,
    dataPoints: config_1.dataPoints,
    onActivityCreated: async (payload, onComplete, onError) => {
        var _a;
        const { fields: input, medplumSdk } = await (0, utils_1.validateAndCreateSdkClient)({
            fieldsSchema: config_1.FieldsValidationSchema,
            payload,
        });
        const resourceId = (_a = (0, extractResourceId_1.extractResourceId)(input.appointmentId, 'Appointment')) !== null && _a !== void 0 ? _a : '';
        const res = await medplumSdk.readResource('Appointment', resourceId);
        await onComplete({
            data_points: {
                appointmentData: JSON.stringify(res),
            },
        });
    },
};
//# sourceMappingURL=getAppointment.js.map