简体   繁体   中英

Mirth channel XML : how to read multiple values from inside of an elements

How to read a list of values from Mirth Channel XML's element? How to read multiple same type of tag and assign to Outbound XML Message Template.

<patient>

<result>    
  <name>Name-1</name>
</result>


 <result>    
  <name>Name-2</name>
 </result>

<patient>

If there is same values for Names defined, then simply performing msg['patient']['result']['name'] will return the value. But how to get values if the names return more than one different names? How to iterate and display in the same XML? I am doing Mirth for the first time and any help is appreciated.

I saw one example.

var nameLen = msg['result']['name'].length();
for(i=0;i<nameLen;i++){
// Your Mapping Logic
logger.debug(msg['result']['name'][i].toString());
}

But its not complete, How to assign this var and loop with Outbound Message XML Template in Mirth Connect ?

Please I need anyone help in this regard to solve this problem.

Thanks

For HL7 v3 messages you need to move in Transformers tab in your destination and define the outbound template as HL7 v3.

And when you loop through to get a value if you plan to use that value further into outbound template you can use that either via putting in channelMap by simply putting it like :

channelMap.put("name_of_your_key", "your_value");

and in outbound template retrieve it like:

channelMap.get("name_of_your_key");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM