<%@ include file="/includes.jsp"%>
<%@ taglib prefix="smvc" uri="http://www.springframework.org/tags/form"%>
	<br/>
	<smvc:form action="importPatientRecord.form?${_csrf.parameterName}=${_csrf.token}" method="post" enctype="multipart/form-data">
		<input type="hidden" name="redirectParams" value="<c:out value="${requestScope['javax.servlet.forward.query_string']}" />" />
		<fieldset class="nobg" style="width: 40%; text-align: left">
			<legend>Import Patients</legend>
			<fieldset>
				<c:if test="${ inputfile == null }">
				File:&#160;<input type="file" name="document" value='<c:out value="${inputfile }"/>' onchange="setFileSize(this);"/><br/>
				</c:if>
				<c:if test="${ inputfile != null }">
				<input type="hidden" name="importfile" value='<c:out value="${inputfile }"/>' />
				File is <c:out value="${inputfile}"/>
				</c:if>
			</fieldset>
			<fieldset class="buttonFieldset">
				<input type="submit" name="startPatientImport" value="Start import"  onclick="showPleaseWait();"/>
			</fieldset>

				<c:if test="${totalPatients != null}">
					<div class="message">
						<img src="../images/16x16/information.png" alt="i" />&#160;  <c:if test="${totalPatients == 1 }">There was 1 patient in the import file</c:if>
																				<c:if test="${totalPatients != 1 }">There were <c:out value="${totalPatients}"/>"/> patients in the import file</c:if>
						<ul>
						<c:if test="${numberInsertedPatients != null}">
							 <li>Patients created: <c:out value="${numberInsertedPatients}"/></li>						
						</c:if>
						<c:if test="${numberUpdatedPatients != null}">
								 <li>Patients updated: <c:out value="${numberUpdatedPatients}"/></li>
						</c:if>
						<c:if test="${numberImportedForms != null}">
								<li>Forms imported: <c:out value="${numberImportedForms}"/></li>
						</c:if>
						</ul>
					</div>
				</c:if>
				<c:if test="${!empty numberRejectedPatients}">
					<c:if test="${numberRejectedPatients != 0}">
						<div class="message">
							<img src="../images/16x16/exclamation.png" alt="Warning"/> Note: <c:out value="${numberRejectedPatients}"/> patients were not imported because they had no key fields (NHS or Hospital Number).
						</div>
					</c:if>
				</c:if>

				<smvc:errors/>
		</fieldset>
	
			<iframe id="waitframe" src="reports/pleaseWait.jsp" frameborder="0" width="200" style="visibility:hidden;" ></iframe>
	
		<br/>
		To import pre v1.9.1 patient exports, please <a href="importPatient.form">click here</a>
	</smvc:form>
