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

	function processButtonClick(patientId,actionname){
		var formObj = document.getElementById('nrlfurtherDtl');
		formObj.method = "get";
		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 enableSubmitButton(){
		
		var yourNotes = document.getElementById("yourNotes");
		var AddNotesButton = document.getElementById("AddNotesButton");
		if(yourNotes){
			if(AddNotesButton){			
				if(yourNotes.value.length > 0){
					AddNotesButton.disabled =  false;
				}else{
					AddNotesButton.disabled =  true;
				}
			}
		}
		
	}


</script>
<smvc:form id="nrlfurtherDtl" method="post" action="nrlfurtherDetails.form" modelAttribute="patientInfo" onsubmit = "return submitTheForm();">
	<input type="hidden" name="redirectParams" value="<c:out value="${requestScope['javax.servlet.forward.query_string']}"/>" />
	<input id="nrlPatientId" type="hidden" name="nrlPatientId" value="<c:out value="${patientInfo.patientId}"/>" />
	<input id="nrlSummaryType" type="hidden" name="nrlSummaryType" value="<%= request.getParameter("nrlSummaryType") %>"/>
<table border="0" width="100%">
	<tr>
		<td class="error"><c:out value="${model.errorMsg}"/></td>
	</tr>
	<tr>
			<c:choose>
				<c:when test="${yourNotesSaved == true }">
					<td align="center">&#160;
					<div align="center" class="message"><img src="../images/16x16/information.png" alt="i" /> 
					Your notes have been added to the patient referral</div>
					</td>
				</c:when>
				<c:otherwise>
					<td align="center" class="error">&nbsp;<smvc:errors
						path="yourNotes" /></td>
				</c:otherwise>

			</c:choose>
		</tr>
</table>

<table cellspacing="0" width="850" border="1" class="table">
	<tr>
		<td width="100%">
		<table border="1" width="100%" cellspacing="0" class="table">		
		
			<tr>
				<td class="nrltableTitleBarNoBold"> <B>New Referral &#160;</B>
				&#160;&#160;&#160; Further Details</td>
			</tr>
			<tr>
				<td>
					<table width="100%" border ="1" class="nrltableWhiteBorder" >
						<tr>							
							<td colspan="2" class="nrlBrown" width="18%">
								<font width="100%">&#160;&#160;&#160;<B>Decision To Treat </B> &#160;&#160;&#160;</font>
							</td>
	                        <td class="nrlBrown" width="10%"><input id = "myMdtFurtherDetails" class="nrlBtnWide" type="button" onclick="processButtonClick('<c:out value="${patientInfo.patientId}"/>','MYEMDT');" value="My MDM" />
	                         <script type="text/javascript" for="myMdtFurtherDetails">
	                                    var formObj = document.getElementById('nrlfurtherDtl');
	                                    formObj.onload= disable();
	                                    function disable(){
	                                    var summaryType='<%= request.getParameter("nrlSummaryType") %>'
	                                    if (summaryType == "Out Tray" || summaryType == "Completed"){
	                                    document.getElementById("myMdtFurtherDetails").disabled =true;
	                                    }else{
	                                     document.getElementById("myMdtFurtherDetails").disabled =false;
	                                    }
	                                    }
                                    </script>
	                        </td>
	                        <td class="nrlBrown" width="10%"><input id = "altConsultFurtherDetails" class="nrlBtnWide" type="button" onclick="processButtonClick('<c:out value="${patientInfo.patientId}"/>','ALTCONSULT');" value="Other Doctor" />
	                         <script type="text/javascript" for="altConsultFurtherDetails">
	                                    var formObj = document.getElementById('nrlfurtherDtl');
	                                    formObj.onload= disable();
	                                    function disable(){
	                                    var summaryType='<%= request.getParameter("nrlSummaryType") %>'
	                                    if (summaryType == "Out Tray" || summaryType == "Completed"){
	                                    document.getElementById("altConsultFurtherDetails").disabled =true;
	                                    }else{
	                                     document.getElementById("altConsultFurtherDetails").disabled =false;
	                                    }
	                                    }
                                    </script>
	                        </td>
	                        <td class="nrlBrown" width="10%"><input id="otherDeptFurtherDetails" class="nrlBtnWide" type="button" onclick="processButtonClick('<c:out value="${patientInfo.patientId}"/>','OTHERDEPT');" value="Other Dep" />
	                         <script type="text/javascript" for="otherDeptFurtherDetails">
	                                    var formObj = document.getElementById('nrlfurtherDtl');
	                                    formObj.onload= disable();
	                                    function disable(){
	                                    var summaryType='<%= request.getParameter("nrlSummaryType") %>'
	                                    if (summaryType == "Out Tray" || summaryType == "Completed"){
	                                    document.getElementById("otherDeptFurtherDetails").disabled =true;
	                                    }else{
	                                     document.getElementById("otherDeptFurtherDetails").disabled =false;
	                                    }
	                                    }
                                    </script>
	                        </td>
	                        <td class="nrlBrown" width="10%"><input id = "referOutFurtherDetails" class="nrlBtnWide" type="button" onclick="processButtonClick('<c:out value="${patientInfo.patientId}"/>','REFOUT');" value="Ref Out" />
	                        <script type="text/javascript" for="referOutFurtherDetails">
	                                    var formObj = document.getElementById('nrlfurtherDtl');
	                                    formObj.onload= disable();
	                                    function disable(){
	                                     var summaryType='<%= request.getParameter("nrlSummaryType") %>'
	                                    if (summaryType == "Out Tray" || summaryType == "Completed"){
	                                    document.getElementById("referOutFurtherDetails").disabled =true;
	                                    }else{
	                                     document.getElementById("referOutFurtherDetails").disabled =false;
	                                    }
	                                    }
                                    </script>
	                        </td>
	                        <td class="nrlBrown" width="13%"><input id= "returnToReferrerFurtherDetails" class="nrlBtnWide" type="button" onclick="processButtonClick('<c:out value="${patientInfo.patientId}"/>','RETTOREF');" value="Return To Referrer" />
	                                <script type="text/javascript" for="returnToReferrerFurtherDetails">
	                                    var formObj = document.getElementById('nrlfurtherDtl');
	                                    formObj.onload= disable();
	                                    function disable(){
	                                    var summaryType='<%= request.getParameter("nrlSummaryType") %>'
	                                    if ('${patientInfo.returnToReferrer}'== "true" || summaryType == "Out Tray" || summaryType == "Completed"){
	                                    document.getElementById("returnToReferrerFurtherDetails").disabled =true;
	                                    }else{
	                                     document.getElementById("returnToReferrerFurtherDetails").disabled =false;
	                                    }
	                                    }
                                    </script>
                            </td>
	                        <td class="nrlBrown" width="10%"><input id = "altDecisionFurtherDetails" class="nrlBtnWide" type="button" onclick="processButtonClick('<c:out value="${patientInfo.patientId}"/>','ALTDEC');" value="Alt.Dec" />
									<script type="text/javascript" for="altDecisionFurtherDetails">
	                                    var formObj = document.getElementById('nrlfurtherDtl');
	                                    formObj.onload= disable();
	                                    function disable(){
	                                    var summaryType='<%= request.getParameter("nrlSummaryType") %>'
	                                    if (summaryType == "Out Tray" || summaryType == "Completed"){
	                                    document.getElementById("altDecisionFurtherDetails").disabled =true;
	                                    }else{
	                                     document.getElementById("altDecisionFurtherDetails").disabled =false;
	                                    }
	                                    }
                                    </script>
	                        </td>
	                        <td class="nrlBrown" width="1%">&#160;</td>
						
						</tr>	
						<tr>	
							<td colspan="9" class="nrlBrown" > &#160;</td>
						</tr>
							
						<tr>	
							<td colspan="9" class="nrlBrown" > 
                    			<!-- <jsp:include page="/nrl/common/nrlPatientInfo.jsp"></jsp:include>	
                    			-->
                    			<%@ include file="/nrl/common/nrlPatientInfo.jsp" %>
                    		</td>
						</tr>					
					</table>
				</td>
			</tr>

			<tr>
				<td>
							<%@ include file="/nrl/common/nrlFromInfoLayout.jsp" %>
				</td>
			</tr>
			<tr>	
				<td  class="nrlBrownBlackText" >
					<table width="100%">
						<tr>
							<td>&#160;
							Existing Notes
							</td>
							<td align="right" width="15%">
								<c:choose>
									<c:when test="${!empty(fn:trim(nrl.pacsViewerUrl))}">
										<a href="<c:out value="${nrl.pacsViewerUrl}"/>?view&ris_pat_id=<c:out value="${patientInfo.hospitalNumber}"/>" target="_blank" title="Open PACS image viewer"><img src="../images/16x16/images.png" alt="images" /> PACS Images </a>&#160;
									</c:when>
									<c:otherwise>
										&#160;	
									</c:otherwise>
								</c:choose>
							</td>
						</tr>
						
					</table>
				</td>
			</tr>
			<tr width="100%">
			
				<td width="100%">
					<table><tr>
						<td width="10%">&#160;</td>
						<td width="80%">
							<%@ include file="allNotes.jsp" %>
						</td>
						<td width="10%">&#160;</td>
					</tr></table>
				</td>
				
			</tr>
				
			<tr>	
				<td  class="nrlBrown" align="Center" >
				 &#160; 
				 <input type="submit" value="Add Your Notes" id="AddNotesButton"  class="nrlBtn" disabled/>
				 &#160;</td>
			</tr>		
						
		</table>
		</td>
	</tr>
</table>
	</smvc:form>



