Announcement

Collapse
No announcement yet.

resetting msg object from XML contents

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

  • resetting msg object from XML contents

    The task is to:
    * send an XML object from Channel-A to Channel-B

    <MyMessage>
    <ID>42</ID>
    <hl7v2>
    MSH|^~\&|LAB|....
    PID|1|....
    </hl7v2>
    </MyMessage>

    * in the Channel-B's source transformer, extract the HL7v2 contents
    * OVERWRITE the current msg object in Channel-B with the extracted contents
    * continue in the other Channel-B source transformers and expecting to reference msg['PID']['PID.5'] as normal.

    The good news is that I can extract the HL7v2 'payload' into a variable. The problem or difficulty is resetting the msg object, or any other object to be able to reference the HL7 properties as expected.

    When I create a new variable with the SerializerFactory.getHL7Serializer, it wraps with the tags <HL7Message>.


    channelMap.put('MessageID', msg['ID']); //successful
    channelMap.put('v2payload',msg['HL7v2']); //also looks good

    var v2Msg = SerializerFactory.getHL7Serializer(false,false,tru e).toXML(msg['HL7v2']);

    channelMap.put('v2Msg', v2Msg );




    Do you have any suggestions on how to overwrite the msg object?

    Current Conditions
    * the receiving channel's input type is XML
    * the need is to take extract all the properties from that XML object; ID is a database PK to be used later in the destination.
    Last edited by Philoushka; 12-16-2009, 09:55 AM.

  • #2
    (note: you have a typo - tru e should be true. don't know if that's tripping up your test code.)

    I have successfully done something similar. However, in my case, the message is converted to XML (and placed in an XML node) before it is received.

    Sending Channel:

    Code:
    var HL7AsXML = SerializerFactory.getHL7Serializer(false,false,true).toXML(msg);
    
    //strip the namespace header since we're just going to wrap the HL7 XML into another XML structure
    var strippedXML;
    var messageStartIndex = HL7AsXML.indexOf("<HL7Message>");
    
    if (messageStartIndex >= 0)
    {
    	strippedXML = HL7AsXML.substring(messageStartIndex,HL7AsXML.length());
    }
    else
    {
    	strippedXML  = HL7AsXML;
    }
    
    var wrappedHL7 = "<td><MessageID>" + blah123 +"</MessageID><hl7>" + strippedXML + "</hl7></td>";
    
    router.routeMessage("Receiving Channel", wrappedHL7);
    Receiving Channel (in the first source filter):
    Code:
    var msgID = msg['MessageID'].toString();
    msg = msg['hl7']['HL7Message'];
    The receiving channel filters and transformers can now treat msg normally.

    Comment

    Working...
    X