Announcement

Collapse
No announcement yet.

Dynamic Mapping

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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!!!

  • #2
    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

    Comment


    • #3
      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.

      Comment


      • #4
        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...

        Comment


        • #5
          Ah That was the problem...Now It is working...

          Thank you very much. This helped a lot.

          Comment

          Working...
          X