Announcement

Collapse
No announcement yet.

Modify response from Web Service Sender

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

  • Modify response from Web Service Sender

    I am needing assistance in modifying a response from a Web Service Sender.

    In the response transformer, it's defined as follows:

    var res = msg.*::['Body'].*::['Request_x0020_or_x0020_Post.....].toString()

    Which is then mapped: responseMap.put("ImmuResponse", res);

    The response is then sent as follows:

    MSH|.....
    MSA|.....
    QAK|.....
    QPD|.....
    PID|.....
    PD1|.....
    PV1|.....
    ORC|.....
    RXA|.....
    OBX|.....
    ORC|.....

    What I am needing help on is modifying some of the segments in the message prior to reaching its destination. I've looked on the forums but wasn't able to find anything that pertained to this and this is the first time I've had to work with responses.

    Any assistance on this would be greatly appreciated!

    Thank you,
    Matt

    Using Mirth 3.6.1

  • #2
    If I understand correctly that res contains an hl7 string, you can manually call the Serializer to convert to and from xml in a similar fashion to what happens when your transformer datatype is set to hl7v2.

    Serializer example code can be retrieved from the reference section in the transformer with names such as "Convert HL7 v2.x to XML."

    Remember the serializers always return strings, so it's necessary when converting to xml to wrap the return value with a new XML() call in order to convert it to an e4x xml object.


    Code:
    var resRaw = msg.*::['Body'].*::['Request_x0020_or_x0020_Post.....'].toString();
    
    var serializer = SerializerFactory.getSerializer('HL7V2');
    
    var res = new XML(serializer.toXML(resRaw));
    
    res['PID']['PID.1']['PID.1.1'] = 1234;
    
    var resTransformed = serializer.fromXML(res.toXMLString());
    
    responseMap.put("ImmuResponse", resTransformed);
    Last edited by agermano; 09-06-2019, 09:21 AM.

    Comment


    • #3
      This worked for what I needed - thank you so much!

      Matt

      Comment

      Working...
      X