I am trying to call stored procedures in a SQL database from Mirth so that I could update/manipulate the database.
I have parsed the HL7 fields and stored them in the channel map. As of now, I'm trying to call two stored procedures through their respective destinations.

Here are the scripts for the destinations:
// Person_Select //
var dbConn;
try {
dbConn = DatabaseConnectionFactory.createDatabaseConnection('com.microsoft.sqlserver.jdbc.SQLServerDriver','jdbc:sqlserver://localhost:1433;databaseName=<dbname>','<username>','<password>');
var sql = "EXEC dbo.Person_Select " +
"@PersonID = " + channelMap.get('PatID') + ", " +
"@MRNO = '" + channelMap.get('MRNO') + "', " +
"@MasterPatientIndex = '" + channelMap.get('MPI') + "'";
logger.warn("Running query: " + sql);
var result = dbConn.executeCachedQuery(sql);
} finally {
if (dbConn) dbConn.close();
}
// Person_AddUpdate //
var dbConn;
try {
dbConn = DatabaseConnectionFactory.createDatabaseConnection('com.microsoft.sqlserver.jdbc.SQLServerDriver','jdbc:sqlserver://localhost:1433;databaseName=pfsdev','winpfs','pfs4you');
var sql = "EXEC dbo.Person_AddUpdate " +
"@PERSON_ID = " + channelMap.get('PatId') + "', " +
"@ACCT_NUMBER = '" + channelMap.get('AcctNum') + "', " +
"@MASTER_PATIENT_INDEX = '" + channelMap.get('MPI') + "', " +
"@MRNO = '" + channelMap.get('MRNO') + "', " +
"@LAST_NAME = '" + channelMap.get('LastName') + "', " +
"@FIRST_NAME = '" + channelMap.get('FirstName') + "', " +
"@MIDDLE_NAME = '" + channelMap.get('MiddleName') + "', " +
"@STATE = '" + channelMap.get('State') + "', " +
"@ZIPCODE = '" + channelMap.get('ZipCode') + "', " +
"@DOB = '" + DateUtil.convertDate('yyyyMMdd', 'yyyy-MM-dd', channelMap.get('DOB')) + "', " +
"@SEX_LVC = '" + channelMap.get('Sex') + "', " +
"@RACE_LVC = '" + channelMap.get('Race') + "', " +
"@LANGUAGE_LVC = '" + channelMap.get('Language') + "', " +
"@ZIPCODE = '" + channelMap.get('ZipCode') + "', " +
"@COUNTRY = '" + channelMap.get('Country') + "', " +
"@HOME_PHONE = '" + channelMap.get('HomePhone') + "', " +
"@WORK_PHONE = '" + channelMap.get('WorkPhone') + "', " +
"@MARITAL_STATUS_LVC = '" + channelMap.get('MaritalStatus') + "', " +
"@BIRTHPLACE = '" + channelMap.get('Birthplace') + "', " +
"@RELIGION_LVC = '" + channelMap.get('Religion') + "'";
logger.warn("Running query: " + sql);
var result = dbConn.executeCachedQuery(sql);
} finally {
if (dbConn) {
dbConn.close();
}
}