"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getPatient = void 0;
const extensions_core_1 = require("@awell-health/extensions-core");
const config_1 = require("./config");
const helpers_1 = require("../../helpers");
const patient_1 = require("../../api/schema/patient");
exports.getPatient = {
    key: 'getPatient',
    category: extensions_core_1.Category.EHR_INTEGRATIONS,
    title: 'Get patient',
    description: 'Retrieve patient details from Athena',
    fields: config_1.fields,
    previewable: false,
    dataPoints: config_1.dataPoints,
    onActivityCreated: async (payload, onComplete, onError) => {
        const { fields: input, client, settings: { practiceId }, } = await (0, helpers_1.validatePayloadAndCreateClient)({
            fieldsSchema: config_1.FieldsValidationSchema,
            payload,
        });
        const res = await client.getPatient({ practiceId, ...input });
        // Both validates and transforms some of the response data
        const patient = patient_1.PatientSchema.parse(res);
        await onComplete({
            data_points: {
                firstName: patient.firstname,
                lastName: patient.lastname,
                dob: patient.dob,
                email: patient.email,
            },
        });
    },
};
//# sourceMappingURL=getPatient.js.map