<?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.periodontalCase" match="urn:structuredBody" mode="periodontalCase">
		<!-- patsient-->
		<xsl:if test="../../urn:recordTarget">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="../../urn:recordTarget" mode="epicrises"/>
				</td>
			</tr>
		</xsl:if>
		<!-- muu osaleja /eestkostja-->
		<xsl:if test="../../urn:recordTarget/urn:patientRole/urn:patient/urn:guardian">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="../../urn:recordTarget/urn:patientRole/urn:patient" mode="guardian"/>
				</td>
			</tr>
		</xsl:if>
		<!-- suunaja-->
		<xsl:if test="../../urn:componentOf/urn:encompassingEncounter/urn:encounterParticipant[@typeCode='REF']/urn:assignedEntity">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="../../urn:componentOf/urn:encompassingEncounter/urn:encounterParticipant[@typeCode='REF']/urn:assignedEntity" mode="refattender"/>
				</td>
			</tr>
		</xsl:if>
		<!-- saatekiri/tellimus-->
		<xsl:if test="../../urn:inFulfillmentOf/urn:order">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="../../urn:inFulfillmentOf/urn:order" mode="reference"/>
				</td>
			</tr>
		</xsl:if>
		<!-- ravijuhtum-->
		<xsl:if test="../../urn:componentOf/urn:encompassingEncounter">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="../../urn:componentOf/urn:encompassingEncounter" mode="careEncounter"/>
				</td>
			</tr>
		</xsl:if>
		<!--Allergia-->
		<xsl:if test="urn:component/urn:section[urn:code/@code='ALL']">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='ALL']" mode="diagnoses"/>
				</td>
			</tr>
		</xsl:if>
		<!--Patsiendi terviseandmed-->
		<xsl:if test="urn:component/urn:section[urn:code/@code='250171008']">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='250171008']" mode="healthData"/>
				</td>
			</tr>
		</xsl:if>
		<!--viidad eelmistele ortodontiliste ravijuhtumite dokumentidele-->
		<xsl:if test="urn:component/urn:section[urn:code/@code='71369009']">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='71369009']" mode="pregnancyDL"/>
				</td>
			</tr>
		</xsl:if>
		<!--KLIINILINE VAATLUS-->
		<xsl:if test="urn:component/urn:section[urn:code/@code='251322003']">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='251322003']" mode="clinicalObservation"/>
				</td>
			</tr>
			<!--Karioloogiline tabel: Piimahambad-->
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='251322003']" mode="teethStatusTable_K_Child">
					<xsl:with-param name="showLink" select="'Jah'"/>
					</xsl:apply-templates>
				</td>
			</tr>
			<!--Ortodontiline tabel: Piimahambad-->
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='251322003']" mode="teethStatusTable_O_Child">
					<xsl:with-param name="showLink" select="'Jah'"/>
					</xsl:apply-templates>
				</td>
			</tr>
		<!--Karioloogiline tabel-->
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='251322003']" mode="teethStatusTable_K">
					<xsl:with-param name="showLink" select="'Jah'"/>
					</xsl:apply-templates>
				</td>
			</tr>
		<!--Parodontiline tabel: Jäävhambad-->
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='251322003']" mode="teethStatusTable_P">
					<xsl:with-param name="showLink" select="'Jah'"/>
					</xsl:apply-templates>
				</td>
			</tr>
		<!--Ortodontiline tabel: Jäävhambad-->
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='251322003']" mode="teethStatusTable_O">
					<xsl:with-param name="showLink" select="'Jah'"/>
					</xsl:apply-templates>
				</td>
			</tr>
		<!--Staatuste detailandmed : Jäävhambad-->
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='251322003']" mode="teethStatusDetail">
					</xsl:apply-templates>
				</td>
			</tr>
		</xsl:if>
		<!--LIIGESE JA LIHASTE FUNKTSIOONIDE HINDAMINE-->
		<xsl:if test="urn:component/urn:section[urn:code/@code='95522001']">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='95522001']" mode="tempMovement"/>
				</td>
			</tr>
		</xsl:if>
		<!--RÖNTGENANALÜÜS-->
		<xsl:if test="urn:component/urn:section[urn:code/@code='22891007']">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='22891007']" mode="teethRadiography"/>
				</td>
			</tr>
		</xsl:if>
		<!--TSEFALOMEETRILISE ANALÜÜSI KOKKUVÕTE-->
		<xsl:if test="urn:component/urn:section[urn:code/@code='19961003']">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='19961003']" mode="cephalogram"/>
				</td>
			</tr>
		</xsl:if>
		<!--RAVIVÕIMALUSED-->
		<xsl:if test="urn:component/urn:section[urn:code/@code='182890002']">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='182890002']" mode="anomaly"/>
				</td>
			</tr>
		</xsl:if>
		<!--ORTODONTILISE RAVI AJAL SOOVITATUD PROTSEDUURID-->
		<xsl:if test="urn:component/urn:section[urn:code/@code='38592005']">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='38592005']" mode="info"/>
				</td>
			</tr>
		</xsl:if>
		<!--RAVI EESMÄRK-->
		<xsl:if test="urn:component/urn:section[urn:code/@code='397688009']">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='397688009']" mode="info"/>
				</td>
			</tr>
		</xsl:if>
		<!--AKTSEPTEERITUD RAVIPLAAN-->
		<xsl:if test="urn:component/urn:section[urn:code/@code='314846003']">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='314846003']" mode="info"/>
				</td>
			</tr>
		</xsl:if>
		<!--PLANEERITUD RAVIETAPPIDE AJAKAVA-->
		<xsl:if test="urn:component/urn:section[urn:code/@code='261774000']">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='261774000']" mode="treatmentPlan"/>
				</td>
			</tr>
		</xsl:if>
		<!--TEOSTATUD TÖÖD-->
		<xsl:if test="urn:component/urn:section[urn:code/@code='182992009']">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='182992009']" mode="dentalVisit">
					<xsl:with-param name="diagnose" select="'Ei'"/>
					</xsl:apply-templates>
				</td>
			</tr>
		</xsl:if>
		<!--RETSEPTID JA RAVIMID-->
		<xsl:if test="urn:component/urn:section[urn:code/@code='DRUG']">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='DRUG']" mode="drugs"/>
				</td>
			</tr>
		</xsl:if>
		<!--VÄLJASTATUD SAATEKIRJAD (Digilugu)-->
		<xsl:if test="urn:component/urn:section[urn:code/@code='183851006']">		
		<tr>
			<td class="tableBlock">
				<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='183851006']" mode="consult"/>
			</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>
		<!--Kokkuvõte ja ravi lõpetamise põhjus-->
		<xsl:if test="urn:component/urn:section[urn:code/@code='SUM']">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='SUM']" mode="text"/>
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='SUM']" mode="careEndReason"/>
				</td>
			</tr>
		</xsl:if>
		<!--Ravijärgsed soovitused-->
		<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="info"/>
				</td>
			</tr>
		</xsl:if>
		<!--Märkused-->
		<xsl:if test="urn:component/urn:section[urn:code/@code='REM']">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='REM']" mode="info"/>
				</td>
			</tr>
		</xsl:if>
	</xsl:template>
</xsl:stylesheet>

