题
欢笑 是一个经纪人的帮助与医疗保健应用程序HL7消息一体化。
我的问题是关于节省自己的麻烦打你自己的数据存储每次你想要做一个查找一些数据包含在HL7.
方案:对于每一个接收到消息的通道,我想要查找设施的记忆/code/身份证件和获得姓名的设施。不幸的是,我不能要求的发送者HL7消息发送它的消息对我来说。所以我必须要写我自己的数据库访问代码,以叫一个存储的过程,通过在ID,并收到完整的名称。
任何想法,关于如何创建一个缓存的数据在欢乐,这样就可以访问的查找,从任何渠道、来源、目的地、变压器或器?
解决方案
你可以尝试写一个全球性的脚本中有两个功能:
1)填充Java hastable或类似构建的数据你是在寻找
2)使用的参数通过在作为关键的hashtable和返回的数据包含在hashtable与此相应的关键。
链接到采用Java在欢乐(链接)
其他提示
在我们的情况下,我们不得不载的查阅值从一个数据库,我们解决了这个如下:
- 有一道部署脚本,载的查阅值当频道被部署到全球地图。
- 有一个全球性的模板功能,可以查阅值从这个全球地图。
- 使用全球模板功能的过滤器和转换。
注:在我们的情况下,每个钥匙可以有两个数值与它相关联。如果我们没有使用我们只需要设置第二,空中查询的数据库。
载的全球地图的地方在这你的部署脚本的渠道(定制需要):
// This script executes once when the mule engine is started
// You only have access to the globalMap here to persist data
var sqlDBDriver = 'net.sourceforge.jtds.jdbc.Driver';
var sqlDBName = 'jdbc:jtds:sqlserver://databaseserver/databasename';
var sqlDBDUser = 'username';
var sqlDBPassword = 'password';
function PopulateLookup ( sqlQuery, globalMapName )
{
logger.info('Loading lookup table values in the deploy script: ' + globalMapName);
var dbConn = DatabaseConnectionFactory.createDatabaseConnection( sqlDBDriver, sqlDBName, sqlDBDUser, sqlDBPassword );
var rs = dbConn.executeCachedQuery( sqlQuery );
dbConn.close();
var arr = new Array();
while(rs.next())
{
var obj = new Object();
obj.LeftValue = rs.getString('LeftValue');
obj.RightValue1 = rs.getString('RightValue1');
obj.RightValue2 = rs.getString('RightValue2');
arr.push(obj);
}
globalMap.put( globalMapName, arr );
}
PopulateLookup( 'SELECT keyColumn as LeftValue, Value1 as RightValue1, Value2 as RightValue2 FROM tableName', 'GlobalMapName' );
// Repeat above line as needed for each lookup you need
return;
为了访问这些价值观使用的下列功能作为一个全球性的模板。
function FindLookupValueWithDefault ( LookupGlobalMapName, LeftValue, DefaultValue1, DefaultValue2 ){
/***********************************************************************************************
DESCRIPTION: Retrieves lookup table values from the global map and uses the input values to return output values
PARAMETERS:
LookupGlobalMapName - name of the lookup table in the Global Map
LeftValue - The value to look up
DefaultValue1 - the first default value if a match was not found
DefaultValue2 - the second default value if a match was not found
RETURNS:
An object containing the replacement value and associated OID if applicable
REMARKS:
************************************************************************************************/
// Retrieve the previously matched item from the globalmap
// We do this to save time and not look through a huge lookup table tons of times
// unless we absolutely have to
var prevItem = globalMap.get(LookupGlobalMapName + '-Previous');
// This is the same item requested for this globalmap name - just return the previous value
if ( prevItem != null && prevItem.LeftValue == LeftValue) {
return prevItem;
}
//
// If we reach this point the previous item either did not exist or did not match
//
// Retrieve the array with lookup objects from the globalmap and search for the matching value
var arr = globalMap.get(LookupGlobalMapName);
var obj = new Object();
obj.LeftValue = LeftValue;
obj.RightValue1 = DefaultValue1;
obj.RightValue2 = DefaultValue2;
for each ( item in arr )
{
var pattern=new RegExp("^" + item.LeftValue + "$");
var result = pattern.test(LeftValue );
if ( pattern.test(LeftValue ) )
{
obj = item;
break;
}
}
// Store the previous value in the globalmap
globalMap.put( LookupGlobalMapName + '-Previous', obj );
// Return the object we found or created
return obj;
}
一样的代码的访问的价值观:
var myObject = FindLookupValueWithDefault('GlobalMapName', 'LookupValue', 'DefaultValue1', 'DefaultValue2');
if ( myObject != null )
{
var value1 = myObject.RightValue1;
var value2 = myObject.RightValue2;
}
你的里程可能会有所不同...但是,这已经为我们工作到现在。
谢谢, 弗兰斯*德湿
不隶属于 StackOverflow