<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Generating conditional XML tags and mapping enums in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Generating-conditional-XML-tags-and-mapping-enums/m-p/2308041#M79416</link>
    <description>&lt;P&gt;I am evaluating Talend for the purpose of migrating medical data.&amp;nbsp; One of our requirements is to be able to generate FHIR XML data from existing product databases.&amp;nbsp; For example, we need to create a FHIR Organisation record from the surgery data in our database.&lt;/P&gt; 
&lt;P&gt;The&amp;nbsp;surgery data has four fields for telephone1, telephone1_type, telephone2, telephone2_type.&amp;nbsp; These will be manifested in the Organisation data as:&lt;/P&gt; 
&lt;PRE&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;Organization xmlns="http://hl7.org.fhir"&amp;gt;
	&amp;lt;name value="Slave system"/&amp;gt;
	&amp;lt;telecom&amp;gt;
                &amp;lt;system value="phone"&amp;gt;
		&amp;lt;value value="01254879658"/&amp;gt;
		&amp;lt;use value="voice"/&amp;gt;
	&amp;lt;/telecom&amp;gt;
	&amp;lt;telecom&amp;gt;
                &amp;lt;system value="phone"&amp;gt;
		&amp;lt;value value=""/&amp;gt;
		&amp;lt;use value=""/&amp;gt;
	&amp;lt;/telecom&amp;gt;
&amp;lt;/Organization&amp;gt;&lt;/PRE&gt; 
&lt;P&gt;There are a number of issues with this translation.&amp;nbsp; The telephone number, telephone2, is not present so the second &amp;lt;telecom&amp;gt; tag should be omitted entirely.&lt;/P&gt; 
&lt;P&gt;The telephone1_type field has a value of "voice" but this is not a valid FHIR value for the &amp;lt;use&amp;gt; tag.&amp;nbsp; I need to map the enumerated values in the database to the correct FHIR equivalents and, where the database telephoneX_type fields have the value "Unknown" or NULL I need to omit the &amp;lt;use&amp;gt; tag.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;The only way I can see to remap the enumeration is a messy expression with many nested StringHandling.CHANGE() calls but I can't help thinking that there must be a better way.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;With regard to the conditional tags,&amp;nbsp;I am also aware that tXMLMap has a conditional expression on its outputs but this seems to filter records, not parts of records.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;I have since found the setting that omits null elements but this doesn't eliminate the empty telecom tag because of the literal attribute value "phone".&amp;nbsp; I then thought of replacing the literal value with the expression below.&amp;nbsp; This works but its rather "hacky" and not really a generic solution.&amp;nbsp; Is there a better way to do this?&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;PRE&gt;(Relational.ISNULL(row1.telephone1) || 0 == StringHandling.LEN(StringHandling.TRIM(row1.telephone1))) ? null : "phone" &amp;nbsp;&lt;/PRE&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 03 May 2018 15:55:41 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2018-05-03T15:55:41Z</dc:date>
    <item>
      <title>Generating conditional XML tags and mapping enums</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Generating-conditional-XML-tags-and-mapping-enums/m-p/2308041#M79416</link>
      <description>&lt;P&gt;I am evaluating Talend for the purpose of migrating medical data.&amp;nbsp; One of our requirements is to be able to generate FHIR XML data from existing product databases.&amp;nbsp; For example, we need to create a FHIR Organisation record from the surgery data in our database.&lt;/P&gt; 
&lt;P&gt;The&amp;nbsp;surgery data has four fields for telephone1, telephone1_type, telephone2, telephone2_type.&amp;nbsp; These will be manifested in the Organisation data as:&lt;/P&gt; 
&lt;PRE&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;Organization xmlns="http://hl7.org.fhir"&amp;gt;
	&amp;lt;name value="Slave system"/&amp;gt;
	&amp;lt;telecom&amp;gt;
                &amp;lt;system value="phone"&amp;gt;
		&amp;lt;value value="01254879658"/&amp;gt;
		&amp;lt;use value="voice"/&amp;gt;
	&amp;lt;/telecom&amp;gt;
	&amp;lt;telecom&amp;gt;
                &amp;lt;system value="phone"&amp;gt;
		&amp;lt;value value=""/&amp;gt;
		&amp;lt;use value=""/&amp;gt;
	&amp;lt;/telecom&amp;gt;
&amp;lt;/Organization&amp;gt;&lt;/PRE&gt; 
&lt;P&gt;There are a number of issues with this translation.&amp;nbsp; The telephone number, telephone2, is not present so the second &amp;lt;telecom&amp;gt; tag should be omitted entirely.&lt;/P&gt; 
&lt;P&gt;The telephone1_type field has a value of "voice" but this is not a valid FHIR value for the &amp;lt;use&amp;gt; tag.&amp;nbsp; I need to map the enumerated values in the database to the correct FHIR equivalents and, where the database telephoneX_type fields have the value "Unknown" or NULL I need to omit the &amp;lt;use&amp;gt; tag.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;The only way I can see to remap the enumeration is a messy expression with many nested StringHandling.CHANGE() calls but I can't help thinking that there must be a better way.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;With regard to the conditional tags,&amp;nbsp;I am also aware that tXMLMap has a conditional expression on its outputs but this seems to filter records, not parts of records.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;I have since found the setting that omits null elements but this doesn't eliminate the empty telecom tag because of the literal attribute value "phone".&amp;nbsp; I then thought of replacing the literal value with the expression below.&amp;nbsp; This works but its rather "hacky" and not really a generic solution.&amp;nbsp; Is there a better way to do this?&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;PRE&gt;(Relational.ISNULL(row1.telephone1) || 0 == StringHandling.LEN(StringHandling.TRIM(row1.telephone1))) ? null : "phone" &amp;nbsp;&lt;/PRE&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2018 15:55:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Generating-conditional-XML-tags-and-mapping-enums/m-p/2308041#M79416</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-05-03T15:55:41Z</dc:date>
    </item>
  </channel>
</rss>

