<?xml version="1.0" encoding="UTF-8"?>
<!--

Stylesheet for epicrisis templates
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:urn="urn:hl7-org:v3" xmlns:ext="urn:hl7-EE-DL-Ext:v1">
	<!--

	Main epicrisis template which includes content rows
	-->
	<xsl:template name="structuredBody.pregnancyGeneral" match="urn:structuredBody" mode="pregnancyGeneral">
		<!-- patsient-->
		<xsl:if test="../../urn:recordTarget">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="../../urn:recordTarget" mode="epicrises"/>
				</td>
			</tr>
		</xsl:if>
		<!--riiklik pension-->
		<xsl:if test="../../urn:recordTarget/urn:patientRole/urn:patient/ext:patientPerson/ext:asOtherIDs">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="../../urn:recordTarget/urn:patientRole/urn:patient/ext:patientPerson/ext:asOtherIDs" mode="pension"/>
				</td>
			</tr>
		</xsl:if>
		<!-- patsiendi perearst-->
		<xsl:if test="../../urn:recordTarget/urn:patientRole/urn:patient/ext:asPatientOfOtherProvider">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="../../urn:recordTarget/urn:patientRole/urn:patient/ext:asPatientOfOtherProvider/ext:providerOrganization" mode="practitioner"/>
				</td>
			</tr>
		</xsl:if>
		<!--veregrupp-->
		<xsl:if test="urn:component/urn:section[urn:code/@code='BLRH']">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='BLRH']" mode="bloodRh"/>
				</td>
			</tr>
		</xsl:if>
		<!--biloogiline isa-->
		<xsl:if test="../../urn:participant[@typeCode='SBJ']/urn:associatedEntity">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="../../urn:participant[@typeCode='SBJ']/urn:associatedEntity" mode="bFather"/>
				</td>
			</tr>
		</xsl:if>
		<!--patsiendi terviseseisundi andmed-->
		<tr>
			<td class="tableBlock">
				<table>
					<tr>
						<td class="blockLabel">PATSIENDI TERVISESEISUNDI ANDMED</td>
					</tr>
					<!--allegria-->
					<xsl:if test="urn:component/urn:section[urn:code/@code='ALL']">
					<tr>
						<td>
							<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='ALL']" mode="diagnoses"/>
						</td>
					</tr>
					</xsl:if>
					<!--eelnevad haigused-->
					<xsl:if test="urn:component/urn:section[urn:code/@code='PASTDGN']">
					<tr>
						<td>
							<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='PASTDGN']" mode="diagnoses"/>
						</td>
					</tr>
					<!--eelnevad operatsioonid-->
					</xsl:if>
					<xsl:if test="urn:component/urn:section[urn:code/@code='PASTSUR']">		
					<tr>
						<td>
							<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='PASTSUR']" mode="procedures"/>
						</td>
					</tr>
					</xsl:if>
					<!--eelnevad vereülekanded-->
					<xsl:if test="urn:component/urn:section[urn:code/@code='PASTPROC']">		
					<tr>
						<td>
							<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='PASTPROC']" mode="procedures"/>
						</td>
					</tr>
					</xsl:if>
					<!--lisateave ohutegurite kohta-->
					<xsl:if test="../../urn:recordTarget/urn:patientRole/urn:patient/ext:patientPerson/ext:riskCode">
					<tr>
						<td class="blockLabel">Lisateave tervise ohutegurite kohta</td>
					</tr>
					<xsl:for-each select="../../urn:recordTarget/urn:patientRole/urn:patient/ext:patientPerson/ext:riskCode">
					<tr>
						<td>
							<xsl:value-of select="@displayName"/>
							<xsl:text>:  </xsl:text>
							<xsl:value-of select="ext:originalText"/>	
						</td>
					</tr>
					</xsl:for-each>	
					</xsl:if>	
				</table>
			</td>
		</tr>		
		<!--Eelnevad rasedused (ütluspõhine)-->
		<xsl:if test="urn:component/urn:section[urn:code/@code='PASTPRGN']">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='PASTPRGN']" mode="pastPregnancy"/>
				</td>
			</tr>
		</xsl:if>
	</xsl:template>
</xsl:stylesheet>

