<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
	<xsl:template name="sign">
		<table border="0" width="100%" cellspacing="0" cellpadding="0"> 
			<tr> 
				<td> 
					<xsl:apply-templates select="/report/ProcedureContext/LocalTime" />
				</td> 
				<td align="right"> 
					<span class="sign">Reading physician: <xsl:apply-templates select="/report/ObserverContext/ReadingPhysician" /></span>
				</td> 
			</tr> 
		</table> 
	</xsl:template>

	<xsl:template name="hospitalname">
		<div align="right">
			<span class="hospital">Hokkaido Univ.</span><br />
			<img width="650" src="resource/footer.bmp" /><br />
			<img height="20" src="resource/logo.jpg" />
		</div>
	</xsl:template>

	<xsl:template name="footer">
		<div class="footer">
			<xsl:call-template name="sign" />
			<br />
			<xsl:call-template name="hospitalname" />
		</div>
	</xsl:template>

	<xsl:template match="StudyDate|BirthDate">
    <xsl:value-of select="text()"/>
	</xsl:template>

	<xsl:template match="Sex">
		<xsl:choose>
		<xsl:when test="text() = 'M'">Male</xsl:when>
		<xsl:when test="text() = 'F'">Female</xsl:when>
		<xsl:otherwise><xsl:value-of select="text()" /></xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="Age">
		<xsl:call-template name="number" /> <xsl:call-template name="age_unit" />
	</xsl:template>

	<xsl:template name="age_unit">
		<xsl:choose>
		<xsl:when test="@unit = 'd'">day</xsl:when>
		<xsl:when test="@unit = 'wk'">week</xsl:when>
		<xsl:when test="@unit = 'mo'">month</xsl:when>
		<xsl:when test="@unit = 'a'">year</xsl:when>
		</xsl:choose>
		<xsl:if test="text() &gt; 1">s</xsl:if>
	</xsl:template>

	<xsl:template name="number">
		<xsl:if test="text() != ''">
			<xsl:value-of select="text()" />
		</xsl:if>
	</xsl:template>

	<xsl:template name="upper_number">
		<xsl:choose>
		<xsl:when test="text() != '' and text() > 0">
			<xsl:value-of select="text()" />
		</xsl:when>
		<xsl:otherwise>----</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="valid_number">
		<xsl:choose>
		<xsl:when test="text() != ''">
			<xsl:value-of select="text()" />
		</xsl:when>
		<xsl:otherwise>----</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="ReferringPhysician|ReadingPhysician|PerformingPhysician|ReportingPhysician">
		<xsl:choose>
		<xsl:when test="string-length(Name) > 0">
			<xsl:value-of select="Name" />
		</xsl:when>
		<xsl:otherwise></xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="LocalTime">
    <xsl:value-of select="concat('Created : ', text())"/>
	</xsl:template>
</xsl:stylesheet>
