<?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:import href="resource/style.xsl" />
	<xsl:output method="html" encoding="utf-8" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" />
	<xsl:template match="/report">
		<html>
			<head>
				<meta http-equiv="content-type" content="text/html; charset=utf-8" />
				<title>Report</title>
				<link rel="stylesheet" href="resource/style.css" text="text/css" />
				<link rel="stylesheet" href="resource/style_footer.css" text="text/css" />
				<style>
					.cover {
						font-size: 150%;
						margin-top: 1em;
					}
					.observation {
						border: 1px solid #000000;
						padding: 3px;
					}
					.cattitle {
						font-size: 100%;
						font-weight: bold;
						margin-bottom: 1em;
					}
					.imgborder {
						margin-right: 0.5em;
						margin-bottom: 0.5em;
					}
				</style>
			</head>
			<body class="bodystyle">
				<xsl:apply-templates select="TotalReport" />
			</body>
		</html>
	</xsl:template>

	<xsl:template match="TotalReport">
		<!-- Header information -->
		<xsl:call-template name="header" />
		<!-- Analysis result -->
		<span class="cattitle">Report contents</span>
		<table cellpadding="0" cellspacing="0" class="withborder">
			<tr>
				<th>No.</th>
				<th>Application</th>
				<th>Study date and time</th>
				<th>Page</th>
			</tr>
			<xsl:for-each select="Analyses/Analysis">
				<tr>
					<td align="center"><xsl:value-of select="position()"/></td>
					<td><xsl:value-of select="@displayname"/></td>
					<td><xsl:value-of select="StudyDate" />&#xA0;<xsl:value-of select="StudyTime"/></td>
					<td align="right"><xsl:value-of select="StartPage"/></td>
				</tr>
			</xsl:for-each>
		</table>
		<br/>
		<!-- Observation -->
		<xsl:if test="Observation/title != '' or Observation/Description != ''">
			<div class="observation">
				<xsl:if test="Observation/title != ''">
					<span class="cattitle">Total observation:</span><xsl:value-of select="Observation/title" /><br />
				</xsl:if>
				<xsl:if test="Observation/Description != ''">
					<span class="cattitle">Description:</span><br />
					<pre style="display:inline; white-space:pre-wrap; word-wrap:break-word; word-break:break-all"><xsl:value-of select="Observation/Description" /></pre><br />
				</xsl:if>
			</div>
		</xsl:if>
		<br/>
		<!-- Footer information -->
		<xsl:call-template name="footer" />
	</xsl:template>

	<xsl:template name="header">
		<div align="center" class="cover">
			<img width="650" src="resource/header.bmp" />
			<br/>
			<br/>
			<span class="maintitle"><xsl:value-of select="/report/TotalReport/@diplayname" /></span><br/>
			<br/>
			<img width="650" src="resource/header.bmp" />
		</div>
		<br />
		<!-- Patient information -->
		<xsl:call-template name="patient" />
	</xsl:template>

	<xsl:template name="patient">
		<table width="100%" cellpadding="0" cellspacing="0" class="withborder">
			<tr>
				<th width="13%">Patient name</th>
				<td width="20%"><xsl:value-of select="/report/SubjectContext/Name" /></td>
				<th width="10%">Patient ID</th>
				<td width="20%"><xsl:value-of select="/report/SubjectContext/ID" /></td>
				<th width="10%">Sex</th>
				<td width="27%"><xsl:apply-templates select="/report/SubjectContext/Sex" /></td>
			</tr>
			<tr>
				<th>Birth date</th>
				<td><xsl:apply-templates select="/report/SubjectContext/BirthDate" /></td>
				<th>Referring physician</th>
				<td><xsl:apply-templates select="/report/ObserverContext/ReferringPhysician" /></td>
				<th>Reading physician</th>
				<td><xsl:apply-templates select="/report/ObserverContext/ReadingPhysician" /></td>
			</tr>
		</table>
		<br />
	</xsl:template>
</xsl:stylesheet>
