"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.patientCreated = void 0;
const lodash_1 = require("lodash");
const MEDPLUM_IDENTIFIER = 'https://www.medplum.com/docs/api/fhir/resources/patient';
const dataPoints = {
    patientId: {
        key: 'patientId',
        valueType: 'string',
    },
};
exports.patientCreated = {
    key: 'patientCreated',
    dataPoints,
    onWebhookReceived: async ({ payload }, onSuccess, onError) => {
        const patientId = payload.id;
        if ((0, lodash_1.isNil)(patientId)) {
            await onError({
            // We should automatically send a 400 here, so no need to provide info
            });
        }
        else {
            await onSuccess({
                data_points: {
                    patientId,
                },
                patient_identifier: {
                    system: MEDPLUM_IDENTIFIER,
                    value: patientId,
                },
            });
        }
    },
};
//# sourceMappingURL=patientCreated.js.map