web stats
Transformer ASTM to SQL Database Issue - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 09-06-2018, 06:50 PM
dandan924 dandan924 is offline
What's HL7?
 
Join Date: Mar 2017
Posts: 5
dandan924 is on a distinguished road
Default Transformer ASTM to SQL Database Issue

Hi,

I want to insert the ASTM to SQL database, but it shows the following error.

Could you help to fix this issue? Many thanks

------------------------
Error Information:
ERROR-406: JDBC Connector error
ERROR MESSAGE: Error writing to database:
org.mozilla.javascript.EvaluatorException: Cannot convert D123,2018-08-20 14:08:43,296,, to java.lang.Integer (8474a163-ad3f-4748-a025-3536574a7ad4#45)
at org.mozilla.javascript.DefaultErrorReporter.runtim eError(DefaultErrorReporter.java:109)
at org.mozilla.javascript.Context.reportRuntimeError( Context.java:945)
at org.mozilla.javascript.Context.reportRuntimeError( Context.java:1001)
at org.mozilla.javascript.Context.reportRuntimeError2 (Context.java:971)
at org.mozilla.javascript.NativeJavaObject.reportConv ersionError(NativeJavaObject.java:896)
at org.mozilla.javascript.NativeJavaObject.toInteger( NativeJavaObject.java:875)
at org.mozilla.javascript.NativeJavaObject.coerceToNu mber(NativeJavaObject.java:766)
at org.mozilla.javascript.NativeJavaObject.coerceType Impl(NativeJavaObject.java:639)
at org.mozilla.javascript.Context.jsToJava(Context.ja va:1724)
at org.mozilla.javascript.NativeJavaClass.constructSp ecific(NativeJavaClass.java:272)
at org.mozilla.javascript.NativeJavaClass.construct(N ativeJavaClass.java:200)
at org.mozilla.javascript.Interpreter.interpretLoop(I nterpreter.java:1748)
at script.doDatabaseScript(8474a163-ad3f-4748-a025-3536574a7ad4:45)
at script(8474a163-ad3f-4748-a025-3536574a7ad4:64)
at org.mozilla.javascript.Interpreter.interpret(Inter preter.java:845)
at org.mozilla.javascript.InterpretedFunction.call(In terpretedFunction.java:164)
at org.mozilla.javascript.ContextFactory.doTopCall(Co ntextFactory.java:426)
at org.mozilla.javascript.ScriptRuntime.doTopCall(Scr iptRuntime.java:3157)
at org.mozilla.javascript.InterpretedFunction.exec(In terpretedFunction.java:175)
at com.mirth.connect.connectors.jdbc.JdbcMessageDispa tcher.doDispatch(JdbcMessageDispatcher.java:96)
at com.mirth.connect.connectors.jdbc.JdbcMessageDispa tcher.doSend(JdbcMessageDispatcher.java:162)
at org.mule.providers.AbstractMessageDispatcher.send( AbstractMessageDispatcher.java:164)
at org.mule.impl.MuleSession.sendEvent(MuleSession.ja va:191)
at org.mule.impl.MuleSession.sendEvent(MuleSession.ja va:130)
at org.mule.routing.outbound.AbstractOutboundRouter.s end(AbstractOutboundRouter.java:85)
at org.mule.routing.outbound.FilteringMulticastingRou ter.route(FilteringMulticastingRouter.java:54)
at org.mule.routing.outbound.OutboundMessageRouter$1. doInTransaction(OutboundMessageRouter.java:78)
at org.mule.transaction.TransactionTemplate.execute(T ransactionTemplate.java:48)
at org.mule.routing.outbound.OutboundMessageRouter.ro ute(OutboundMessageRouter.java:82)
at org.mule.impl.model.DefaultMuleProxy.onCall(Defaul tMuleProxy.java:247)
at org.mule.impl.model.seda.SedaComponent.doSend(Seda Component.java:209)
at org.mule.impl.model.AbstractComponent.sendEvent(Ab stractComponent.java:277)
at org.mule.impl.MuleSession.sendEvent(MuleSession.ja va:201)
at org.mule.routing.inbound.InboundMessageRouter.send (InboundMessageRouter.java:176)
at org.mule.routing.inbound.InboundMessageRouter.rout e(InboundMessageRouter.java:143)
at org.mule.providers.AbstractMessageReceiver$Default InternalMessageListener.onMessage(AbstractMessageR eceiver.java:487)
at org.mule.providers.AbstractMessageReceiver.routeMe ssage(AbstractMessageReceiver.java:266)
at org.mule.providers.AbstractMessageReceiver.routeMe ssage(AbstractMessageReceiver.java:225)
at com.mirth.connect.connectors.vm.VMMessageReceiver. getMessages(VMMessageReceiver.java:223)
at org.mule.providers.TransactedPollingMessageReceive r.poll(TransactedPollingMessageReceiver.java:108)
at org.mule.providers.PollingMessageReceiver.run(Poll ingMessageReceiver.java:97)
at org.mule.impl.work.WorkerContext.run(WorkerContext .java:290)
at edu.emory.mathcs.backport.java.util.concurrent.Thr eadPoolExecutor.runWorker(ThreadPoolExecutor.java: 1061)
at edu.emory.mathcs.backport.java.util.concurrent.Thr eadPoolExecutor$Worker.run(ThreadPoolExecutor.java :575)
at java.lang.Thread.run(Unknown Source)

----------------------------------
TransFormer Code:

$c('DeviceID',msg['H']['H.4']['H.4.2'].toString());
$c('TestID',msg['O']['O.3']['O.3.2'].toString());
$c('OperatorID',msg['R'][0]['R.10']['R.10.1'].toString());
$c('ObservationDateTime',DateUtil.convertDate( "yyyyMMddHHmmss","yyyy-MM-dd' 'HH:mm:ss", msg['R'][0]['R.11']['R.11.1'].toString()));

$c('observations',[]);

var i = 0;
for each (R in msg.R){
var observation = {};
observation.PName = msg['R'][i]['R.2']['R.2.4'].toString();
observation.PUnit = msg['R'][i]['R.4']['R.4.1'].toString();
observation.PValue = msg['R'][i]['R.3']['R.3.1'].toString();
observation.PMinValue = msg['R'][i]['R.5']['R.5.1'].toString();
observation.PMaxValue = msg['R'][i]['R.5']['R.5.2'].toString();
i++;
$c('observations').push(observation);
}

----------------------
Database Write Code:

var dbConn;

try {
dbConn = DatabaseConnectionFactory.createDatabaseConnection ('net.sourceforge.jtds.jdbc.Driver','jdbc:jtds:sql server://localhost:1433/test','Admin','Admin');

var insertQuery="INSERT INTO Demo1 (Device, TestTime, SampleID, PName, Value) VALUES (?, ?, ?, ?, ?)";

var params = new java.util.ArrayList([$('DeviceID'), $('ObservationDateTime'), $('TestID'), null, null]);

for each (observation in $('observations')) {
// ArrayList is 0 indexed
params.set(3, observation.PName);
params.set(4, observation.PValue);

dbConn.executeUpdate(insertQuery, params);
}

} finally {
if (dbConn) {
dbConn.close();
}
}
Reply With Quote
Reply

Tags
database write, multiple segment

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 04:39 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation