"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.addHistory = void 0;
const zod_1 = require("zod");
const extensions_core_1 = require("@awell-health/extensions-core");
const settings_1 = require("../../settings");
const client_1 = require("../../client");
const config_1 = require("./config");
exports.addHistory = {
    key: 'addHistory',
    category: extensions_core_1.Category.EHR_INTEGRATIONS,
    title: 'Add History',
    description: "Add history item on Elation's patient page",
    fields: config_1.fields,
    previewable: true,
    onEvent: async ({ payload, onComplete }) => {
        const { fields, settings } = (0, extensions_core_1.validate)({
            schema: zod_1.z.object({
                fields: config_1.FieldsValidationSchema,
                settings: settings_1.SettingsValidationSchema,
            }),
            payload,
        });
        const api = (0, client_1.makeAPIClient)(settings);
        await api.addHistory({
            type: fields.type,
            patient: fields.patientId,
            text: fields.text,
        });
        await onComplete();
    },
};
//# sourceMappingURL=addHistory.js.map