Created
February 27, 2018 15:54
-
-
Save onewoorks/1b62885d599b6656e874e677c5c4df4a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var dbConn; | |
| var result; | |
| var paramList; | |
| var content = {}; | |
| var table; | |
| var column; | |
| var pat_id; | |
| var json = {}; | |
| var minimumURLParameterCount = 3; | |
| var responseContentType; | |
| /* Preparing input parameters */ | |
| var contextPath = $('contextPath'); | |
| logger.info(contextPath); | |
| var prefixService = "/integration"; | |
| var params = contextPath.substring(prefixService.length).split('/'); | |
| try { | |
| dbConn = DatabaseConnectionFactory.createDatabaseConnection('com.mysql.jdbc.Driver','jdbc:mysql://172.19.64.7:3306/integdb','root','Root@!23'); | |
| if(params.length < minimumURLParameterCount) | |
| return Packages.com.mirth.connect.server.userutil.ResponseFactory.getErrorResponse('Too few parameters in request'); | |
| // Just in case we fail, set a sane responseContentType | |
| responseContentType = 'application/json'; | |
| channelMap.put('responseContentType', 'application/json'); | |
| table = params[1]; | |
| column = params[2]; | |
| pat_id = params[3]; | |
| paramList = [pat_id]; | |
| result = dbConn.executeCachedQuery('select content, images from dicom where patient_id=? order by id desc limit 1', paramList); | |
| result.next(); | |
| json.data = '{"content":'+result.getString(1)+',"images":'+result.getString(2)+'}'; | |
| result.close(); | |
| channelMap.put('responseStatusCode', '200'); | |
| json.status = 'success'; | |
| channelMap.put('responseContent', content); | |
| channelMap.put('responseContentType', responseContentType); | |
| return json.data; | |
| } | |
| catch (err) | |
| { | |
| channelMap.put('responseStatusCode', '500'); | |
| json.status = 'error'; | |
| if(err.javaException) { | |
| // If you want to unpack a Java exception, this is how you do it: | |
| json.errorType = String(err.javaException.getClass().getName()); | |
| json.errorMessage = String(err.javaException.getMessage()); | |
| } | |
| channelMap.put('responseContentType', responseContentType); | |
| // Return an error with our "error" JSON | |
| return Packages.com.mirth.connect.server.userutil.ResponseFactory.getErrorResponse(JSON.stringify(json)); | |
| } finally { | |
| if (dbConn) { | |
| dbConn.close(); | |
| } | |
| } | |
| ---- | |
| var dbConn; | |
| var patient_mrn = $('OrderContentPatientMRN'); | |
| var patient_name = $('OrderContentPatientName'); | |
| var modality = $('OrderContentModality'); | |
| var ordered_by = $('OrderContentOrderedBy'); | |
| var his_order_id = $('OrderContentHisOrderId'); | |
| var decipline = $('OrderContentHisDecipline'); | |
| var status = 0; | |
| try { | |
| dbConn = DatabaseConnectionFactory.createDatabaseConnection( | |
| 'com.mysql.jdbc.Driver', | |
| 'jdbc:mysql://172.19.64.7:3306/integdb','root','Root@!23'); | |
| var result = dbConn.executeUpdate("INSERT INTO orders (patient_mrn, patient_name, modalilty, status, his_order_id, decipline, ordered_by) VALUES (?, ?, ?, ?, ?, ?, ?)", | |
| [patient_mrn,patient_name,modality,status,his_order_id, decipline,ordered_by]); | |
| } finally { | |
| if (dbConn) { | |
| dbConn.close(); | |
| } | |
| } | |
| ------ | |
| var dbConn; | |
| var result; | |
| var paramList; | |
| var content = {}; | |
| var table; | |
| var column; | |
| var pat_id; | |
| var json = {}; | |
| var minimumURLParameterCount = 3; | |
| var responseContentType; | |
| /* Preparing input parameters */ | |
| var contextPath = $('contextPath'); | |
| logger.info(contextPath); | |
| var prefixService = "/integration"; | |
| var params = contextPath.substring(prefixService.length).split('/'); | |
| try { | |
| dbConn = DatabaseConnectionFactory.createDatabaseConnection('com.mysql.jdbc.Driver','jdbc:mysql://172.19.64.7:3306/integdb','root','Root@!23'); | |
| if(params.length < minimumURLParameterCount) | |
| return Packages.com.mirth.connect.server.userutil.ResponseFactory.getErrorResponse('Too few parameters in request'); | |
| // Just in case we fail, set a sane responseContentType | |
| responseContentType = 'application/json'; | |
| channelMap.put('responseContentType', 'application/json'); | |
| table = params[1]; | |
| column = params[2]; | |
| pat_id = params[3]; | |
| paramList = [pat_id]; | |
| result = dbConn.executeCachedQuery('select content, images from dicom where patient_id=? order by id desc limit 1', paramList); | |
| result.next(); | |
| json.data = '{"content":'+result.getString(1)+',"images":'+result.getString(2)+'}'; | |
| result.close(); | |
| channelMap.put('responseStatusCode', '200'); | |
| json.status = 'success'; | |
| channelMap.put('responseContent', content); | |
| channelMap.put('responseContentType', responseContentType); | |
| return json.data; | |
| } | |
| catch (err) | |
| { | |
| channelMap.put('responseStatusCode', '500'); | |
| json.status = 'error'; | |
| if(err.javaException) { | |
| // If you want to unpack a Java exception, this is how you do it: | |
| json.errorType = String(err.javaException.getClass().getName()); | |
| json.errorMessage = String(err.javaException.getMessage()); | |
| } | |
| channelMap.put('responseContentType', responseContentType); | |
| // Return an error with our "error" JSON | |
| return Packages.com.mirth.connect.server.userutil.ResponseFactory.getErrorResponse(JSON.stringify(json)); | |
| } finally { | |
| if (dbConn) { | |
| dbConn.close(); | |
| } | |
| } | |
| ---- | |
| // | |
| //var contextPath = $('contextPath'); | |
| //var prefixService = "/integration"; | |
| //var params = contextPath.substring(prefixService.length).split('/'); | |
| // | |
| //var route = String(params[1]); | |
| //var routePath = String(params[2]); | |
| // | |
| //switch(route){ | |
| // case 'orders': | |
| // switch(routePath){ | |
| // case 'neworder': | |
| // logger.info('in the new order'); | |
| // destinationSet.removeAllExcept(1); | |
| // break; | |
| // case 'orderlist': | |
| // logger.info('listing order'); | |
| // DestinationSet.removeAllExcept(3); | |
| // break; | |
| // } | |
| // break; | |
| // default: | |
| // break; | |
| //} | |
| //logger.info(msg); | |
| //channelMap.put('OrderContentPatientMRN', validate(msg['patient_mrn'],'', new Array())); | |
| //channelMap.put('OrderContentPatientName', validate(msg['patient_name'], '', new Array())); | |
| //channelMap.put('OrderContentHisOrderId', validate(msg['his_order_id'], '', new Array())); | |
| //channelMap.put('OrderContentHisDecipline', validate(msg['his_dicipline'], '', new Array())); | |
| //channelMap.put('OrderContentOrderedBy', validate(msg['ordered_by'], '', new Array())); | |
| //channelMap.put('OrderContentModality', validate(msg['modality'], '', new Array())); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment