"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.pathwayCompleted = void 0;
const lodash_1 = require("lodash");
const dataPoints = {
    pathway_definition_id: {
        key: 'pathway_definition_id',
        valueType: 'string',
    },
    complete_date: {
        key: 'complete_date',
        valueType: 'date',
    },
};
exports.pathwayCompleted = {
    key: 'pathwayCompleted',
    dataPoints,
    onWebhookReceived: async ({ payload }, onSuccess, onError) => {
        const { pathway, complete_date } = payload;
        if ((0, lodash_1.isNil)(pathway.pathway_definition_id)) {
            await onError({
                response: {
                    statusCode: 400,
                    message: 'Pathway definition id is required',
                },
            });
        }
        else {
            await onSuccess({
                patient_id: pathway.patient_id,
                pathway_id: pathway.id,
                data_points: {
                    pathway_definition_id: pathway.pathway_definition_id,
                    complete_date,
                },
            });
        }
    },
};
//# sourceMappingURL=pathwayCompleted.js.map