<%@ 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" />
<div class="dialogBox">
	<div class="dialogTitle">Find Patient</div>
	<div class="dialogContent">
	<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">Referring 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" 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">Primary Site</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;NHS Number</div>
	<div class="fieldSetColumnSecond"><smvc:input path="nhsNumber"
		onkeypress="searchPatient(event);" /></div>
	<div class="fieldSetColumnFirst">Referred From</div>
	<div class="fieldSetColumnFourth"><smvc:select
		path="referredFrom">
		<smvc:option value="All">Any</smvc:option>
		<c:choose>         
			<c:when test="${webApp.centralHubHospital}">
				<c:forEach var="user" items="${webapp.userNameNameMap}">
					<smvc:option value="${user.key}"><c:out value="${user.value}"/></smvc:option>
				</c:forEach>
			</c:when>
			<c:otherwise>
				<c:forEach var="user" items="${webapp.usersByHospitalIdMap[webapp.currentUser.hospital.id]}">
					<smvc:option value="${webapp.userIdUsernameMap[user]}"><c:out value="${webapp.userIdNameMap[user]}"/></smvc:option>
				</c:forEach>
			</c:otherwise>
		</c:choose>
	</smvc:select></div>
	</div>

	<div class="rowDivFirst">
	<div class="fieldSetColumnFirst"><c:if
		test="${'InCompleteReferrals' ne parentScreen}">
				&nbsp;&nbsp;Tracking Status
			</c:if></div>
	<div class="fieldSetColumnSecond"><c:if
		test="${'FindExisting' eq parentScreen}">
		<smvc:select path="referralStatus">
			<smvc:option value="All">Any</smvc:option>
			<smvc:option value="1">Patient Referred</smvc:option>
			<smvc:option value="2">Response Sent</smvc:option>
			<smvc:option value="3">Referral Completed</smvc:option>

		</smvc:select>
	</c:if> <c:if
		test="${('ReferralsIn' eq parentScreen) or ('Completed' eq parentScreen) or ('ResponseSent' eq parentScreen) or ('Unregistered' eq parentScreen)}">
		<smvc:select path="referralStatus" disabled="true">
			<smvc:option value="All">Any</smvc:option>
			<smvc:option value="1">Patient Referred</smvc:option>
			<smvc:option value="2">Response Sent</smvc:option>
			<smvc:option value="3">Referral Completed</smvc:option>

		</smvc:select>
	</c:if></div>
	<div class="fieldSetColumnFirst"><c:if
		test="${'InCompleteReferrals' ne parentScreen}">
			Referred To
		</c:if></div>
	<div class="fieldSetColumnFourth"><c:if
		test="${'InCompleteReferrals' ne parentScreen}">
		<smvc:select path="referredTo">
			<smvc:option value="All">Any</smvc:option>
			<c:forEach var="user" items="${webapp.allManagementClinicians}">
				<smvc:option value="${user.username}"><c:out value="${user.name}"/></smvc:option>
			</c:forEach>
		</smvc:select>
	</c:if></div>
	</div>
	<div class="rowDivFirst">&nbsp;</div>
</div>
</div>


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