<%@ include file="/includes.jsp"%>
<!-- start emdt/tiles/emdtFormMenu.jsp -->
<script type="text/javascript">
function gotoPatientDetails(){
	 document.location.href="viewPatient.form?formName=";
}
function gotoForm(formName,filterFormId){
	 document.location.href="../emdt/consultationNote.form?filterFormId="+filterFormId;
}
function gotoSummary(summaryId){
	 document.location.href="patientSummaryActions.form?method=view&summaryId="+summaryId+"&page=referrals";
}
</script>
<c:choose>
	<c:when test="${filterForm.name ne null }"><c:set var="nameOfForm" value="${filterForm.name}"></c:set></c:when>
	<c:otherwise><c:if test="${consultationNoteForm ne null}"><c:set var="nameOfForm" value="${consultationNoteForm.view.formName}"></c:set></c:if></c:otherwise>
</c:choose>

<c:set var="referralsDefinition" value="${referralPatientDto.referralsDefinition}"  scope="request"/>
<c:if test="${referralsDefinition ne null}">
	<c:set var="groupBy" value="" scope="request" ></c:set>
	<c:if test="${nameOfForm !=null or nameOfForm ne ''}">
		<c:forEach var="formSummaryMapOrder" items="${referralsDefinition.formSummaryMapOrder}">
			<c:if
				test="${formSummaryMapOrder.formOrSummaryName eq nameOfForm and formSummaryMapOrder.groupName!='Top Level' }">
				<c:set var="groupBy" value="${formSummaryMapOrder.groupName}" scope="request"></c:set>
			</c:if>
		</c:forEach>
	</c:if>
	<c:if test="${nameOfForm !=null or nameOfForm ne '' }">
		<c:forEach var="formSummaryMapOrder" items="${referralsDefinition.formSummaryMapOrder}">
			<c:if test="${formSummaryMapOrder.formOrSummaryName eq summaryName and formSummaryMapOrder.groupName=='Top Level' }">
				<c:set var="groupBy" value="" scope="request"></c:set>
			</c:if>
		</c:forEach>
	</c:if>
<c:choose>
	<c:when test="${ summaryName eq null and ((null eq nameOfForm) or  ('' eq nameOfForm)) and addToMeeting ne true }">
		<c:set var="menuButtonHolderDivClass" value="menuButtonSquare selected"/>
	</c:when>
	<c:otherwise>
		<c:set var="menuButtonHolderDivClass" value="menuButtonSquare blue"/></c:otherwise>
</c:choose>
	<c:choose>
		<c:when test="${groupBy ne null and groupBy ne ''}">
					<div class="menuHolder">
						<div class="<c:out value="${menuButtonHolderDivClass}"/>">
							<a href="viewPatient.form?formName=">Patient<br />Details</a>
						</div>
						<tiles:insertTemplate template ="forms/groupFormsMenu.jsp"  /><br/>
						<tiles:insertTemplate template ="forms/formsMenu.jsp" />
					</div>
		</c:when>
		<c:otherwise>
			<div class="menuHolder">
					<div class="<c:out value="${menuButtonHolderDivClass}"/>">
						<a href="viewPatient.form?formName=">Patient<br /> Details</a>
					</div>
				<tiles:insertTemplate template ="forms/groupFormsMenu.jsp"  />
			</div>
		</c:otherwise>
	</c:choose>
	<!-- 
	<div class="menuSub2Holder">
		<div
			<c:choose>
		 		<c:when test="${addToMeeting eq true}">class="menuButtonRect selected"</c:when>
				<c:otherwise>class="menuButtonHolderBlueLong"</c:otherwise>
			</c:choose>
			onclick="location.href='../referrals/addCurrentPatientToNextMeeting.form'">
			<br />Add to MDT <br />Meeting
		</div>
	</div>
	 -->
</c:if>

<!-- end emdt/tiles/emdtFormMenu.jsp -->
