简体   繁体   中英

Accessing global variables inside a Mirth database writer query

Fairly new to Mirth here, and am still learning the nomenclature, terminology, and architecture - so bear with me here:)

Using an older Mirth Connect 3.4.1 setup.

The question is: Is there a way to access a global variable or map lookup value within the destination mappings for a given channel where the channel destination is using the Database Writer connector, and in SQL mode, not Javascript?

The goal is to take a value from the original input message, match it in a lookup, and then use the result of that as a part of the insert statement in the database writer.

For example: Let's say the message contained a property foo . I'd like to look that up and use the results as ${bar} in the query.

INSERT INTO ... (..., mrn, name, foo, bar, ... )
    VALUES (..., ${mrn} ,${name}, ${foo}, ${bar}, ...))

Hope this makes sense. This is probably doable to do in Javascript, since you have more control over things, but I am dealing with a boat load of channels and need to make some changes. Trying to find a shorter path here, if one is possible.

Thanks in advance!

When you say 'match it in a lookup' do you mean in something like a globalMap/channelMap array, or do you mean do a SQL select in between the message being received and the insert statement?

If you're just trying to use values from the inbound message in the insert statement you should be able to reference the message fields directly as ${msg['PID']['PID.3'].toString()} for MRN for example.

Gleaning a little more information from your comment on the answer by @workwm, the most straight forward way to do this is in your transformer after you set the value for the foo map variable.

$co('bar', $($('foo')))
// or the equivalent, assuming foo is in the connectorMap and
// the value you want to lookup is in the globalMap
connectorMap.put('bar', globalMap.get(connectorMap.get('foo')))

Could also be simplified with a local variable

var foo = msg.whatever;
$co('foo', foo);
$co('bar', $(foo));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM