"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.updateBaselineInfo = void 0;
const extensions_core_1 = require("@awell-health/extensions-core");
const config_1 = require("./config");
const zod_1 = __importDefault(require("zod"));
exports.updateBaselineInfo = {
    key: 'updateBaselineInfo',
    category: extensions_core_1.Category.WORKFLOW,
    title: 'Update Baseline Datapoints',
    description: 'Update some (or all) of the baseline datapoints for the patient currently enrolled in the care flow.',
    fields: config_1.fields,
    dataPoints: config_1.dataPoints,
    previewable: false,
    onEvent: async ({ payload, onComplete, helpers }) => {
        const { fields: { careflowId: externalCareflowId, baselineInfo }, pathway: { id: currentCareflowId }, } = (0, extensions_core_1.validate)({
            schema: zod_1.default.object({
                fields: config_1.FieldsValidationSchema,
                pathway: config_1.PathwayValidationSchema,
            }),
            payload,
        });
        const sdk = await helpers.awellSdk();
        const { updateBaselineInfo } = await sdk.orchestration.mutation({
            updateBaselineInfo: {
                __args: {
                    input: {
                        pathway_id: externalCareflowId !== null && externalCareflowId !== void 0 ? externalCareflowId : currentCareflowId,
                        baseline_info: baselineInfo,
                    },
                },
                code: true,
                success: true,
            },
        });
        await onComplete({
            data_points: {
                success: updateBaselineInfo.success.toString(),
            },
        });
    },
};
//# sourceMappingURL=updateBaselineInfo.js.map