"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateAndCreateSdkClient = void 0;
const extensions_core_1 = require("@awell-health/extensions-core");
const zod_1 = __importDefault(require("zod"));
const core_1 = require("@medplum/core");
const settings_1 = require("../settings");
const validateAndCreateSdkClient = async ({ fieldsSchema, payload, }) => {
    const { settings: { clientId, clientSecret }, fields, settings, } = (0, extensions_core_1.validate)({
        schema: zod_1.default.object({
            fields: fieldsSchema,
            settings: settings_1.SettingsValidationSchema,
            pathway: zod_1.default.object({ id: zod_1.default.string() }),
            activity: zod_1.default.object({ id: zod_1.default.string() }),
        }),
        payload,
    });
    const { patient, pathway, activity } = payload;
    const medplumSdk = new core_1.MedplumClient({
        clientId,
    });
    await medplumSdk.startClientLogin(clientId, clientSecret);
    return { medplumSdk, fields, settings, patient, pathway, activity };
};
exports.validateAndCreateSdkClient = validateAndCreateSdkClient;
//# sourceMappingURL=validateAndCreateSdkClient.js.map