Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Loading attribute from a specific section in XML file

Hi

I need to load the value of attribute "code" from the first "organizer" according to the attribute "name" as a reference;

For example:   load the value of attribute "code" from the section where attribute name="VC". ( I should get S006).

Here is the XML code:

<entry>

     <organizer classCode="BATTERY" moodCode="EVN">

               <code name="VC" codeSystem="2.16.840"/>

               <component>

                         <observation classCode="OBS" moodCode="EVN">

                              <value code="S006" />

                         </observation>

               </component>

     </organizer>

     <organizer classCode="BATTERY" moodCode="EVN">

               <code name="MB" codeSystem="2.16.840"/>

               <component>

                         <observation classCode="OBS" moodCode="EVN">

                              <value code="S003" />

                         </observation>

               </component>

     </organizer>

</entry>

Please help. Thanks.

1 Solution

Accepted Solutions
rbecher
MVP
MVP

Somthing like this:

[publicarEspirometries/ClinicalDocument/component/structuredBody/component/section/entry]:

LOAD

[typeCode],

    [observationMedia/ID],

    [observationMedia/classCode],

    [observationMedia/moodCode],

    [observationMedia/value],

    [observationMedia/value/mediaType],

    [observationMedia/value/representation],

    [observationMedia/templateId/extension],

    [observationMedia/templateId/root],

    [organizer/classCode],

    [organizer/moodCode],

    [organizer/statusCode/code],

    [organizer/code/code],

    [organizer/code/codeSystem],

    [organizer/code/displayName],

    [observation/classCode],

    [observation/moodCode],

    [observation/value/unit],

    [observation/value/xsi:type],

    [observation/value/value],

    [observation/value/code],

    [observation/value/codeSystem],

    [observation/value/codeSystemName],

    [observation/value/displayName],

    [observation/statusCode/code],

    [observation/code/code],

    [observation/code/codeSystem],

    [observation/code/displayName],

    [observation/templateId/extension],

    [observation/templateId/root],

    [%Key_section_8DE2BFA8AE16711D],

    [%Key_entry_531F1B1B7C50DD70]

FROM [lib://Daten/Section1.xml]

(XmlSimple, table is [publicarEspirometries/ClinicalDocument/component/structuredBody/component/section/entry])

Where Match([organizer/code/code], 'MMFVC', 'MMFVCMB');

[publicarEspirometries/ClinicalDocument/component/structuredBody/component/section/entry/organizer/component]:

LOAD

[organizer/classCode],

    [organizer/moodCode],

    [organizer/statusCode/code],

    [sequenceNumber/value],

    [observation/classCode],

    [observation/moodCode],

    [observation/value/unit],

    [observation/value/value],

    [observation/value/xsi:type],

    [observation/value/code],

    [observation/value/displayName],

    [observation/value/codeSystem],

    [observation/value/digits],

    [observation/value/scale/unit],

    [observation/value/scale/value],

    [observation/value/origin/unit],

    [observation/value/origin/value],

    [observation/statusCode/code],

    [observation/code/code],

    [observation/code/codeSystem],

    [observation/code/displayName],

    [observation/templateId/extension],

    [observation/templateId/root],

    [%Key_entry_531F1B1B7C50DD70],

    [%Key_component_FF3ABE3584473A7D]

FROM [lib://Daten/Section1.xml]

(XmlSimple, table is [publicarEspirometries/ClinicalDocument/component/structuredBody/component/section/entry/organizer/component])

Where Exists([%Key_entry_531F1B1B7C50DD70]) AND [observation/code/code] = 'GQC';

- Ralf

Astrato.io Head of R&D

View solution in original post

20 Replies
rbecher
MVP
MVP

Hi Adnan,

this works like expected with the standard xml processing:

// Start of [section.xml] LOAD statements

organizer:

LOAD classCode,

    moodCode,

    [component/observation/classCode] as [observation/classCode],

    [component/observation/moodCode] as [observation/moodCode],

    [component/observation/value/code] as code,

    [code/name] as name,

    [code/codeSystem] as codeSystem

FROM (XmlSimple, Table is [entry/organizer]);

// End of [section.xml] LOAD statements

- Ralf

Astrato.io Head of R&D
rbecher
MVP
MVP

Or in Sense, just drag the xml file into the app and it will create a similar LOAD statement..

Astrato.io Head of R&D
Not applicable
Author

Thank you Ralf.

But what I really want to do is to load the "code" attribute only from the first organizer where name="VC", so I would get the value "S006" only. I don't know how to do this using script.

rbecher
MVP
MVP

You can add a WHERE clause:

[entry/organizer]:

LOAD

    [classCode],

    [moodCode],

    [component/observation/classCode],

    [component/observation/moodCode],

    [component/observation/value/code],

    [code/name],

    [code/codeSystem]

FROM [lib://Daten/section.xml]

(XmlSimple, table is [entry/organizer])

WHERE [code/name] = 'VC';

- Ralf

Astrato.io Head of R&D
johanlindell
Partner - Creator II
Partner - Creator II

Or if you want just the first occurance nomatter code you can add "First":

[entry/organizer]: 

First 1

LOAD  

    [classCode], 

    [moodCode], 

    [component/observation/classCode], 

    [component/observation/moodCode], 

    [component/observation/value/code], 

    [code/name], 

    [code/codeSystem] 

FROM [lib://Daten/section.xml] 

(XmlSimple, table is [entry/organizer])  ;

Not applicable
Author

Hi Ralf

When I added the where statement, the LOAD worked fine on the previous section. But when I applied the same on the original XML file, it loaded empty fields. The XML is well formed. There is only one thing that I doubt; in the original XML file, each organizer has several components as above in the section. It's as follows:

<entry>

     <organizer>

          <component>

          </component>

          <component>

          </component>

     </organizer>

     <organizer>

          <component>

          </component>

          <component>

          </component>

     </organizer>

</entry>

Could this be the issue?

Not applicable
Author

Thanks Johan

It worked. But I need to specify a load condition rather than choosing the first value.

rbecher
MVP
MVP

There should be all components loaded for this organizer. To check this can you post a real sample here?

Astrato.io Head of R&D
jonathandienst
Partner - Champion III
Partner - Champion III

Adapting Ralf's script, possibly this:

[entry/organizer]:

LOAD

    [classCode],

    [moodCode],

    [component/observation/classCode],

    [component/observation/moodCode],

    [component/observation/value/code],

    [code/name],

    [code/codeSystem]

FROM [lib://Daten/section.xml]

(XmlSimple, table is [entry/organizer])

WHERE [code/name] = 'VC' and Len(component) > 0;

or else use the actual fields:

WHERE [code/name] = 'VC' and Len( [component/observation/classCode]) > 0;

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein