Announcement

Collapse
No announcement yet.

looping in xml using aggerate results

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

  • looping in xml using aggerate results

    Hi all, Looked at a few examples on forums but struggling to get this working. I am reading from a DB reader and as aggreate pull, so i get all data in one msg like below. I am trying to take the xml and convert it into a csv

    Input
    Code:
    <results>
        <result>
            <hl7_adt_msh_sending_app> Medical Center</hl7_adt_msh_sending_app>
            <hl7_adt_pv1_admit_date>202107280800</hl7_adt_pv1_admit_date>
        </result>
        <result>
            <hl7_adt_msh_sending_app> Another Medical Center</hl7_adt_msh_sending_app>
            <hl7_adt_pv1_admit_date>202108111200</hl7_adt_pv1_admit_date>
        </result>
    </results>
    Output tree example as Delimted Text
    Code:
    name,admitDate


    In the source transformer i have below as JS

    Code:
    var counter = 0;
    for each(var node in msg['result.result'].children())
    {
    tmp['row'][counter]['column1'] = msg['hl7_adt_msh_sending_app'].toString()
    
    counter++;
    
    }

  • #2
    The problem with your code is you are treating tmp like a non-aggregated result sets, i.e. a row at a time.

    This:

    forM.png

    Gives you:

    forM2.png
    Last edited by pacmano; 09-09-2021, 11:43 AM.
    Diridium Technologies, Inc.
    https://diridium.com

    Comment


    • #3
      Do read https://forums.mirthproject.io/forum...support/16869- though since I wouldn't do it the way I posted it - was just pointing out the concept of tmp.

      In particular, see https://forums.mirthproject.io/forum...389#post100389 from agermano
      Last edited by pacmano; 09-09-2021, 12:14 PM.
      Diridium Technologies, Inc.
      https://diridium.com

      Comment


      • #4
        This issue might be relevant when using the solution mentioned in the previous comment, but it should be getting resolved soon https://github.com/nextgenhealthcare...ct/issues/4400

        Comment

        Working...
        X