<%@ include file="/includes.jsp"%>
<%@ taglib prefix="smvc" uri="http://www.springframework.org/tags/form"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<script type="text/javascript">
function searchPatient(event){
	if (event.keyCode == 13)
    {
		document.getElementById('action').value = 'SEARCH';
        submit();
    }
}
</script>
<input type="hidden" name="action" id="action" value="" />
<smvc:hidden path="actionRequired" />
<tags:dialogBox title="Find Patient">
	<div class="rowDivFirst">&nbsp;</div>
	<div class="rowDivFirst">
	<div class="fieldSetColumnFirst">&nbsp;&nbsp;Name</div>
	<div class="fieldSetColumnSecond"><smvc:input path="name"
		onkeypress="searchPatient(event);" /></div>
	<div class="fieldSetColumnFirst">Submitting Hospital</div>
	<div class="fieldSetColumnFourth">  
	<c:choose>
	<c:when test="${webapp.centralHubHospital}">
		<smvc:select path="hospital">
		    <smvc:option value="-1">Any</smvc:option>
			<c:if test="${patientSearchDto.hospitalsList!=null and (fn:length(patientSearchDto.hospitalsList) > 0)}">
				<c:forEach var="hospital" items="${patientSearchDto.hospitalsList}" varStatus="status">
					<smvc:option value="${hospital.id}"><c:out value="${hospital.hospitalName}"/></smvc:option>
				</c:forEach>
			</c:if>
		</smvc:select>
	</c:when>
	<c:otherwise>
		<smvc:select path="hospital" > <%-- review this for HHFT-style referrals: was disabled="true" --%>
		    <smvc:option value="-1">Any</smvc:option>
		    <smvc:option value="0">extra</smvc:option>
			<c:if test="${patientSearchDto.hospitalsList!=null and (fn:length(patientSearchDto.hospitalsList) > 0)}">
				<c:forEach var="hospital" items="${patientSearchDto.hospitalsList}" varStatus="status">
						<smvc:option value="${hospital.id}"><c:out value="${hospital.hospitalName}"/></smvc:option>
				</c:forEach>
			</c:if>
		</smvc:select>
	</c:otherwise>
	</c:choose>
	</div>
	<!--<div class="fieldSetColumnFirst">Search Within</div>
	<div class="fieldSetColumnFourth"><smvc:select path="scope">
		<smvc:option value="all">All Patients</smvc:option>
		<smvc:option value="user">My Patients</smvc:option>
	</smvc:select></div>
	--></div>

	<div class="rowDivFirst">
	<div class="fieldSetColumnFirst">&nbsp;&nbsp;Date Of Birth</div>
	<div class="fieldSetColumnSecond"><smvc:input path="dob"
		onkeypress="searchPatient(event);" /></div>
	<div class="fieldSetColumnFirst">Speciality</div>
	<div class="fieldSetColumnFourth"><webapp:selectAndEditList
		includeEmpty="true" path="primarySite" domain="EMDT"
		list="speciality" disabled="false"
		currentValue="${patientSearchDto.primarySite}" /></div>
	</div>

	<div class="rowDivFirst">
	<div class="fieldSetColumnFirst">&nbsp;&nbsp;Hospital Number</div>
	<div class="fieldSetColumnSecond"><smvc:input path="hospitalNumber"
		onkeypress="searchPatient(event);" /></div>
	<div class="fieldSetColumnFirst"> Submitting Clinician</div>
	<div class="fieldSetColumnFourth">
	 <smvc:select path="referredFrom" cssStyle="width: 20em;">
			<smvc:option value="All">Any</smvc:option>
		 <c:forEach var="usersByHospitalMap" items="${webapp.usersByHospitalIdMap}">
			 <optgroup label="${webapp.hospMap[usersByHospitalMap.key]}">
				 <c:forEach var="userId" items="${usersByHospitalMap.value}">
					 <smvc:option value="${userId}" ><c:out value="${webapp.userIdNameMap[userId]}"/></smvc:option>
				 </c:forEach>
			 </optgroup>
		 </c:forEach>
	</smvc:select>
	</div>
	</div>

	<div class="rowDivFirst">&nbsp;</div>
</tags:dialogBox>

<div class="containerMedium">
<div class="floatRight"><input type="reset" id="resetButtonId" value="Reset" onclick="setAction('RESET');" />
	<input type="submit" id="searchButtonId" value="Search" onclick="setAction('SEARCH');" /></div>
</div>
