Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: distinct-values work-around for Xpath 1.0

From: Richard Braman <rbraman@------------.--->
To: NULL
Date: 4/10/2010 3:33:00 PM
<?xml version="1.0" encoding="UTF-8"?>
<!--I am having a similar problem although my xml is a little more
complicated.  I am trying to dedup the results so that Body Weight, Body
Height, etc only show up once.  This uses XSLT 1.0, so distinct-values()
is not an option :(:-->
<entry typeCode="DRIV">
		<organizer classCode="CLUSTER" moodCode="EVN">
			<templateId root="2.16.840.1.113883.10.20.1.35"/> <!-- Vital signs
organizer template -->
			<id root="c6f88320-67ad-11db-bd13-0800200c9a66"/>
			<code code="46680005" codeSystem="2.16.840.1.113883.6.96"
displayName="Vital signs"/>
			<statusCode code="completed"/>
			<effectiveTime value="19991114"/>
			<component>
				<observation classCode="OBS" moodCode="EVN">
					<templateId root="2.16.840.1.113883.10.20.1.31"/> <!-- Result
observation template -->
					<id root="c6f88321-67ad-11db-bd13-0800200c9a66"/>
					<code code="50373000" codeSystem="2.16.840.1.113883.6.96"
displayName="Body height"/>
					<statusCode code="completed"/>
					<effectiveTime value="19991114"/>
					<value xsi:type="PQ" value="177" unit="cm"/>
				</observation>
			</component>
			<component>
				<observation classCode="OBS" moodCode="EVN">
					<templateId root="2.16.840.1.113883.10.20.1.31"/> <!-- Result
observation template -->
					<id root="c6f88322-67ad-11db-bd13-0800200c9a66"/>
					<code code="27113001" codeSystem="2.16.840.1.113883.6.96"
displayName="Body weight"/>
					<statusCode code="completed"/>
					<effectiveTime value="19991114"/>
					<value xsi:type="PQ" value="86" unit="kg"/>
				</observation>
			</component>
			<component>
				<observation classCode="OBS" moodCode="EVN">
					<templateId root="2.16.840.1.113883.10.20.1.31"/> <!-- Result
observation template -->
					<id root="c6f88323-67ad-11db-bd13-0800200c9a66"/>
					<code code="271649006" codeSystem="2.16.840.1.113883.6.96"
displayName="Systolic BP"/>
					<statusCode code="completed"/>
					<effectiveTime value="19991114"/>
					<value xsi:type="PQ" value="132" unit="mm[Hg]"/>
				</observation>
			</component>
			<component>
				<observation classCode="OBS" moodCode="EVN">
					<templateId root="2.16.840.1.113883.10.20.1.31"/> <!-- Result
observation template -->
					<id root="c6f88324-67ad-11db-bd13-0800200c9a66"/>
					<code code="271650006" codeSystem="2.16.840.1.113883.6.96"
displayName="Diastolic BP"/>
					<statusCode code="completed"/>
					<effectiveTime value="19991114"/>
					<value xsi:type="PQ" value="86" unit="mm[Hg]"/>
				</observation>
			</component>
		</organizer>
	</entry>
	<entry typeCode="DRIV">
		<organizer classCode="CLUSTER" moodCode="EVN">
			<templateId root="2.16.840.1.113883.10.20.1.35"/> <!-- Vital signs
organizer template -->
			<id root="d11275e0-67ae-11db-bd13-0800200c9a66"/>
			<code code="46680005" codeSystem="2.16.840.1.113883.6.96"
displayName="Vital signs"/>
			<statusCode code="completed"/>
			<effectiveTime value="20000407"/>
			<component>
				<observation classCode="OBS" moodCode="EVN">
					<templateId root="2.16.840.1.113883.10.20.1.31"/> <!-- Result
observation template -->
					<id root="d11275e1-67ae-11db-bd13-0800200c9a66"/>
					<code code="50373000" codeSystem="2.16.840.1.113883.6.96"
displayName="Body height"/>
					<statusCode code="completed"/>
					<effectiveTime value="20000407"/>
					<value xsi:type="PQ" value="177" unit="cm"/>
				</observation>
			</component>
			<component>
				<observation classCode="OBS" moodCode="EVN">
					<templateId root="2.16.840.1.113883.10.20.1.31"/> <!-- Result
observation template -->
					<id root="d11275e2-67ae-11db-bd13-0800200c9a66"/>
					<code code="27113001" codeSystem="2.16.840.1.113883.6.96"
displayName="Body weight"/>
					<statusCode code="completed"/>
					<effectiveTime value="20000407"/>
					<value xsi:type="PQ" value="88" unit="kg"/>
				</observation>
			</component>
			<component>
				<observation classCode="OBS" moodCode="EVN">
					<templateId root="2.16.840.1.113883.10.20.1.31"/> <!-- Result
observation template -->
					<id root="d11275e3-67ae-11db-bd13-0800200c9a66"/>
					<code code="271649006" codeSystem="2.16.840.1.113883.6.96"
displayName="Systolic BP"/>
					<statusCode code="completed"/>
					<effectiveTime value="20000407"/>
					<value xsi:type="PQ" value="145" unit="mm[Hg]"/>
				</observation>
			</component>
			<component>
				<observation classCode="OBS" moodCode="EVN">
					<templateId root="2.16.840.1.113883.10.20.1.31"/> <!-- Result
observation template -->
					<id root="d11275e4-67ae-11db-bd13-0800200c9a66"/>
					<code code="271650006" codeSystem="2.16.840.1.113883.6.96"
displayName="Diastolic BP"/>
					<statusCode code="completed"/>
					<effectiveTime value="20000407"/>
					<value xsi:type="PQ" value="88" unit="mm[Hg]"/>
				</observation>
			</component>
		</organizer>
	</entry>
</section>
</component>
<!--My current xslt:-->
<!-- Vital Signs-->
<xsl:template
match="n1:component/n1:section[n1:templateId/@root='2.16.840.1.113883.10
.20.1.16']">
  <xsl:apply-templates select="n1:title" />
  <div id="lblvitals">
	<table width="100%" class="display" id="vitals">
	  <thead>
		  <tr>
			<th align="left">Date</th>
			<xsl:apply-templates select="n1:entry" mode="findDates" />
		</tr>
	  </thead>			
	  <tbody>
		  <xsl:apply-templates select="n1:entry//n1:observation/n1:code"
mode="vitals" />              
	  </tbody>
	  </table>
  </div>
</xsl:template>
<!-- Vital Date Header NOT COMPLETE-->
<xsl:template match="n1:entry" mode="findDates">
  <xsl:variable name="effectiveTime"
select="n1:organizer/n1:effectiveTime/@value"/>
  <xsl:if test="$effectiveTime">
	<th>
	  <xsl:call-template name="formatMediumDate">
		<xsl:with-param name="date" select="$effectiveTime"/>
	  </xsl:call-template>
	</th>
  </xsl:if>
</xsl:template>
<!-- For evey vital type write a row-->
<xsl:template match="n1:entry//n1:observation/n1:code" mode="vitals">
  <xsl:variable name="code" select="@code"/>
   <xsl:variable name="displayName" select="@displayName"/>
  <tr>
	<td>
	  <xsl:value-of select="$displayName" />                    
	</td>
	  <xsl:call-template name="ed">
		<xsl:with-param name="code" select="$code"></xsl:with-param>
		<xsl:with-param name="node"
select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component
/n1:section[n1:templateId/@root='2.16.840.1.113883.10.20.1.16']//n1:obse
rvation/n1:code[@code=$code]/..">            </xsl:with-param>
	  </xsl:call-template> 
  </tr>
</xsl:template>

<xsl:template name="ed">
	<xsl:param name="code" />    
	<xsl:param name="node"></xsl:param>
	<xsl:for-each select="$node/n1:value">
		 <td><xsl:value-of select="@value"></xsl:value-of></td>
	</xsl:for-each>	 
</xsl:template> 
<!--Current Output:-->
<div id="lblvitals">
	<table width="100%" class="display" id="vitals">
		<thead>
			<tr>
				<th align="left">Date</th>
				<th>14-NOV-99</th>
				<th>07-APR-00</th>
			</tr>
		</thead>
		<tbody>
			<tr>
				<td>Body height</td>
				<td>177</td>
				<td>177</td>
			</tr>
			<tr>
				<td>Body weight</td>
				<td>86</td>
				<td>88</td>
			</tr>
			<tr>
				<td>Systolic BP</td>
				<td>132</td>
				<td>145</td>
			</tr>
			<tr>
				<td>Diastolic BP</td>
				<td>86</td>
				<td>88</td>
			</tr>
			<tr>
				<td>Body height</td>
				<td>177</td>
				<td>177</td>
			</tr>
			<tr>
				<td>Body weight</td>
				<td>86</td>
				<td>88</td>
			</tr>
			<tr>
				<td>Systolic BP</td>
				<td>132</td>
				<td>145</td>
			</tr>
			<tr>
				<td>Diastolic BP</td>
				<td>86</td>
				<td>88</td>
			</tr>
		</tbody>
	</table>
</div>


*** Sent via Developersdex http://www.developersdex.com ***


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent