web stats
Repeating Elements in XML - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Thread Tools Display Modes
Old 04-03-2017, 01:24 PM
nadipallyck1 nadipallyck1 is offline
Mirth Newb
Join Date: Mar 2017
Posts: 18
nadipallyck1 is on a distinguished road
Default Repeating Elements in XML


I am doing a mapping from an XML to CCD. I have a sample input XML in inbound template and sample CCD in outbound template. I am able to map non repeating elements but facing problem with repeating elements. For every repeating element in the input file I am unable to create a new instance in output CCD. Right now I am working on "author". I gave many tries with loops but couldn't figure out the exact logic. Can anyone please help in writing correct code? Thanks in advance.

I am using Mirth version

I am attaching the channel with this thread. The respective author information is present in eCrew section of my input xml. eCrew.01 is the authour id.

Please help.

Attached Files
File Type: xml Nemsis to CCD doc.xml (155.2 KB, 19 views)
Reply With Quote
Old 04-04-2017, 08:47 AM
cbarlow cbarlow is offline
OBX.2 Kenobi
Join Date: Sep 2015
Location: Missouri
Posts: 52
cbarlow is on a distinguished road

Start with this. You will need to tweak but this should point you in the right direction. This is how in standard XML you add to a repeating outbound XML.

PHP Code:
for each(eCrew in msg['Header']['PatientCareReport']['eCrew']['eCrew.CrewGroup']) {

author = <author>


Reply With Quote
Old 04-04-2017, 01:20 PM
nadipallyck1 nadipallyck1 is offline
Mirth Newb
Join Date: Mar 2017
Posts: 18
nadipallyck1 is on a distinguished road

Thank you very much for the reply. I tried your suggestion but not getting the desired output. I tried something like this

count = msg['Header']['PatientCareReport']['eCrew']['eCrew.CrewGroup'].length();
for(i = 0; i < count; i++)
tmp.*::['author'][i] = new XML(tmp.*::['author']);
tmp.*::['author'][i].*::['time']['@value'] = date;
tmp.*::['author'][i].*::['assignedAuthor'].*::['id']['@root'] = msg['Header']['PatientCareReport']['eCrew']['eCrew.CrewGroup'][i]['eCrew.01'].toString();

It is creating the new instance with correct mapping but it is appending at the end of the document instead of at author. I tried insertBefore(tmp.*::['custodian']) (where it should append) for appending it at right place but it is not working. Can you suggest me correct logic for appending it?
Reply With Quote
Old 04-04-2017, 10:35 PM
siddharth siddharth is offline
Mirth Guru
Join Date: Feb 2013
Posts: 832
siddharth is on a distinguished road

You did not follow his (cbarlows) suggestion at all.

He instructed to build a CCD XML in the transformer Javascript using ECMA script. Either that way or you use the .*:: operator in the right manner. But a mix of both will not work.

Last edited by siddharth; 04-04-2017 at 10:36 PM. Reason: correction
Reply With Quote

ccd., repeating, xml

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:27 AM.

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