<%@ include file="/includes.jsp" %>
<%@ taglib prefix="smvc" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>

<script type="text/javascript">
function importResults() {
	var res=confirm("Please confirm you want to import these results.");
	if(res){
		document.getElementById('pathologyResultsImportForm').submit();
	}
	return res;
}
</script>
<smvc:form  modelAttribute="pathologyResultsDto" id="pathologyResultsImportForm" action="../emdt/pathologyFeeds.form">
	<input type="hidden" name="redirectParams" value="<c:out value="${requestScope['javax.servlet.forward.query_string']}" />" />
	<table>
		<tr>
			<td align="center"><br />
			 <c:if test="${messages ne null}">
			 	<span class="info"><c:out value="${messages}"/></span>
			</c:if>
			 <c:if test="${errors ne null}">
			 	<span class="error"><c:out value="${errors}"/></span>
			</c:if>
			</td>
		</tr>
	</table>
	<br />
	<table width="750" border="0">
		<tr>
			<td align="center"><tags:dialogBox title="Pathology Results">
			<c:choose>
			<c:when test="${pathologyResultsDto.results ne null and fn:length(pathologyResultsDto.results) gt 0}">
				<table align="center" class="table" border="1">
					<tr>
						<th class="label">Select </th>
						<th class="label">Biopsy Date </th>
						<th class="label">Lab Order Number</th>
						<th class="label">Lab Name </th>
						<th class="label">Source</th>
					</tr>
						<c:forEach var="result"	items="${pathologyResultsDto.results}" varStatus="index">
							<tr>
								<td class="input" align="center"
									title="Check to import pathology result">
									<smvc:checkbox path="selected" value="${result.labOrderNumber}" />
								</td>
								<td class="input"><fmt:formatDate value="${result.biopsyDate}" pattern="dd MMM yyyy, HH:mm" /></td>
								<td class="input" ><c:out value="${result.labOrderNumber}"/></td>
								<td class="input"><c:out value="${result.labName}"/></td>
								<td class="input"><c:out value="${result.source}"/></td>
							</tr>
						</c:forEach>
						<tr><td colspan="5">Select the results to import.</td></tr>
				</table>
					<table align="center">
					<tr><td><br/></td></tr>
					<tr><td><input type="button" value="Import Results" onclick="return importResults()"/></td></tr><tr><td><br/></td></tr></table>
				</c:when>
				<c:otherwise>
					<table align="center">
						<tr><td><br/></td></tr>
						<tr><td><span class="warning">No Pathology Results found.</span></td></tr>
						<tr><td><br/></td></tr>
					</table>
				</c:otherwise>
			</c:choose>
			</tags:dialogBox></td>
		</tr>
	</table>
</smvc:form>
