<?xml version="1.0"?>

<!--  XSL Style Sheet for exporting M600 results to MSExcel                                     -->
<!--  Copyright: Medmont Pty Ltd                                                                -->
<!--             605 Camberwell Road                                                            -->
<!--             Camberwell Australia                                                           -->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl" xmlns:n="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:template match="/">
    <HTML>      
      <xsl:element name="XML">
        <xsl:attribute name="id">source</xsl:attribute>
        <xsl:attribute name="src"><xsl:eval>Url</xsl:eval></xsl:attribute>
	XML Not Supported
      </xsl:element>
      <HEAD>
      <META name="author" CONTENT="Khalid Perwaiz" />
      <LINK REV="made" href="mailto:help@medmont.com" />
      <TITLE><xsl:value-of select="*/Patient/LastName" />, <xsl:value-of select="*/Patient/FirstName" /></TITLE>
      </HEAD>  
      <BODY STYLE="font-family:Arial, helvetica, sans-serif; font-size:12pt;
            background-color:#FFFFFF">
        <xsl:for-each select="*/Patient">
	  
          <div align="left">
            <table border="0" bgcolor="#CEE4E4" width="100%">
              <tr>
                <th width="100%" height="26" colspan="4" bgcolor="#008080" align="left" nowrap="">
                		<font color="white"><xsl:value-of select="LastName"/>, <xsl:value-of select="FirstName"/></font>
                </th>
	      </tr>
              <tr>
                <th align="right" nowrap="" valign="top">Sex:</th>
                <td width="50%" valign="top" align="left"><xsl:value-of select="Sex"/></td>
                <th align="right" nowrap="" valign="top">Date of Birth:</th>
                <td width="50%" valign="top"><xsl:value-of select="BirthDate"/></td>
              </tr>
              <tr>
                <th align="right" nowrap="" valign="top">Condition:</th>
                <td width="50%" valign="top" align="left"><xsl:value-of select="Condition"/></td>
                <th align="right" nowrap="" valign="top">Procedure:</th>
                <td width="50%" valign="top"><xsl:value-of select="Procedure"/></td>
              </tr>
              <tr>
                <th align="right" nowrap="" valign="top">Comments:</th>
                <td colspan="3" valign="top"><xsl:value-of select="Comments"/></td>
              </tr>
            </table>
          </div>
          <br/>
                    
          <!-- Process Each M600 Threshold Exam for the current Patient -->
          
          <xsl:for-each select="/*/M600ThresholdExam[PatientID = context(-1)/ID]">
            <div align="left" STYLE="margin-left: 20px">
              <table width="98%" border="0" bgcolor="#E0E0E0">
                <tr>
                  <th width="95%" bgcolor="#808080" nowrap="" align="left" colspan="4">
                  	<font color="white">M700 Threshold Exam - <xsl:value-of select="context(-2)/FirstName"/> 
                  	<xsl:value-of select="context(-2)/LastName"/></font>
                  </th>
		</tr>
                <tr>
                  <th align="right" nowrap="" valign="top">Eye:</th>
                  <td width="50%" valign="top"><xsl:value-of select="Eye"/></td>
                  <th align="right" nowrap="" valign="top">Date:</th>
                  <td width="50%" valign="top"><xsl:value-of select="Date"/></td>
                </tr>
                <tr>
                  <th align="right" nowrap="" valign="top">Template:</th>
                  <td width="50%" valign="top"><xsl:value-of select="TemplateName"/></td>
                  <th align="right" nowrap="" valign="top">Duration:</th>
                  <td width="50%" valign="top"><xsl:value-of select="Duration"/> secs <xsl:value-of select="PeriodType"/></td>
                </tr>
                <tr>
                  <th align="right" nowrap="" valign="top">Comments:</th>
                  <td colspan="3" valign="top"><xsl:value-of select="Comments"/></td>
                </tr>
              </table>
              	<table width="98%" border="0" bgcolor="#00CC99">
		<th align="center" nowrap="" valign="top" >Ring</th>
		<th align="center" nowrap="" valign="top" >Meridian</th>
		<th align="center" nowrap="" valign="top" >Value</th>
		<xsl:apply-templates select="/MedmontStudioExportFile/M600ThresholdExam[ID = context(-1)/ID]/ThresholdTest/Test/TestPoints/ThresholdTestPoint"/>
	     	</table>
	       </div>            
            <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>    
          </xsl:for-each>     <!-- M600 Threshold Exam -->
          </xsl:for-each>     <!-- Patient -->
      </BODY>
    </HTML>
  </xsl:template>
  
  <!-- Process ThresholdTestPoint -->
  <xsl:template match="ThresholdTestPoint">
	<xsl:if test="Completed[. = 'true']">
	<tr>  	
		<td bgcolor="FFCC99" width ="33%" align="center" nowrap="" valign="top">
			<xsl:value-of select="Position/Ring" />
		</td>
		<td bgcolor="99CC00" width ="33%" align="center" nowrap="" valign="top">
			<xsl:value-of select="Position/Meridian" />
		</td>
		<td bgcolor="99CCFF" width ="33%" align="center" nowrap="" valign="top">
			<xsl:value-of select="Value" />
		</td>
	</tr>
	</xsl:if>
  </xsl:template>
</xsl:stylesheet>

