web stats
Dynamic Mapping - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 07-06-2019, 11:35 PM
shishirakram shishirakram is offline
Mirth Newb
 
Join Date: Jun 2018
Posts: 12
shishirakram is on a distinguished road
Default Dynamic Mapping

Hi I have a problem.

Source message is HL7 and I'm picking up specific fields in HL7 and passing them to a webservice.

Now I'm planning to move those mappings (From HL7 to Webservice) to database. So that whenever location of a particular field changes in the HL7 message(Location may change from client to client or message type to message type) I do not have to change my channel instead I'll update the mapping in my database so that it reflects in my channel. That is the plan.

So to do that how should I save those mapping details in database and use it in channel?? Please help me I'm struck here.

I have tried storing mappings in a table something like this:

firstName - msg['PID']['PID.5']['PID.5.2']

And use this mapping in my channel transformer as

var firstName = database call to fetch the mapping.

But this is not working coz mirth is considering the value that it is getting from database as the actual firstName. Instead I have to tell mirth that the value in database is the XPath to find the firstName value in the HL7 message. How to instruct mirth???


Please help me!!!
Reply With Quote
  #2  
Old 07-10-2019, 01:28 AM
schillert schillert is offline
Mirth Newb
 
Join Date: Jul 2012
Posts: 24
schillert is on a distinguished road
Default

Hi,

try

var mapping="var firstname=msg['PID']['PID.5']['PID.5.2'].toString()"
eval(mapping);

This results in the variable 'firstname' being created with the desired value.
You can fetch the value for varianle 'mapping' from a database.

Hope this helps
Reply With Quote
  #3  
Old 07-10-2019, 03:39 AM
shishirakram shishirakram is offline
Mirth Newb
 
Join Date: Jun 2018
Posts: 12
shishirakram is on a distinguished road
Default

Thank you schillert.
But eval works in case of temporary variable. But when I use it on some global variable or the variable stored in DB it is not working.

For Example:
As you mentioned eval works if i write something like this:

var mapping="var firstname=msg['PID']['PID.5']['PID.5.2'].toString()"
eval(mapping);

but when you try this :

globalMap.put("mapping","var firstname=msg['PID']['PID.5']
['PID.5.2'].toString()");

or

globalMap.put("mapping","msg['PID']['PID.5']
['PID.5.2'].toString()");
eval(globalMap.get("mapping"));

It is not working.
Reply With Quote
  #4  
Old 07-10-2019, 04:02 AM
schillert schillert is offline
Mirth Newb
 
Join Date: Jul 2012
Posts: 24
schillert is on a distinguished road
Default

Hi,

the strings in all map-variables are Java-strings, while strings in JavaScript-variables are JavaScript-strings. This is sometimes confusing.
Try a cast:

eval(String(globalMap.get("mapping").toString()))

Hope this helps...
Reply With Quote
  #5  
Old 07-10-2019, 04:16 AM
shishirakram shishirakram is offline
Mirth Newb
 
Join Date: Jun 2018
Posts: 12
shishirakram is on a distinguished road
Default

Ah That was the problem...Now It is working...

Thank you very much. This helped a lot.
Reply With Quote
Reply

Tags
dynamic mapping, mapping, xpath

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 06:51 AM.


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