web stats
DataBase Reader JavaScript to HL7 Message - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 05-05-2012, 04:59 AM
tps tps is offline
What's HL7?
 
Join Date: Feb 2012
Posts: 4
tps is on a distinguished road
Default DataBase Reader JavaScript to HL7 Message

Hello,
I want to create a message for each messageid using a data base table with following data

MessageID input StatusMSG0001 msg['EVN']['EVN.2']['EVN.2.1'] ='0' 0
MSG0001 msg['MSH']['MSH.7']['MSH.7.1'] ='20120504' 0
MSG0001 msg['MSH']['MSH.9']['MSH.9.1'] ='ADT' 0
MSG0001 msg['MSH']['MSH.9']['MSH.9.2'] ='A04' 0
MSG0001 msg['MSH']['MSH.9']['MSH.9.3'] ='ADT_A04' 0
MSG0001 msg['MSH']['MSH.10'] ='MSG0001' 0
MSG0001 msg['MSH']['MSH.11']['MSH.11.1'] ='T' 0
MSG0001 msg['MSH']['MSH.12']['MSH.12.1'] ='2.5' 0
MSG0001 msg['PID']['PID.3']['PID.3.1'] ='1' 0
MSG0001 msg['PID']['PID.5']['PID.5.1']['PID.5.1.1'] ='Renu' 0
MSG0001 msg['PV1']['PV1.2'] ='IPD' 0

I have taken taken source as database reader with JS and in source transformer written a script as follows

var dbConn = DatabaseConnectionFactory.createDatabaseConnection ('net.sourceforge.jtds.jdbc.Driver','jdbc:jtds:sql server://192.168.1.21:1433/HealthNote','MirthUser','iwork07');
var result = dbConn.executeCachedQuery("SELECT ID, MessageID, MessageType, input, Status, Segement FROM v_MirthInput WHERE (Status = 0) AND (MessageID = N'MSG0001')");
while (result.next())
{var example = (result.getString('field_name') != null)?result.getString('field_name'):"" ;
tmp = result.getString('input');
}


and in outbound template
MSH|^~\&||||||||||
EVN|||||||||||||||||||
PID|||||||||||||||||||
PV1|||||||||||||||||||

when I deploy the channel I am getting error

[2012-05-05 17:27:47,265] ERROR (com.mirth.connect.connectors.jdbc.JdbcMessageRece iver:228): org.mozilla.javascript.EcmaError: ReferenceError: "result" is not defined. (fb7db4e6-9481-4a6c-ac9c-57103580f52f#413)


Please guide
Reply With Quote
  #2  
Old 05-07-2012, 12:25 PM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 887
cory_cole is on a distinguished road
Default

MessageID = N'MSG0001' is this a typo? Is this what you want? What is the meaning behind N'MSG0001'?
Reply With Quote
  #3  
Old 05-07-2012, 10:39 PM
tps tps is offline
What's HL7?
 
Join Date: Feb 2012
Posts: 4
tps is on a distinguished road
Default

Message ID is message control id and the input is the field in tmp.
Reply With Quote
  #4  
Old 05-08-2012, 03:04 AM
narupley's Avatar
narupley narupley is offline
Mirth Employee
 
Join Date: Oct 2010
Posts: 3,529
narupley is on a distinguished road
Default

Does the stacktrace show exactly where the code is failing?
Reply With Quote
  #5  
Old 05-08-2012, 08:34 AM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 887
cory_cole is on a distinguished road
Default

The N is outside the quotes. That will cause an error on the database side and make that a null item.
Reply With Quote
  #6  
Old 05-08-2012, 08:39 AM
narupley's Avatar
narupley narupley is offline
Mirth Employee
 
Join Date: Oct 2010
Posts: 3,529
narupley is on a distinguished road
Default

Quote:
Originally Posted by cory_cole View Post
The N is outside the quotes. That will cause an error on the database side and make that a null item.
I don't think that the N prefix would cause an error, much less that specific error you're seeing. Does the stacktrace show exactly where the code is failing?
Reply With Quote
Reply

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 -7. The time now is 10:15 PM.


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