Announcement

Collapse
No announcement yet.

Delete segment xml

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

  • Delete segment xml

    Good. Could someone tell me how I can delete the SPM segment of this message in XML format?

    <OUL_R24.SPECIMEN>
    <SPM>
    <SPM.1>1</SPM.1>
    <SPM.2>
    <EIP.1>
    <EI.1></EI.1>
    </EIP.1>
    <EIP.2>
    <EI.1></EI.1>
    </EIP.2>
    </SPM.2>
    <SPM.4>
    <CWE.1</CWE.1>
    </SPM.4>
    <SPM.18>
    <TS.1></TS.1>
    </SPM.18>
    <SPM.20>Y</SPM.20>
    </SPM>
    <OBX>
    <OBX.1>1</OBX.1>
    <OBX.2>NM</OBX.2>
    <OBX.3>
    <CE.1>EC</CE.1>
    <CE.2></CE.2>
    <CE.3>LN</CE.3>
    </OBX.3>
    <OBX.6>
    <CE.1>seg</CE.1>
    </OBX.6>
    <OBX.7></OBX.7>
    <OBX.8>N</OBX.8>
    <OBX.11>I</OBX.11>
    </OBX>
    <OBX>
    <OBX.1>2</OBX.1>
    <OBX.2>NM</OBX.2>
    <OBX.3>
    <CE.1></CE.1>
    <CE.2></CE.2>
    <CE.3>LN</CE.3>
    </OBX.3>
    <OBX.6>
    <CE.1>seg</CE.1>
    </OBX.6>
    <OBX.7></OBX.7>
    <OBX.8>N</OBX.8>
    <OBX.11>D</OBX.11>
    <OBX.14>
    <TS.1>20190408171238</TS.1>
    </OBX.14>
    </OBX>
    </OUL_R24.SPECIMEN>

  • #2
    delete msg['SPM']

    Comment


    • #3
      delete msg['SPM']
      Best,

      Kirby

      Mirth Certified|Epic Bridges Certified|Cloverleaf Level 2 Certified

      Appliance Version 3.11.4
      Mirth Connect Version 3.8.0
      Java Version 1.6.0_45-b06
      Java (64 bit) Version 1.6.0_45-b06
      Java 7 (64 bit) Version 1.7.0_151-b15
      Java 8 (64 bit) Version 1.8.0_181-b13
      PostgreSQL Version 9.6.8

      Comment


      • #4
        It doesn't work for me

        Comment


        • #5
          Can you tell us why it doesn't work? Do you receive an error?

          Perhaps the message isn't HL7? I thought you were posting the xml transformed step, but maybe your message is XML?
          Best,

          Kirby

          Mirth Certified|Epic Bridges Certified|Cloverleaf Level 2 Certified

          Appliance Version 3.11.4
          Mirth Connect Version 3.8.0
          Java Version 1.6.0_45-b06
          Java (64 bit) Version 1.6.0_45-b06
          Java 7 (64 bit) Version 1.7.0_151-b15
          Java 8 (64 bit) Version 1.8.0_181-b13
          PostgreSQL Version 9.6.8

          Comment


          • #6
            try this....

            msg = delete msg['SPM'];

            Comment


            • #7
              I receive the message in xml format

              Comment


              • #8
                delete msg['SPM'] worked for me after I fixed the typo (CWE.1 is missing the >.)

                Kirby asked if you were getting an error. What else is your transformer doing? Are you using an outbound template?

                Comment


                • #9
                  I am using this transformer. I managed to delete the first segment, but I can't get the rest of the message deleted

                  var con = 0;
                  for each( spm in msg['OUL_R24.ORDER'][con]['OUL_R24.SPECIMEN']){

                  delete spm['SPM'][con];
                  con++;
                  }

                  Comment


                  • #10
                    I have already solved. Thank you

                    Comment


                    • #11
                      Can you post the resolution?
                      Best,

                      Kirby

                      Mirth Certified|Epic Bridges Certified|Cloverleaf Level 2 Certified

                      Appliance Version 3.11.4
                      Mirth Connect Version 3.8.0
                      Java Version 1.6.0_45-b06
                      Java (64 bit) Version 1.6.0_45-b06
                      Java 7 (64 bit) Version 1.7.0_151-b15
                      Java 8 (64 bit) Version 1.8.0_181-b13
                      PostgreSQL Version 9.6.8

                      Comment


                      • #12
                        for (var i = 0; i < getArrayOrXmlLength(msg['OUL_R24.ORDER']['OUL_R24.SPECIMEN']); i++) {

                        delete msg['OUL_R24.ORDER'][i]['OUL_R24.SPECIMEN']['SPM'];

                        }

                        Comment


                        • #13
                          The other answers did work for your example in the first post, but you weren't giving us the whole picture. Something like this should also work:

                          Code:
                          for each (var spm in msg['OUL_R24.ORDER']['OUL_R24.SPECIMEN']['SPM']) {
                              delete spm[0];
                          }
                          You've actually got your index in the wrong place in your solution. It might work some of the time, but it would likely break if there were ever more than one OUL_R24.SPECIMEN per OUL_R24.ORDER.

                          Based on your loop, it should be:
                          Code:
                          delete msg['OUL_R24.ORDER']['OUL_R24.SPECIMEN'][i]['SPM'];

                          Comment

                          Working...
                          X