<?xml version="1.0" encoding="UTF-8"?>
<!--
  Title: Modular CDA XSL StyleSheet
  Original Filename: cda_modular.xsl 
  Intended for use with: headers.xsl, style.xsl, utility.xsl, cda.css
  Version: 3.0
  Revision History: 8/12/09 Jingdong Li updated 
  Specification: ANSI/HL7 CDA, R2-2005  
  The current version and documentation are available at www.alschulerassociates.com/cda/?topic=cda-xsl. 
  We welcome feedback to tools@alschulerassociates.com
  The stylesheet is the cumulative work of several developers; the most significant prior milestones were the foundation work from HL7 
  Germany and Finland (Tyylitiedosto) and HL7 US (Calvin Beebe), and the presentation approach from Tony Schaller, medshare GmbH provided at IHIC 2009. 
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:n1="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<xsl:include href="headers.xsl"/>
	<xsl:include href="style.xsl"/>
	<xsl:output method="html" indent="yes" version="4.01" encoding="ISO-8859-1" doctype-system="http://www.w3.org/TR/html4/strict.dtd" doctype-public="-//W3C//DTD HTML 4.01//EN"/>
	<!-- global variable title -->
	<xsl:variable name="title">
		<xsl:choose>
			<xsl:when test="string-length(/n1:ClinicalDocument/n1:title)  &gt;= 1">
				<xsl:value-of select="/n1:ClinicalDocument/n1:title"/>
			</xsl:when>
			<xsl:when test="/n1:ClinicalDocument/n1:code/@displayName">
				<xsl:value-of select="/n1:ClinicalDocument/n1:code/@displayName"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:text>Clinical Document</xsl:text>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:variable>
	<!-- Main -->
	<xsl:template match="/">
		<xsl:apply-templates select="n1:ClinicalDocument"/>
	</xsl:template>
	<!-- produce browser rendered, human readable clinical document	-->
	<xsl:template match="n1:ClinicalDocument">
		<html>
			<xsl:comment>
					Do not edit this HTML directly, it was generated by an XSLT transformation from a source CDA document. 
					The stylesheet which produced this display of the CDA document was most recently updated by Jingdong Li, AALLC, on November 13, 2008. 
					The current version and documentation are always available at www.alschulerassociates.com/cda/?topic=cda-tools. We welcome feedback to ___@alschulerassociates.com
					The stylesheet is the cumulative work of several developers; the most significant prior milestones were the foundation work from HL7 Finland
(Tyylitiedosto) and HL7 US (Calvin Beebe), and the presentation approach from [[the Swiss]].
			</xsl:comment>
			<head>
				<title>
					<xsl:value-of select="$title"/>
				</title>
				<link rel="stylesheet" type="text/css" href="cda.css"/> 
			</head>
		<body>
			<h1 class="h1center"><xsl:value-of select="$title"/></h1>
			<!-- START display top portion of clinical document -->
				<xsl:call-template name="recordTarget"/>
				<xsl:call-template name="documentGeneral"/>
				<xsl:call-template name="documentationOf"/>
				<xsl:call-template name="author"/>
				<xsl:call-template name="componentof"/>
				<xsl:call-template name="participant"/>
				<xsl:call-template name="dataEnterer"/>
				<xsl:call-template name="authenticator"/>
				<xsl:call-template name="informant"/>
				<xsl:call-template name="informationRecipient"/>
				<xsl:call-template name="legalAuthenticator"/>
				<xsl:call-template name="custodian"/>
			<!-- END display top portion of clinical document -->
			
			<!-- produce table of contents -->
			<xsl:call-template name="make-tableofcontents"/>
			<hr align="left" color="teal" size="2" width="80%" />
			<!-- produce human readable document content -->
			<xsl:apply-templates select="n1:component/n1:structuredBody|n1:component/n1:nonXMLBody"/> 
			<br />
			<hr align="left" color="teal" size="2" width="80%" />
			<br />
		</body>
		</html>
	</xsl:template>
	<!-- generate table of contents -->
	<xsl:template name="make-tableofcontents">
		<h2>
			<a name="toc">Table of Contents</a>
		</h2>
		<ul>
			<xsl:for-each select="n1:component/n1:structuredBody/n1:component/n1:section/n1:title">
				<li>
					<a href="#{generate-id(.)}">
						<xsl:value-of select="."/>
					</a>
				</li>
			</xsl:for-each>
		</ul>
	</xsl:template>
</xsl:stylesheet>
