Announcement

Collapse
No announcement yet.

appendChile to XML repeating segment

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

  • appendChile to XML repeating segment

    Hi - I am trying to create an XML message with a repeating segment that has many loops in it. I would like to keep the loops for those segments together in the XML output. When I am using the appendChild, it is creating it at the end of the message. I am pulling the data from a database to an XML message.

    Here is my xml template:
    <specimenInformation>
    <tumorSpecimenInformation>
    </tumorSpecimenInformation>
    </specimenInformation>
    <tests>
    <testName></testName>
    <testCode></testCode>
    <platformTechnology></platformTechnology>
    <testMethodology></testMethodology>
    <testResults></testResults>
    </tests>
    <clinicalTrials>
    <nctID></nctID>
    <titleBrief></titleBrief>
    </clinicalTrials>
    <therapies>
    <therapyName></therapyName>
    </therapies>
    </root>

    Here is part of my code:
    **I pull from a query***
    if (resultTest.getString('Test_Id') == holdTestId)
    {
    // do nothing
    }

    else {

    createSegment('tests', tmp, testCount);
    //createSegmentAfter('tests', tmp['specimenInformation'], testCount);

    testCountD = testCount + 1;

    // test info
    tmp['tests'][testCount]['testName'] = validate(resultTest.getString('Test'), '');
    tmp['tests'][testCount]['testCode'] = validate(resultTest.getString('Compendium_Id'), '');
    tmp['tests'][testCount]['platformTechnology'] = validate(resultTest.getString('Technology'), '');
    tmp['tests'][testCount]['testMethodology'] = validate(resultTest.getString('Method'), '');

    testCountResults = testCount;
    testCount++;
    resultIndex = 1;
    resultCount = 0;

    }

    **based on test, I have a switch setup to send over different type of results**
    switch(String(resultTest.getString('Technology'))) {

    case 'NGS':
    var resultStr = <testResults/>;

    tmp['tests'][testCountResults].appendChild(resultStr);

    break;

    case 'CNA':
    var resultStr = <testResults/>;

    tmp['tests'][testCountResults].appendChild(resultStr);

    break;

    then I have a new query for the therapies and clinical trials:
    var caseDrugs = executeCachedQuery(dbConn, caseDrugQuery);

    caseDrugsCount = 0;

    while (caseDrugs.next()) {
    tmp['therapies']['therapyName'][caseDrugsCount] = caseDrugs.getString('Drugs');
    caseDrugsCount++;
    }

    and
    var caseCTCs = executeCachedQuery(dbConn, ctcQuery);

    ctcCount = 0;

    while (caseCTCs.next()){
    tmp['clinicalTrials']['nctID'][ctcCount] = caseCTCs.getString('NCT_ID');
    tmp['clinicalTrials']['titleBrief'][ctcCount] = caseCTCs.getString('BRIEF_TITLE');
    ctcCount++;
    }

    The output of the xml looks like this:
    <specimenInformation>
    data here
    </specimenInformation>
    <tests>
    <testName></testName>
    <testCode></testCode>
    <platformTechnology></platformTechnology>
    <testMethodology></testMethodology>
    <testResults>
    1 test result here
    </testResults>
    </tests>
    <clinicalTrials> then case clinical trials</clinicalTrials>
    <therapies>
    <therapyName/>case therapies <therapyName/>
    </therapies>
    <tests>
    <testName></testName>
    <testCode></testCode>
    <platformTechnology></platformTechnology>
    <testMethodology></testMethodology>
    <testResults>
    then the other tests and test results start
    </testResults>
    </tests>


    I would like the other test results to appear before the clincial trials and therapies for the case.

  • #2
    Use insertBefore or insertAfter

    Comment


    • #3
      I tried createSegmentAfter. This did put them before the clinical trials tag, but it left out the test information except for the last test. Then it added the test results to the last test.
      </specimenInformation>
      <tests/>
      <tests/>
      <tests/>
      <tests/>
      <tests/>
      <tests/>
      <tests/>
      <tests/>
      <tests/>
      <tests/>
      <tests/>
      <tests/>
      <tests>
      <testName>test</testName>
      <testCode>testcode</testCode>
      <platformTechnology>testTech</platformTechnology>
      <testMethodology>testMethod</testMethodology>
      <testResults>



      I tried to use insertAfter, but is said not defined.

      Comment

      Working...
      X