"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.deletePatient = void 0;
const extensions_core_1 = require("@awell-health/extensions-core");
const client_1 = require("../../client");
const errorHandler_1 = require("../../shared/errorHandler");
const generic_zod_1 = require("../../validation/generic.zod");
const fields_1 = require("./fields");
exports.deletePatient = {
    key: 'deletePatient',
    category: extensions_core_1.Category.EHR_INTEGRATIONS,
    title: 'Delete Patient',
    description: 'Removes the specified Patient.',
    fields: fields_1.deleteFields,
    previewable: true,
    onActivityCreated: async (payload, onComplete, onError) => {
        try {
            const patientId = generic_zod_1.stringId.parse(payload.fields.patientId);
            const facilityId = generic_zod_1.stringId.parse(payload.fields.facilityId);
            const api = (0, client_1.createMetriportApi)(payload.settings);
            await api.deletePatient(patientId, facilityId);
            await onComplete();
        }
        catch (err) {
            await (0, errorHandler_1.handleErrorMessage)(err, onError);
        }
    },
};
//# sourceMappingURL=delete.js.map