From 22fa8a885256012c490050cf59eb79b634ba8bc6 Mon Sep 17 00:00:00 2001 From: pacmano1 <44065187+pacmano1@users.noreply.github.com> Date: Mon, 9 Sep 2024 09:36:45 -0500 Subject: [PATCH] Create router.routeMessage.js --- router.routeMessage.js | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 router.routeMessage.js diff --git a/router.routeMessage.js b/router.routeMessage.js new file mode 100644 index 0000000..1fbceb6 --- /dev/null +++ b/router.routeMessage.js @@ -0,0 +1,40 @@ +/** + * @file routeMessageFunctions.js + * @author Tony Germano + * @description + * This file contains utility functions for routing messages in Mirth Connect. + * These functions simplify the process of routing messages by abstracting away + * the details of creating raw messages and routing them to the appropriate channel. + */ + +/** + * Routes a message to a specified channel by name. + * + * @param {string} channelName - The name of the channel to which the message should be routed. + * @param {Object} message - The message to be routed. + * @param {Object} sourceMap - The source map containing metadata or properties related to the message. + * @param {Object} destinationSet - The destination set specifying where the message should be routed. + * @returns {Object} - The result of the routing process. + * + * @example + * const result = routeMessage('MyChannel', message, sourceMap, destinationSet); + */ +function routeMessage(channelName, message, sourceMap, destinationSet) { + return router.routeMessage(channelName, createRawMessage(message, sourceMap, destinationSet)); +} + +/** + * Routes a message to a specified channel by ID. + * + * @param {string} channelId - The ID of the channel to which the message should be routed. + * @param {Object} message - The message to be routed. + * @param {Object} sourceMap - The source map containing metadata or properties related to the message. + * @param {Object} destinationSet - The destination set specifying where the message should be routed. + * @returns {Object} - The result of the routing process. + * + * @example + * const result = routeMessageByChannelId('1234abcd', message, sourceMap, destinationSet); + */ +function routeMessageByChannelId(channelId, message, sourceMap, destinationSet) { + return router.routeMessageByChannelId(channelId, createRawMessage(message, sourceMap, destinationSet)); +}