"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createTask = void 0;
const extensions_core_1 = require("@awell-health/extensions-core");
const config_1 = require("./config");
const lib_1 = require("../../lib");
const lodash_1 = require("lodash");
exports.createTask = {
    key: 'createTask',
    category: extensions_core_1.Category.WORKFLOW,
    title: 'Create task',
    description: 'Create a Task in Dock Health',
    fields: config_1.fields,
    previewable: false,
    dataPoints: config_1.dataPoints,
    onActivityCreated: async (payload, onComplete, onError) => {
        const { fields, dockClient } = await (0, lib_1.validatePayloadAndCreateClient)({
            fieldsSchema: config_1.FieldsValidationSchema,
            payload,
        });
        const res = await dockClient.createTask({
            description: fields.description,
            patient: !(0, lodash_1.isEmpty)(fields.patientId)
                ? {
                    id: fields.patientId,
                }
                : undefined,
            taskList: {
                id: fields.taskListId,
            },
            taskGroup: !(0, lodash_1.isEmpty)(fields.taskGroupId)
                ? {
                    id: fields.taskGroupId,
                }
                : undefined,
            // taskMetaData: [
            //   {
            //     customFieldIdentifier: 'awellCareflowId',
            //     customFieldName: 'Awell care flow ID',
            //     value: pathwayId,
            //   },
            //   {
            //     customFieldIdentifier: 'awellActivityId',
            //     customFieldName: 'Awell activity ID',
            //     value: activityId,
            //   },
            // ],
        });
        await onComplete({
            data_points: {
                taskId: res.id,
            },
        });
    },
};
//# sourceMappingURL=createTask.js.map