<?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.pregnancy" match="urn:structuredBody" mode="pregnancy">
		<!-- 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>
		<!--puude ja töövõimetuse andmed-->
	<xsl:if test="urn:component/urn:section[urn:code/@code='DISABL']">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='DISABL']" mode="disability"/>
				</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>
		<!--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>
					<!--
					<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>
					</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>
					<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><span class="rowTitle">
							<xsl:value-of select="@displayName"/></span>
							<xsl:text>  </xsl:text>
							<span class="rowValue">
							<xsl:value-of select="ext:originalText"/></span>
						</td>
					</tr>
					</xsl:for-each>	
					</xsl:if>	
				</table>
			</td>
		</tr>		
		<!--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>
		<!--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>
		<!--Eelnevad rasedused (DL)-->
		<xsl:if test="urn:component/urn:section[urn:code/@code='PAST_PRGN_DL']">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='PAST_PRGN_DL']" mode="pregnancyDL"/>
				</td>
			</tr>
		</xsl:if>
		<!--Antud raseduse arvelevõtmise andmed-->
		<xsl:if test="urn:component/urn:section[urn:code/@code='PRGN']">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='PRGN']" mode="currentPregnancy"/>
				</td>
			</tr>
		</xsl:if>	
		<!--Kestva raseduse vastuvõtud-->
		<xsl:if test="urn:component/urn:section[urn:code/@code='ENC']">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='ENC']" mode="currentPregnancyEncounter"/>
				</td>
			</tr>
		</xsl:if>	
		<!--Kestva raseduse vastuvõtud-->
		<xsl:if test="urn:component/urn:section[urn:code/@code='ENC']">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='ENC']" mode="pregnancyTable"/>
				</td>
			</tr>
		</xsl:if>		
		<!--Analüüsid-->
				<xsl:if test="urn:component/urn:section[urn:code/@code='ANA']">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='ANA']" mode="tests"/>
				</td>
			</tr>
		</xsl:if>
		<!--Uuringud-->
		<xsl:if test="urn:component/urn:section[urn:code/@code='PROC']">		
		<tr>
			<td class="tableBlock">
				<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='PROC']" mode="statProcedures"/>
			</td>
		</tr>
		</xsl:if>
		<!--ERIARSTIDE KONSULTATSIOONID (Digilugu)-->
		<xsl:if test="urn:component/urn:section[urn:code/@code='CONSULT']">		
		<tr>
			<td class="tableBlock">
				<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='CONSULT']" mode="consult"/>
			</td>
		</tr>
		</xsl:if>
		<!--GRAVIDOGRAMM-->
			<tr>
				<td class="tableBlock">
					<xsl:text>SIIA TULEB "SÜMFUUS - FUNDUSE MÕÕT"</xsl:text>
					<xsl:text>x - telg: rasedusnädal, y - telg: emakapõhja kõrgus (cm)</xsl:text>
				</td>
			</tr>
		<!--VAGINAALNE VAATLUS-->
		<xsl:if test="urn:component/urn:section[urn:code/@code='PELVIS_PROC']">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='PELVIS_PROC']" mode="pelvis"/>
				</td>
			</tr>
		</xsl:if>
		
		<!--väljastatud dokumendid-->
		<xsl:if test="urn:component/urn:section[urn:code/@code='DOC']">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='DOC']" mode="documents"/>
				</td>
			</tr>
		</xsl:if>
		<!--SÜNNIEPIKRIIS VÕI EMA STATS: EPIKRIIS-->
		<xsl:if test="urn:component/urn:section[urn:code/@code='PRGN_DL']">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='PRGN_DL']" mode="pregnancyDL"/>
				</td>
			</tr>
		</xsl:if>
		
	</xsl:template>
</xsl:stylesheet>

