<%@ taglib uri="/tags/struts-bean-el" prefix="bean-el" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html-el" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="/tags/fw" prefix="fw" %>
<%@ taglib uri="/tags/esr-core" prefix="esrcore" %>
<%@ taglib uri="/tags/authz" prefix="auth" %>
<%@ page import='gov.va.med.esr.common.model.lookup.Capability' %>

<c:set var="viewParsedMessage" value="false"/>
<c:set var="viewRawMessage" value="false"/>
<auth:authorize ifAnyGranted="<%=Capability.VIEW_PARSED_MESSAGE.getName()%>"> 
	<c:set var="viewParsedMessage" value="true"/>   	
</auth:authorize>
<auth:authorize ifAnyGranted="<%=Capability.VIEW_RAW_MESSAGE.getName()%>"> 
	<c:set var="viewRawMessage" value="true"/>   	
</auth:authorize>

<c:if test="${selectedMessage != null}">
	<c:set var="messageId" value="${selectedMessage.entityKey.keyValueAsString}" scope="request"/>
        <%  			
        	java.util.HashMap params = new java.util.HashMap();
		params.put("selectedMsgId",(String)request.getAttribute("messageId"));
		String selectedSiteId = (String)request.getAttribute(gov.va.med.esr.ui.message.action.MessageConstants.SELECTED_SITE_ID);
		if(selectedSiteId != null && selectedSiteId.length() > 0) params.put("selectedSiteId",selectedSiteId);
		pageContext.setAttribute("parameters",params);
	%>
</c:if>	     	      
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShell" role="presentation">
<tr>
    <td width="100%">
    	<table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShellTableBody" role="presentation">
	   <tr>
	     <td>
	    	<table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShellTableHead" role="presentation">
		 <tr> 
			<td class="moduleBlueBox"><img alt=""  src="../images/spacer.gif" width="28" height="23"/></td>
			<td width="80%" class="moduleHeadline"><bean-el:message key="title.message.detail" /></td>
			<c:if test="${selectedMessage != null}">
				<c:if test="${viewParsedMessage == true}">
					<td nowrap class="moduleBlueLink" style="padding: 1 8 1 8"><fw:link action="messageDetail.do?methodName=viewParsedMessage" name="parameters"><bean-el:message key="label.message.viewParsedMessage" /></fw:link></td>
					<td class="moduleHeadline">&nbsp;</td>
				</c:if>
				<c:if test="${viewRawMessage == true}">
				<td nowrap class="moduleBlueLink" style="padding: 1 8 1 8"><fw:link action="messageDetail.do?methodName=viewRawMessage" name="parameters"><bean-el:message key="label.message.viewRawMessage" /></fw:link></td>
				<td class="moduleHeadline">&nbsp;</td>
				</c:if>
			</c:if>
			<td nowrap class="moduleBlueLink" style="padding: 1 8 1 8">
			<c:choose>
			  <c:when test="${not empty selectedSiteId}"><fw:link action="/hl7Message.do?methodName=displayMessages" paramName="selectedSiteId" paramId="selectedSiteId"><bean-el:message key="link.name.backToMessageList"/></fw:link></c:when>
		    	  <c:otherwise><fw:link action="/hl7Message.do?methodName=chooseDisplayMessages"><bean-el:message key="link.name.backToMessageList"/></fw:link></c:otherwise>
			</c:choose>
			</td>
			<td><img alt=""  src="../images/spacer.gif" width="5"/></td>		
		 </tr>
    		</table>
	     </td>
	    </tr>
                  
	    <tr><td class="moduleValue">

	     	<c:choose>
	     	  <c:when test="${selectedMessage != null}">		  
		      <table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShellTableBody" role="presentation">
		      <tr>
			 <td width="45%" class="moduleLabel"><bean-el:message key="label.message.batchMessageId" />:</td>
			 <td width="55%" class="moduleValue" nowrap><esrcore:displayValue name="selectedMessage" property="batchControlIdentifier"/></td>
		      </tr>
		      <tr>
			 <td width="45%" class="moduleLabel"><bean-el:message key="label.message.messageId" />:</td>
			 <td width="55%" class="moduleValue" nowrap><esrcore:displayValue name="selectedMessage" property="controlIdentifier"/></td>
		      </tr>
		      <tr>
			 <td class="moduleLabel"><bean-el:message key="label.message.messageType" />:</td>
			 <td class="moduleValue"><esrcore:displayValue name="selectedMessage" property="type.code"/></td>
		      </tr>
		      <tr>
			<td class="moduleLabel"><bean-el:message key="label.message.transmissionSite" />:</td>
			<td class="moduleValue" nowrap><esrcore:displayValue name="selectedMessage" property="vaFacility.facilityName"/></td>
		      </tr>
		      <tr>
			<td class="moduleLabel"><bean-el:message key="label.message.transmissionDate" />:</td>
			<td class="moduleValue" nowrap><esrcore:displayDate name="selectedMessage" dateProperty="transmissionDate" displayTime="true" nullText=""/></td>
		      </tr>
		      <tr>
			<td class="moduleLabel"><bean-el:message key="label.message.status" />:</td>
			<td class="moduleValue"><esrcore:displayValue name="selectedMessage" property="status.description"/></td>
		      </tr>
		      <tr>
			<td class="moduleLabel"><bean-el:message key="label.message.ackType" />:</td>
			<td class="moduleValue"><esrcore:displayValue name="selectedMessage" property="ackType"/></td>
		      </tr>
		      <tr>
			<td class="moduleLabel"><bean-el:message key="label.message.dateTimeAckReceived" />:</td>
			<td class="moduleValue"><esrcore:displayDate name="selectedMessage" dateProperty="ackDate" displayTime="true" nullText=""/></td>
      		      </tr>
      		      <tr>
		      	<td class="moduleLabel"><bean-el:message key="label.message.retransmissionID" />:</td>
		      	<td class="moduleValue"><esrcore:displayValue name="selectedMessage" property="initiatingMessage.controlIdentifier"/></td>
		      </tr>
		      <tr>
		      	<td class="moduleLabel"><bean-el:message key="label.message.retransmissionCount" />:</td>
		      	<td class="moduleValue"><esrcore:displayValue name="selectedMessage" property="retransmissionCount"/></td>
		      </tr>
		      </table>
	      	  </c:when>
	      	  <c:otherwise><bean-el:message key="label.noDataAvailable" /></c:otherwise>
	      	</c:choose>
	      
	  </td></tr>
	</table>
    </td>
</tr>
</table>
