<?xml version="1.0" encoding="UTF-8"?>
<!--
Stylesheet for referral templates
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:urn="urn:hl7-org:v3">
	<!--
	Main referral template which includes content rows
	-->
	<xsl:template name="structuredBody.referral" match="urn:structuredBody" mode="referral">
		
		<!-- Patsient -->
		<xsl:if test="../../urn:recordTarget">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="../../urn:recordTarget" mode="epicrises"/>
				</td>
			</tr>
		</xsl:if>
		
		<!-- Suunaja andmed -->
		<xsl:if test="urn:component/urn:section[urn:code/@code='REF']">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='REF']/urn:entry/urn:act/urn:performer/urn:assignedEntity" mode="attender"/>
				</td>
			</tr>
		</xsl:if>
		<!-- Suunatud -->
		<xsl:if test="urn:component/urn:section[urn:code/@code='DIR']">
			<tr>
				<td  class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='DIR']" mode="refs"/>
				</td>
			</tr>
		</xsl:if>
		<!-- Diagnoosid -->
		<xsl:if test="urn:component/urn:section[urn:code/@code='DGN']">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='DGN']" mode="referralDiagnose"/>
				</td>
			</tr>
		</xsl:if>
		<!-- Anamnees, staatus -->
		<xsl:if test="urn:component/urn:section[urn:code/@code='ANAM']">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='ANAM']" mode="text"/>
				</td>
			</tr>
		</xsl:if>
		
		<tr>
			<td class="tableBlock">
				<!-- call template for procedures, surgery and tests -->
				<xsl:call-template name="procedures"/>
			</td>
		</tr>
		<xsl:if test="urn:component/urn:section[urn:code/@code='INFO']">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='INFO']" mode="text"/>
				</td>
			</tr>
		</xsl:if>
		<xsl:if test="urn:component/urn:section[urn:code/@code='REGIME']">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='REGIME']" mode="regime"/>
				</td>
			</tr>
		</xsl:if>
	</xsl:template>
</xsl:stylesheet>
