<?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">
	<xsl:include href="formatting.xsl"/>
	<xsl:include href="commonBlocks.xsl"/>
	<xsl:include href="narrativeBlocks.xsl"/>
	<xsl:include href="epicrisis.xsl"/>
	<xsl:include href="timecriticalData.xsl"/>
	<xsl:include href="stat.xsl"/>
	<xsl:include href="ambEpicrisis.xsl"/>
	<xsl:include href="daycareEpicrisis.xsl"/>
	<xsl:include href="birthEpicrisis.xsl"/>
	<xsl:include href="trust.xsl"/>
	<xsl:include href="nursingEpicrisis.xsl"/>
	<xsl:include href="immunization.xsl"/>
	<xsl:include href="growth.xsl"/>
	<xsl:include href="physical.xsl"/>
	<xsl:include href="progress.xsl"/>
	<xsl:include href="guidance.xsl"/>
	<xsl:include href="immunizationSideEffects.xsl"/>
	<xsl:include href="healthcard.xsl"/>
	<xsl:include href="healthcardAge.xsl"/>
	<xsl:include href="referral.xsl"/>
	<xsl:include href="referralAnswer.xsl"/>
	<xsl:include href="imageReference.xsl"/>
	<xsl:include href="will.xsl"/>
	<xsl:include href="prescription.xsl"/>
	<xsl:include href="pregnancy.xsl"/>
	<xsl:include href="pregnancyGeneral.xsl"/>
	<xsl:include href="pregnancyVisit.xsl"/>
	<!--ortodontia-->
	<xsl:include href="periodontalGeneral.xsl"/>
	<xsl:include href="periodontalPlan.xsl"/>
	<xsl:include href="periodontalVisit.xsl"/>
	<xsl:include href="periodontalObservation.xsl"/>
	<xsl:include href="periodontalStatus.xsl"/>
	<xsl:include href="periodontalCase.xsl"/>
	<xsl:include href="teethStatus.xsl"/>
	<!--

	Select document type and apply according to template
	-->
	<xsl:template name="chooseDocument">
		<xsl:choose>
			<xsl:when test="urn:code/@code='1'">
				<xsl:apply-templates select="urn:component/urn:structuredBody" mode="statEpicrisis"/>
			</xsl:when>
			<xsl:when test="urn:code/@code='2'">
				<xsl:apply-templates select="urn:component/urn:structuredBody" mode="ambEpicrisis"/>
			</xsl:when>
			<xsl:when test="urn:code/@code='3'">
				<xsl:apply-templates select="urn:component/urn:structuredBody" mode="daycareEpicrisis"/>
			</xsl:when>
			<xsl:when test="urn:code/@code='4'">
				<xsl:apply-templates select="urn:component/urn:structuredBody" mode="birthEpicrisis"/>
			</xsl:when>
			<xsl:when test="urn:code/@code='5'">
				<xsl:apply-templates select="urn:component/urn:structuredBody" mode="timeCritical"/>
			</xsl:when>
			<xsl:when test="urn:code/@code='6'">
				<xsl:apply-templates select="urn:component/urn:structuredBody" mode="stat"/>
			</xsl:when>
			<xsl:when test="urn:code/@code='9'">
				<xsl:apply-templates select="urn:component/urn:structuredBody" mode="trust"/>
			</xsl:when>
			<xsl:when test="urn:code/@code='10'">
				<xsl:apply-templates select="urn:component/urn:structuredBody" mode="nursingEpicrisis"/>
			</xsl:when>
			<xsl:when test="urn:code/@code='11'">
				<xsl:apply-templates select="urn:component/urn:structuredBody" mode="immunization"/>
			</xsl:when>
			<xsl:when test="urn:code/@code='12'">
				<xsl:apply-templates select="urn:component/urn:structuredBody" mode="growth"/>
			</xsl:when>
			<xsl:when test="urn:code/@code='13'">
				<xsl:apply-templates select="urn:component/urn:structuredBody" mode="physical"/>
			</xsl:when>
			<xsl:when test="urn:code/@code='14'">
				<xsl:apply-templates select="urn:component/urn:structuredBody" mode="progress"/>
			</xsl:when>
			<xsl:when test="urn:code/@code='15'">
				<xsl:apply-templates select="urn:component/urn:structuredBody" mode="guidance"/>
			</xsl:when>
			<xsl:when test="urn:code/@code='16'">
				<xsl:apply-templates select="urn:component/urn:structuredBody" mode="immunizationSideEffects"/>
			</xsl:when>
			<xsl:when test="urn:code/@code='17_1'">
				<xsl:apply-templates select="urn:component/urn:structuredBody" mode="healthcard"/>
			</xsl:when>
			<xsl:when test="urn:code/@code='17_2'">
				<xsl:apply-templates select="urn:component/urn:structuredBody" mode="healthcardAge"/>
			</xsl:when>
			<xsl:when test="urn:code/urn:translation/@code='34140-4'">
				<xsl:apply-templates select="urn:component/urn:structuredBody" mode="referral"/>
			</xsl:when>
			<xsl:when test="urn:templateId[substring(@extension,1,26)='1.3.6.1.4.1.28284.6.1.1.64']">
				<xsl:apply-templates select="urn:component/urn:structuredBody" mode="referralAnswer"/>
			</xsl:when>
			<xsl:when test="urn:templateId[substring(@extension,1,27)='1.3.6.1.4.1.28284.6.1.1.123']">
				<xsl:apply-templates select="urn:component/urn:structuredBody" mode="imageReference"/>
			</xsl:when>
			<xsl:when test="urn:code/@code='18'">
				<xsl:apply-templates select="urn:component/urn:structuredBody" mode="will"/>
			</xsl:when>
			<xsl:when test="urn:code/@code='29305-0'">
				<xsl:apply-templates select="urn:component/urn:structuredBody" mode="prescription"/>
			</xsl:when>
			<xsl:when test="urn:code/@code='21'">
				<xsl:apply-templates select="urn:component/urn:structuredBody" mode="pregnancy"/>
			</xsl:when>
			<xsl:when test="urn:code/@code='19'">
				<xsl:apply-templates select="urn:component/urn:structuredBody" mode="pregnancyGeneral"/>
			</xsl:when>
			<xsl:when test="urn:code/@code='20'">
				<xsl:apply-templates select="urn:component/urn:structuredBody" mode="pregnancyVisit"/>
			</xsl:when>
			<!--ortodontia-->
			<xsl:when test="urn:code/@code='22'">
				<xsl:apply-templates select="urn:component/urn:structuredBody" mode="periodontalGeneral"/>
			</xsl:when>
			<xsl:when test="urn:code/@code='23'">
				<xsl:apply-templates select="urn:component/urn:structuredBody" mode="periodontalPlan"/>
			</xsl:when>
			<xsl:when test="urn:code/@code='24'">
				<xsl:apply-templates select="urn:component/urn:structuredBody" mode="periodontalVisit"/>
			</xsl:when>
			<xsl:when test="urn:code/@code='25'">
				<xsl:apply-templates select="urn:component/urn:structuredBody" mode="periodontalObservation"/>
			</xsl:when>
			<xsl:when test="urn:code/@code='26'">
				<xsl:apply-templates select="urn:component/urn:structuredBody" mode="periodontalStatus"/>
			</xsl:when>			
			<xsl:when test="urn:code/@code='27'">
				<xsl:apply-templates select="urn:component/urn:structuredBody" mode="periodontalCase"/>
			</xsl:when>
			<xsl:when test="urn:code/@code='28'">
				<xsl:apply-templates select="urn:component/urn:structuredBody" mode="teethStatus"/>
			</xsl:when>
		</xsl:choose>
	</xsl:template>
</xsl:stylesheet>

