<%@ include file="/includes.jsp" %>
<%@ taglib prefix="smvc" uri="http://www.springframework.org/tags/form" %>
<script language="javascript">

function sendToFurtherDetails(patientId,summaryType){
document.getElementById('nrlPatientId').value=patientId;
document.getElementById('nrlSummaryType').value=summaryType;
document.getElementById('nrlfurtherDtl').submit();
}

function processButtonClick(patientId,actionname,summaryType){
var formObj = document.getElementById('nrlfurtherDtl');
document.getElementById('nrlSummaryType').value=summaryType;
document.getElementById('nrlPatientId').value=patientId;
	if(actionname=='MYEMDT'){
	    formObj.action='nrlAddToMyMdt.form';
	}else if(actionname=='ALTCONSULT'){
    	formObj.action='nrlAlternativeConsultant.form';
	}else if(actionname=='OTHERDEPT'){
	   formObj.action='nrlToOtherDepartment.form';
	}else if(actionname=='REFOUT'){
	   formObj.action='nrlReferOut.form';
	}else if(actionname=='RETTOREF'){
	   formObj.action='nrlReturnToReferrer.form';
	}else if(actionname=='ALTDEC'){
	   formObj.action='nrlAlternativeDecision.form';
	}
document.getElementById('nrlfurtherDtl').submit();
}

function viewOtherDocDetails(){

	var selClinician = "${param.selClinician}";
	var url = 'nrlUserDetails.form?selClinician='+selClinician;
	var win = window.open(url,'viewDetails','scrollbars=1,toolbar=0,status=1,menubar=1,resizable=1,location=0,directories=0,width=600,height=550,left=0,top=0');
	win.focus();
}

</script>
<smvc:form id="nrlfurtherDtl" method="get" action="nrlfurtherDetails.form" >
<input type="hidden" name="redirectParams" value="<c:out value="${requestScope['javax.servlet.forward.query_string']}" />" />
	<input id="nrlPatientId" type="hidden" name="nrlPatientId" value=""/>
	<input id="nrlSummaryType" type="hidden" name="nrlSummaryType" value=""/>
	<table border="0" width="850">
		<c:choose>
			<c:when test="${model.successMsg != null || model.errorMsg != null}">
				<tr>
					<td align="center"><c:if test="${model.successMsg != null}">
						<div class="message"><img
							src="../images/16x16/information.png" alt="i" />
						<c:out value="${model.successMsg}"/></div>
					</c:if>
					<c:if test="${param.selClinician != null}">
						<div><a href="nrlUserDetails.form?selClinician=<c:out value="${param.selClinician}"/>" onClick="viewOtherDocDetails();return false;">Click here to View Details</a></div>
					 </c:if>
					 <c:if test="${model.errorMsg != null}">
						<div class="error"><img src="../images/16x16/error.png"
							alt="e" /><c:out value="${model.errorMsg}"/></div>
					</c:if></td>
				</tr>
			</c:when>
			<c:otherwise>
				<tr>
					<td>&#160;</td>
				</tr>
			</c:otherwise>
		</c:choose>

	</table>
		<table align="center" cellspacing="0" width="850" border="1" class="table">
			<tr>
				<td width="100%">
				<table border="1" width="100%" cellspacing="0" class="table">
                
                <c:set var="tableTitleBarColspan" value="14"/>
				<c:if test="${model.summaryType eq 'Patients In Breach'}">
                    <c:set var="tableTitleBarColspan" value="15"/>					
				</c:if>
					<tr>
						<td colspan="<c:out value="${tableTitleBarColspan}"/>" class="tableTitleBar">
						<c:choose>
							<c:when test="${model.summaryType eq 'Patients In Breach'}">
							Priority List - New Referral
							List
							</c:when>
							<c:otherwise>
							<c:out value="${model.summaryType}"></c:out> - New Referral
							List
							</c:otherwise>
						</c:choose>
						</td>
					</tr>
					<tr class="tableHeader">
						<th class="tableColHeader" width="3%" colspan="3"></th>
						<th class="tableColHeader" width="2.5%">Source</th>
						<th class="tableColHeader" width="10%">Surname</th>
						<th class="tableColHeader" width="13.5%">Forename</th>
						<th class="tableColHeader" width="10%">Date of Birth</th>
						<th class="tableColHeader" width="8%">My MDM</th>
						<th class="tableColHeader" width="10%">Other Doctor</th>
						<th class="tableColHeader" width="10%">Other Department</th>
						<th class="tableColHeader" width="7%">Refer<br />
						Out</th>
						<th class="tableColHeader" width="10%">Return To Referrer</th>
						<th class="tableColHeader" width="8%">Alternative Decision</th>
						<th class="tableColHeader" width="8%">Decision Made</th>
						<c:if test="${model.summaryType eq 'Patients In Breach'}">
							<th class="tableColHeader" width="8%">User</th>
						</c:if>
					</tr>

                    <c:set var="resultCount" value="${fn:length(model.nrlList)}"/>
                    
                    <c:choose>
                    <c:when test="${resultCount > 0}">
					<c:forEach items="${model.nrlList}" var="nrlsummaryBean"
						varStatus="s">
						<c:choose>
                            <c:when test="${nrlsummaryBean.highlightRow == true}">
							   <tr  bgcolor="red">
							</c:when>
                            <c:otherwise>
                               <tr class='<c:out value="${s.count%2 == 0 ? 'odd' : 'even' }"/>Row <c:out value="${selClass }"/>'>
							</c:otherwise>
						</c:choose>
							<td width="3%" colspan="3">
								<a style="cursor: pointer" onclick="sendToFurtherDetails(<c:out value="${nrlsummaryBean.nrlId}"/>,<c:out value="${model.summaryType}"/>);"> 
								<img title="Further Details" src="../images/add.png" /></a></td>
							<td width="2.5%"><c:out value="${nrlsummaryBean.source}"/>" /></td>
							<td width="10%"><a style="cursor: pointer"
								onclick="sendToFurtherDetails('<c:out value="${nrlsummaryBean.nrlId}"/>','<c:out value="${model.summaryType}"/>');"><c:out
								value="<c:out value="${nrlsummaryBean.surname}"/>" /></a></td>
							<td width="13.5%"><c:out value="${nrlsummaryBean.forename}"/>" /></td>
							<td width="10%" nowrap="nowrap"><fmt:formatDate
								value="<c:out value="${nrlsummaryBean.dob}" pattern="dd MMM yyyy" /></td>

							<td width="8%"><input class="nrlBtn" type="button"
								<c:out value="${nrlsummaryBean.disableAllButtons}"/> onclick="processButtonClick('<c:out value="${nrlsummaryBean.nrlId}"/>','MYEMDT','<c:out value="${model.summaryType}"/>');"
								value="My MDM" /></td>
							<td width="10%"><input class="nrlBtn" type="button"
								<c:out value="${nrlsummaryBean.disableAllButtons}"/>  onclick="processButtonClick('<c:out value="${nrlsummaryBean.nrlId}"/>','ALTCONSULT','<c:out value="${model.summaryType}"/>');"
								value="Other Doctor" /></td>
							<td width="10%"><input class="nrlBtn" type="button"
								<c:out value="${nrlsummaryBean.disableAllButtons}"/>  onclick="processButtonClick('<c:out value="${nrlsummaryBean.nrlId}"/>','OTHERDEPT','<c:out value="${model.summaryType}"/>');"
								value="Other Dep" /></td>
							<td width="7%"><input class="nrlBtn" type="button"
								<c:out value="${nrlsummaryBean.disableAllButtons}"/>  onclick="processButtonClick('<c:out value="${nrlsummaryBean.nrlId}"/>','REFOUT','<c:out value="${model.summaryType}"/>');"
								value="Ref Out" /></td>
							<td width="10%"><input class="nrlBtn" type="button"
								<c:out value="${nrlsummaryBean.disableAllButtons}"/> <c:out value="${nrlsummaryBean.disableReturnToReferrerButtons}"/> onclick="processButtonClick('<c:out value="${nrlsummaryBean.nrlId}"/>','RETTOREF','<c:out value="${model.summaryType}"/>');"
								value="Return To Ref" /></td>
							<td width="8%"><input class="nrlBtn" type="button"
								<c:out value="${nrlsummaryBean.disableAllButtons}"/>  onclick="processButtonClick('<c:out value="${nrlsummaryBean.nrlId}"/>','ALTDEC','<c:out value="${model.summaryType}"/>');"
								value="Alt.Dec" /></td>
							<td width="8%"><c:out value="${nrlsummaryBean.decisionMade}"/>" /></td>
							<c:if test="${model.summaryType eq 'Patients In Breach'}">
								<td width="8%"><c:out value="${nrlsummaryBean.admittingPhysician}"/>" /></td>
							</c:if>
							</tr>
						</c:forEach>
					</c:when>
					<c:otherwise>
						<tr>
							<td align="center" class="message" colspan="<c:out value="${tableTitleBarColspan}"/>">No Record(s) Found</td>
						</tr>
					</c:otherwise>
				</c:choose>


				</table>
				</td>
			</tr>
		</table>
	</smvc:form>



