<?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.nursingEpicrisis" match="urn:structuredBody" mode="nursingEpicrisis">
	
	<!--patsient ja kontaktisikud-->
				<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>
		
		<!--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>
		
		<!--suunaja arst-->
		<xsl:if test="../../urn:componentOf/urn:encompassingEncounter/urn:encounterParticipant[@typeCode='REF']/urn:assignedEntity[urn:code/@code='DOCTOR']">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="../../urn:componentOf/urn:encompassingEncounter/urn:encounterParticipant[@typeCode='REF']/urn:assignedEntity[urn:code/@code='DOCTOR']" mode="refattender"/>
				</td>
			</tr>
		</xsl:if>
		
		<!--suunaja kontaktisik-->
		<xsl:if test="../../urn:componentOf/urn:encompassingEncounter/urn:encounterParticipant[@typeCode='REF']/urn:assignedEntity[urn:code/@code='CONTACT']">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="../../urn:componentOf/urn:encompassingEncounter/urn:encounterParticipant[@typeCode='REF']/urn:assignedEntity[urn:code/@code='CONTACT']" mode="contactrefattender"/>
				</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>
		
		<!-- raviarst-->
				<xsl:if test="../../urn:componentOf/urn:encompassingEncounter/urn:encounterParticipant[@typeCode='ATND']/urn:assignedEntity">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="../../urn:componentOf/urn:encompassingEncounter/urn:encounterParticipant[@typeCode='ATND']/urn:assignedEntity" mode="doctor"/>
				</td>
			</tr>
		</xsl:if>

		<!--haigusjuhtum-->
		<xsl:if test="../../urn:componentOf/urn:encompassingEncounter">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="../../urn:componentOf/urn:encompassingEncounter" mode="encompassingEncounter">
						<xsl:with-param name="encounterType" select="'nurse'"/>
					</xsl:apply-templates>
				</td>
			</tr>
		</xsl:if>
		
		<!-- õendusanamnees-->
		<xsl:if test="urn:component/urn:section[urn:code/@code='HHANAM']">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='HHANAM']" mode="text"/>
				</td>
			</tr>
		</xsl:if>
		
		<!--õendusdiagnoosid-->
		<xsl:if test="urn:component/urn:section[urn:code/@code='HHDGN']">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='HHDGN']" mode="nurseDiagnoses"/>
				</td>
			</tr>
		</xsl:if>
		
		<!-- toimingud ja protseduurid-->
		<xsl:if test="urn:component/urn:section[urn:code/@code='HHPROC']">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='HHPROC']" mode="nurseProcedures"/>
				</td>
			</tr>
		</xsl:if>
		
		<!-- väljastatud 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>
		
		<!--hinnang perioodi kohta-->
		<xsl:if test="urn:component/urn:section[urn:code/@code='NREGIME']">
			<tr>
				<td class="tableBlock">
					<xsl:apply-templates select="urn:component/urn:section[urn:code/@code='NREGIME']" mode="text"/>
				</td>
			</tr>
		</xsl:if>
		
		<!-- lisainfo patsiendi kohta-->
		<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:template>
</xsl:stylesheet>
