<%@ include file="/includes.jsp"%>
<%@ taglib prefix="smvc" uri="http://www.springframework.org/tags/form"%>
		
	<html>
		<head>
			<title>Letter Created</title>
			<link rel="stylesheet" href="../webapp.css" type="text/css" />
			<script src="../js/webapp.js" type="text/javascript">
			//this comment is here to prevent an IE6 bug manifesting
			</script>
		</head>
		<body>
			<center>
				<br/>
				<table>
					<tr>
					  <tr>
					  <td>
		                 <c:if test="${val!= null }">
							
							<h3><font color="red">Patient Not Selected</font></h3>
							The query associated with this letter template is for the current patient, but<br/>
							you don't currently have a patient selected.<br/>
							Please select a patient first.
						</c:if>
						</td>
		               </tr>
                     
		        <c:if test="${val== null }">
					<td>
					
					
						<c:if test="${not empty results}">
								<h3>The following letters have been created...</h3>
								<ul>							
								<c:forEach var="row" items="${results }" varStatus="ss">
		                        	<li> <a href="letterDoc.form?templateName=<c:out value="${row[1]}"/>" title="View Letter"><c:out value="${row[0]}"/>" /></a> </li>
								</c:forEach>
								</ul>
					    </c:if>
					    <c:if test="${empty results}">
						<h3>Unable to produce letter</h3>
						It was not possible to produce your letter because no results were returned by the underlying query.<br/>
						Please check your query produces results and that the patient has the appropriate forms filled in. 
						</c:if>
					    
						<c:if test="${mismatch!= null }">
							<h3><font color="red">Fields are mismatched</font></h3>
							Letters could not be created because the following merge fields were present<br/>
							within the letter template but they were not present in the query:<br/><br/>
							<ul>
							<c:forEach var="row" items="${mismatch }" varStatus="ss">
						      <li> <c:out value="${row}"/> </li>
							</c:forEach>
							</ul>
							Please either add the fields to your query, or edit your letter template so the missing fields are removed.
						</c:if>
				    </td>
			    </c:if>
			</tr>
		 </table>
				<br/>
				<table>
				<tr>
					<td colspan='3'>
                    <input type="button" value="  Back  " onclick="document.location='letterGenerate.form'"/>
                    </td>
                </tr>  
                </table>      
			</center>
		</body>
	</html>


