web stats
Mirth Certified Engineer - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 10-07-2019, 09:38 PM
prakashjoy prakashjoy is offline
Mirth Newb
 
Join Date: Sep 2016
Posts: 18
prakashjoy is on a distinguished road
Default Mirth Certified Engineer

Hi,

I created two code templates Library as follows.
1. DB Library
2. HL7 ADT V25 Library

1. DB Library - Using for below data base operations.
1.1 getDBConnnection - create connection object
1.2 executeSelect - executing select query
1.2 executeInsertOrUpdate - Performing insert update operations.

2. HL7 ADT V25 Library - For ADT segments creation (set and get method).
Eg
2.1 setPID - Select records from database and make object for constructing PID segment..
2.2 getPID - Constructing PID segment.

All the methods provided in the attached file.

The transformation script channel is provided below.
var dBConn = getDBConnnection($('dBProfile')); -- getting connection.
//script for setup object
var inPutPID = setPID(dBConn, hL7ADT.inPutPV1.mr_no, triggerEventID);
//getting hl7 PID segment
var pID = <PID/>;
var inputDataPID = $('hL7ADT').inPutPID
pID = getPID(inputDataPID);
tmp.appendChild(pID);


Mirth version using is 3.4.2.8129

I can access code template "executeSelect" (created in Library - DB Library)
from setPID(Library - HL7 ADT V25 Library).

Its working in my development environment.

My aim is for all the ADT's i am creating separate channels and i need to reuse all the set , get and db code templates for constructing all ADT messages.

My questions are below. Please help me.
1. The process I am following is correct?
2. Is it possible to call one code template created in Library 1 from another code template created in another code library. Is working in my dev setup. Please help me on this.
3. Writing js for constructing hl7 message is right?
Attached Files
File Type: txt code template.txt (6.8 KB, 3 views)
Reply With Quote
  #2  
Old 10-08-2019, 12:44 PM
pacmano pacmano is offline
OBX.3 Kenobi
 
Join Date: Oct 2009
Location: Texas
Posts: 127
pacmano is on a distinguished road
Default

Firstly, I'd suggest you rename your post for the kind of help you are seeking.

Secondly, I would break out your questions to unique threads.

As for "is the process you are following correct?" question - there are often many ways to do things in Mirth so you need to be mindful of how scalable your work is. For example, many folks have a set of variables in the configuration map (Setting...Configuration Map) for the storage of DB connect parameters (the v3_ variables below). Then use a shared code template for DB calls like:

Code:
function executeSharedDBStatement(statement, isQuery, paramList)
{
	var result;

	try
	{
		var dbConn = globalMap.get("dbConn");

		if (dbConn == null || dbConn.getConnection().isClosed())
		{
			
			dbConn = DatabaseConnectionFactory.createDatabaseConnection(configurationMap.get('v3_pg_driver'),configurationMap.get('v3_pg_url'),configurationMap.get('v3_pg_username'),configurationMap.get('v3_pg_password'));
			globalMap.put("dbConn", dbConn);
		}

		if (paramList == undefined)
		{
			paramList = new Packages.java.util.ArrayList();
		}

		if (isQuery)
		{
			result = dbConn.executeCachedQuery(statement, paramList);
		}
		else
		{
			result = dbConn.executeUpdate(statement, paramList);
		}
	}
	catch (e)
	{
		logger.error(e);
	}
	finally
	{
		return result;
	}
}
You can then call the function like

Code:
var expression = "<your SQL code that does a select>"
var result = executeSharedDBStatement(expression, true);
or
Code:
var expression = "<your SQL code that does an insert that does not expect any outputt>"
var result = executeSharedDBStatement(expression, false);
__________________
Mirth 3.8.0 / PostgreSQL 11 / Ubuntu 18.04
Diridium Technologies, Inc.
https://diridium.com
Reply With Quote
Reply

Tags
adt, code template, code template library, javascript, reuse code template

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 11:54 PM.


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