web stats
XML transformer - Page 2 - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #11  
Old 06-05-2019, 04:07 PM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 747
agermano is on a distinguished road
Default

It's having an issue because that particular message does not have an 'execute' child element. What do you need to do in that case?
Reply With Quote
  #12  
Old 06-10-2019, 11:39 PM
Adrien Adrien is offline
Mirth Newb
 
Join Date: Mar 2019
Posts: 9
Adrien is on a distinguished road
Default

In this case, I need to add 'prestataire' between the </ execute> and <NABMs> tags.
Reply With Quote
  #13  
Old 06-11-2019, 11:24 AM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 747
agermano is on a distinguished road
Default

The error is because msg['execute'] does not exist.

I see now under msg.evenementServeurActe.actesNGAP, there are three child elements named acteNGAP. Each of those has has a child named execute and a child named NABMs. Two of the three already have a child named prestataire between execute and NABMs.

Will it always be the case that the first and only the first acteNGAP will be missing prestataire?

Is the prestataire section the same for every message (can you code it statically?)

Is the prestataire section the same for every acteNGAP section within the same message? Would you always be able to copy it from another section or could there sometimes be no prestataire in the entire message?

Code:
var prestataire = msg.evenementServeurActe.actesNGAP.acteNGAP.prestataire;

if (prestataire.length() === 0) {
    // build it
    prestataire = <prestataire>
        <medecins>
            <medecin>
                <numeroAdeli>12345</numeroAdeli>
                <identification>
                    <code>AAA</code>
                    <libelle>BBB</libelle>
                </identification>
            </medecin>
        </medecins>
        <uniteFonctionnelle>
            <code>789</code>
            <libelle>YYY</libelle>
        </uniteFonctionnelle>
    </prestataire>;
} else {
    // copy the first one in the message
    prestataire = prestataire[0].copy();
}

for each (var acteNGAP in msg.evenementServeurActe.actesNGAP.acteNGAP) {
    if (acteNGAP.prestataire.length() === 0) {
        acteNGAP.insertChildAfter(acteNGAP.execute[0], prestataire.copy());
    }
}
Reply With Quote
Reply

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 12:04 AM.


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