<script language="JavaScript" src="../scripts/ESR-Script.js"></script>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ 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/esr-core" prefix="esrcore" %>
<%@ taglib uri="/tags/valuelist" prefix="vlh" %>
<%@ taglib uri="/tags/fw" prefix="fw" %>
<%@ taglib uri="/tags/authz" prefix="auth" %>
<%@ page import='gov.va.med.esr.common.model.lookup.Capability' %>

<c:set var="displayAllMessages" scope="page"><bean-el:message key="link.displayAllMessages"/></c:set>
<c:set var="displayMessages" scope="page"><bean-el:message key="link.name.viewAllMessages"/></c:set>
<c:set var="displayArchivedMessages" scope="page"><bean-el:message key="link.name.viewAllArchivedMessages"/></c:set>
<c:set var="displaySiteMessages" scope="page"><bean-el:message key="link.name.viewFacilityMessages"/></c:set>
<c:set var="sendQueryMessageZ07Link"><bean-el:message key="link.name.sendQueryZ07" /></c:set>
<c:set var="sendMsdsQueryMessageLink"><bean-el:message key="link.name.sendMsdsQuery" /></c:set>
<c:set var="preferredFacility" scope="page"><bean-el:message key="label.preferredFacility"/></c:set>
<c:set var="expandableSectionCollapsed" scope="page"><bean-el:message key="label.expandableSectionCollapsed"/></c:set>

<c:set var="isAddAPerson" value="false"></c:set>
<c:if test="${facilityForm.addAPerson == true}">  
    <c:set var="isAddAPerson" value="true"></c:set>
</c:if>

<table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShell" role="presentation">
<html-el:form action="/facility" method="post">
  <%@ include file="/admin/csrfgentoken.jsp" %>
  <tr>
    <td>
      <table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShellTable" 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="24" height="19"/></td>
                <td nowrap style="padding-left: 7"><bean-el:message key="label.facilities"/></td>
                <td width="100%"><img alt=""  src="../images/spacer.gif"></td>
                <!--<auth:authorize ifAnyGranted="<%=Capability.SEND_QUERY_MESSAGE_Z07.getName()%>">
					<td nowrap class="moduleBlueLink" style="padding: 1 8 1 8"><fw:link action="sendMsdsQueryMessage" paramId="methodName" paramName="sendMsdsQueryMessageLink"><bean-el:message key="link.name.sendMsdsQuery"/></fw:link></td>
				</auth:authorize>
                <td><img alt=""  src="../images/spacer.gif" width="5"/></td>-->
				<auth:authorize ifAnyGranted="<%=Capability.SEND_QUERY_MESSAGE_Z07.getName()%>">
				<!-- do not show link if add a person -->
				   <c:if test="${isAddAPerson == false}">
    		    		<td nowrap class="moduleBlueLink"  style="padding: 1 8 1 8"><fw:link  action="sendQueryMessageZ07" paramId="methodName" paramName="sendQueryMessageZ07Link"><bean-el:message key="link.name.sendQueryZ07"/></fw:link></td>
		    		</c:if>
				</auth:authorize>
                <td><img alt=""  src="../images/spacer.gif" width="5"/></td>               
				<auth:authorize ifAnyGranted="<%=Capability.VIEW_TRANSMISSION_LOG.getName()%>">
				   <c:if test="${isAddAPerson == false}">
				       <td nowrap class="moduleBlueLink" style="padding: 1 8 1 8"><fw:link action="hl7Message.do?methodName=displayArchivedMessages"><bean-el:message key="link.name.viewAllArchivedMessages"/></fw:link></td>
				   </c:if>
				</auth:authorize>
				<td><img alt=""  src="../images/spacer.gif" width="5"/></td>
				<auth:authorize ifAnyGranted="<%=Capability.VIEW_TRANSMISSION_LOG.getName()%>">
				   <c:if test="${isAddAPerson == false}">
				       <td nowrap class="moduleBlueLink" style="padding: 1 8 1 8"><fw:link action="hl7Message.do?methodName=displayMessages"><bean-el:message key="link.name.viewAllMessages"/></fw:link></td>
				   </c:if>
				</auth:authorize>
              </tr>
            </table>
          </td>
        </tr>
        <tr>
          <td>
    	    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="moduleShellTableBody" role="presentation">
                <c:choose>
                <c:when test="${vlhlist == null}">
                <tr>
                  <td class="moduleLabel" style="padding:10 0 10 10; text-align: left"><bean-el:message key="label.noDataAvailable"/></td>
                </tr>
                </c:when>
                <c:otherwise>
                <tr>
                  <td>
                    <%-- Begin value list --%>
                    <div id="facilitiesvisisted" style="border-width:0px;">
                      <table id="tableResult" align="center" width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleTable" role="presentation">
                        <vlh:root id="personSearchTableId" value="vlhlist" url="?" includeParameters="*" configName="valueListConfigBeanLookAndFeel">
                          <vlh:addParam name="checkboxName" value="Select" temp="false"/>
                          <tr>
                            <td colspan="6">
                              <table class="pagelinks" role="presentation">
                                <tr>
                                  <td width="45%"><img alt=""  src="../images/spacer.gif"></td>
                                  <td width="5%" nowrap="true">
                                    <span class="pagebanner"><c:out value="${vlhlist.valueListInfo.totalNumberOfEntries}"/> Total
                                    - Page (<c:out value="${vlhlist.valueListInfo.pagingPage}"/> of <c:out value="${vlhlist.valueListInfo.totalNumberOfPages}"/>).
                                    &nbsp;</span>
                                  </td>
                                  <td width="5%">
                                    <c:choose>
                                    <c:when test="${vlhlist.valueListInfo.totalNumberOfPages > 1}">
                                      <vlh:paging attributes="class=\"pagelinks\"" pages="10"><c:out value="${pagepersonSearchTableId}"/>&nbsp;</vlh:paging>
                                    </c:when>
                                    <c:otherwise>
                                      &nbsp;
                                    </c:otherwise>
                                    </c:choose>
                                  </td>
                                  <td width="45%"><img alt=""  src="../images/spacer.gif"></td>
                                </tr>
                              </table>
                            </td>
                          </tr>

                          <%-- Facility Row Header --%>
                          <vlh:row bean="facilityBean">
                          <tr>
                            <td colspan="6">
                              <table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShellLowTableHead" role="presentation">
                                <tr>
                                  <td class="moduleBrownBox"><img alt=""  src="../images/spacer.gif" width="24" height="19"/></td>
                                  <%-- Include a check mark if it is a preferred facility --%>
                                  <c:if test="${facilityBean.preferredFacility == 'true'}">
                                    <td style="padding-left: 7; padding-top: 5"><html-el:img alt="${preferredFacility}"  src="../images/check_green.gif"/></td>
                                  </c:if>
                                  <td width="60%" style="padding: 7 7" nowrap>
                                    <c:out value="${facilityBean.vaFacility.facilityName}"/>
                                  </td>
                                  <td width="100%"><img alt=""  src="../images/spacer.gif"></td>

								  <auth:authorize ifAnyGranted="<%=Capability.VIEW_TRANSMISSION_LOG.getName()%>">
                                    <td nowrap class="moduleBlueLink" style="padding: 1 8 1 8">
					                    <c:set var="stationNumber" value="${facilityBean.vaFacility.code}"/>
                                    	<fw:link action="hl7Message.do?methodName=displayMessages" paramId="selectedSiteId" paramName="stationNumber"><bean-el:message key="link.name.viewFacilityMessages"/></fw:link>
                                    </td>
								  </auth:authorize>
                                </tr>
                              </table>
                            </td>
                          </tr>

                          <%-- Facility Data --%>
                          <tr>
                            <td valign="top" class="darkLabel" style="text-align: left; padding-left: 10" nowrap><bean-el:message key="label.primaryMeansTestFacility"/>:</td>
                            <td class="darkValue" valign="top" nowrap>
                              <c:choose>
                              <c:when test="${facilityBean.primaryTestFacility == 'true'}">
                                <bean-el:message key="text.yes"/>
                              </c:when>
                              <c:otherwise>
                                <bean-el:message key="text.no"/>
                              </c:otherwise>
                              </c:choose>
                            </td>
                            <td class="darkValue" width="50%"><img alt=""  src="../images/spacer.gif"></td>
                            <td class="darkLabel">&nbsp;</td>
                            <td class="darkValue">&nbsp;</td>
                            <td class="darkValue" width="50%"><img alt=""  src="../images/spacer.gif"></td>
                          </tr>
			  <tr><td>&nbsp;</td></tr>
			  <!-- Patient Visit Summaries for multiple years -->
			  <c:set var="rowLabelColor" value="darkLabel" />
                          <c:set var="rowValueColor" value="darkValue" />

			  <c:forEach var="patientVisitSummary" items="${facilityBean.patientVisitSummaries}">
			    <c:choose>
			  	<c:when test="${rowLabelColor == 'darkLabel'}">
					  <c:set var="rowLabelColor" value="label" />
					  <c:set var="rowValueColor" value="value" />
				</c:when>
				<c:otherwise>
					  <c:set var="rowLabelColor" value="darkLabel" />
					  <c:set var="rowValueColor" value="darkValue" />
				</c:otherwise>
                            </c:choose>
                          <tr>
                             <td class="<c:out value="${rowLabelColor}"/>" style="text-align: left; padding-left: 10" nowrap><bean-el:message key="label.incomeYear"/>:</td>
                             <td class="<c:out value="${rowValueColor}"/>" valign="top" nowrap><esrcore:displayValue name="patientVisitSummary" property="incomeYear" nullText=""/></td>
                             <td class="<c:out value="${rowLabelColor}"/>">&nbsp;</td>
                             <td class="<c:out value="${rowLabelColor}"/>" style="text-align: left; padding-left: 10" nowrap><bean-el:message key="label.dateOfLastVisit"/>:</td>
                             <td class="<c:out value="${rowValueColor}"/>" valign="top" nowrap><esrcore:displayValue name="patientVisitSummary" property="lastVisitDate" nullText=""/></td>
                             <td class="<c:out value="${rowLabelColor}"/>">&nbsp;</td>
                          </tr>
                          <tr>
                             <td class="<c:out value="${rowLabelColor}"/>" style="text-align: left; padding-left: 10" nowrap><bean-el:message key="label.numberOfInpatientDays"/>:</td>
                             <td class="<c:out value="${rowValueColor}"/>" valign="top" nowrap><esrcore:displayValue name="patientVisitSummary" property="inpatientDays" nullText=""/></td>
                             <td class="<c:out value="${rowLabelColor}"/>">&nbsp;</td>
                             <td class="<c:out value="${rowLabelColor}"/>" style="text-align: left; padding-left: 10" nowrap><bean-el:message key="label.numberOfOutpatientDays"/>:</td>
                             <td class="<c:out value="${rowValueColor}"/>" valign="top" nowrap><esrcore:displayValue name="patientVisitSummary" property="outpatientDays" nullText=""/></td>
                             <td class="<c:out value="${rowLabelColor}"/>">&nbsp;</td>
                          </tr>
						  </c:forEach>

					      <auth:authorize ifAnyGranted="<%=Capability.VIEW_FEE_BASIS.getName()%>">

                          <%-- Fee Basis Program Information Expand/Collapse Section --%>
                          <tr>
                            <td colspan="6">
                              <table align="left" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation">
                                <tr>
                                  <td class="moduleLabel" style="padding: 5 0 5 10; text-align: left">
                                    <fw:link href="." onclick="expandOrCollapse(fbBlock_${facilityBean.vaFacility.stationNumber}, fbImage_${facilityBean.vaFacility.stationNumber}, fbHiddenId_${facilityBean.vaFacility.stationNumber}); return false">
                                      <html-el:img alt="${expandableSectionCollapsed}" align="center" border="0" styleId="fbImage_${facilityBean.vaFacility.stationNumber}" src="../images/redArrowRight.gif"/><bean-el:message key="link.name.feeBasisProgram"/>
                                    </fw:link>
                                    <input name="fbHiddenId_<c:out value="${facilityBean.vaFacility.stationNumber}"/>" id="fbHiddenId_<c:out value="${facilityBean.vaFacility.stationNumber}"/>" type="hidden" value="false"/>
                                  </td>
                                </tr>
                              </table>
                            <td/>
                          </tr>

                          <%-- Fee Basis Program Information Data --%>
                          <c:choose>
                              <c:when test="${not empty facilityBean.feeBasisInfo}">
				  			  <tr>
								<td colspan="6">
								  <div id="fbBlock_<c:out value="${facilityBean.vaFacility.stationNumber}"/>" class="expandCollapseBody">
								  <table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShellTableBody" role="presentation">
								  <c:set var="rowLabelColor" value="darkLabel" />
								  <c:set var="rowValueColor" value="darkValue" />
								  <c:forEach var="feeBasisProgram" items="${facilityBean.feeBasisInfo}">
								  <c:choose>
									<c:when test="${rowLabelColor == 'darkLabel'}">
									  <c:set var="rowLabelColor" value="label" />
									  <c:set var="rowValueColor" value="value" />
									 </c:when>
									<c:otherwise>
									  <c:set var="rowLabelColor" value="darkLabel" />
									  <c:set var="rowValueColor" value="darkValue" />
									</c:otherwise>
								  </c:choose>
								  <tr>
									<td class="<c:out value="${rowLabelColor}"/>" style="text-align: left; padding-left: 10" nowrap><bean-el:message key="label.feeBasisProgram"/>:</td>
									<td class="<c:out value="${rowValueColor}"/>" valign="top" nowrap><esrcore:displayValue name="feeBasisProgram" property="name" nullText=""/></td>
									<td class="<c:out value="${rowLabelColor}"/>" width="50%">&nbsp;</td>
									<td class="<c:out value="${rowLabelColor}"/>" style="text-align: left; padding-left: 10" nowrap><bean-el:message key="label.treatmentType"/>:</td>
									<td class="<c:out value="${rowValueColor}"/>" valign="top" nowrap><esrcore:displayValue name="feeBasisProgram" property="treatmentType" nullText=""/></td>
									<td class="<c:out value="${rowLabelColor}"/>" width="50%">&nbsp;</td>
								  </tr>
								  <tr>
									<td class="<c:out value="${rowLabelColor}"/>" style="text-align: left; padding-left: 10" nowrap><bean-el:message key="label.authorizationFrom"/>:</td>
									<td class="<c:out value="${rowValueColor}"/>" valign="top" nowrap><esrcore:displayValue name="feeBasisProgram" property="authorizationFrom" nullText=""/></td>
									<td class="<c:out value="${rowLabelColor}"/>">&nbsp;</td>
									<td class="<c:out value="${rowLabelColor}"/>" style="text-align: left; padding-left: 10" nowrap><bean-el:message key="label.authorizationTo"/>:</td>
									<td class="<c:out value="${rowValueColor}"/>" valign="top" nowrap><esrcore:displayValue name="feeBasisProgram" property="authorizationTo" nullText=""/></td>
									<td class="<c:out value="${rowLabelColor}"/>">&nbsp;</td>
								  </tr>
								  <tr>
									<td class="<c:out value="${rowLabelColor}"/>" style="text-align: left; padding-left: 10" nowrap><bean-el:message key="label.reportDate"/>:</td>
									<td class="<c:out value="${rowValueColor}"/>" valign="top" nowrap><esrcore:displayDate name="feeBasisProgram" dateProperty="reportDate" nullText=""/></td>
									<td class="<c:out value="${rowLabelColor}"/>">&nbsp;</td>
									<td class="<c:out value="${rowLabelColor}"/>" style="text-align: left; padding-left: 10" nowrap>&nbsp;</td>
									<td class="<c:out value="${rowValueColor}"/>" valign="top" nowrap>&nbsp;</td>
									<td class="<c:out value="${rowLabelColor}"/>">&nbsp;</td>
									</tr>
								  <tr><td class="<c:out value="${rowLabelColor}"/>" colspan="6">&nbsp;</td></tr>
								  </c:forEach>
								  </table>
								  </div>
								</td>
							  </tr>
                              </c:when>
                              <c:otherwise>
                           	    <tr><td colspan="6">
               							  <div id="fbBlock_<c:out value="${facilityBean.vaFacility.stationNumber}"/>" class="expandCollapseBody">
                           		<table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShellTableBody" role="presentation">
                           			<tr><td class="value" style="text-align: left; padding-left: 10"><bean-el:message key="message.noFeeBasisPrograms"/></td></tr>
                           		</table>
                           	    </td></tr>
                              </c:otherwise>
                          </c:choose>
                          </auth:authorize>

                          </vlh:row>
                        </vlh:root>
                      </table>
                   </div>
                 </td>
               </tr>
               </c:otherwise>
               </c:choose>
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</html-el:form>
</table>
