<%@ include file="/includes.jsp"%>
<style>
.summaryFormContainer {
	border: black 1px solid;
	xpadding: 3px;
}

.summaryPageHeader {
	display: none;
}

.summaryFieldTable {
	width: 100%;
}

.summaryFieldTitle {
	padding-top: 4px;
	vertical-align: top;
	width: 200px;
}

.summaryFieldValue {
	
}

.summaryFieldRow {
	
}

.summaryPageContainer {
	
}

.summarySectionContainer {
	padding-left: 1em;
	padding-top: 3px;
	padding-bottom: 3px;
	margin-bottom: 3px;
	margin-top: 2px;
}

.summaryFormType {
	font-size: 12pt;
	font-weight: bold;
	color: #4A79A5;
	padding-right: 2em;
}

.summaryFieldType {
	display: none;
}

.summaryFormTitle {
	font-weight: bold;
	font-size: 12pt;
}

.summaryFieldTitle {
	vertical-align: top;
	font-weight: bold;
}

.summaryPageType {
	font-size: 8pt;
	color: #4A79A5;
	padding-right: 2em;
}

.summaryPageTitle {
	font-weight: bold;
}

.summarySectionType {
	color: #4A79A5;
	padding-right: 2em;
}

.summarySectionTitle {
	
}

pre {
	font-family: Arial;
	white-space: pre-wrap; /* css-3 */
	white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */
	white-space: -pre-wrap; /* Opera 4-6 */
	white-space: -o-pre-wrap; /* Opera 7 */
	word-wrap: break-word; /* Internet Explorer 5.5+ */
	width: 99%; /* remove horizontal scroll-bar when viewing in IE7 */
}

.fixedtable {
	width: 100%;
	table-layout: fixed;
}
</style>
<tiles:insertTemplate template ="referralsDetailsTopBar.jsp" ></tiles:insertTemplate>
<div class="container">
<c:choose>
	<c:when
		test="${((webapp.roleManagement and ('InCompleteReferrals' ne parentScreen))  and ('ReferAPatient' ne parentScreen)) or  ('FindExisting' eq parentScreen) }">
		<tiles:insertTemplate template ="/referrals/tiles/managementMenu.jsp" ></tiles:insertTemplate>
	</c:when>
	<c:otherwise>
		<tiles:insertTemplate template ="/referrals/tiles/referralsFormMenu.jsp" ></tiles:insertTemplate>
	</c:otherwise>
</c:choose> <br />
<br />
<br />
<br />
<table width="100%">
	<tr>
		<td><tags:dialogBox title="${summary.label }">
			<table width="100%">
				<tr>
					<td><c:forEach var="form" items="${summary.forms}">
						<div class="summaryFormContainer">
						<div class="summaryFormHeader"><span class="summaryFormType">&nbsp;Form</span>
						<span class="summaryFormTitle"> <c:out value="${form.label }"/>&nbsp;
						<c:choose>
							<c:when
								test="${(webapp.roleManagement  and ('ReferAPatient' ne parentScreen)) or  ('FindExisting' eq parentScreen)}">
								<a href="../referrals/consultationNote.form?formName=&filterFormId=<c:out value="${form.formId}"/>&mode=CREATE&labelVal=<c:out value="${form.label}"/>&buttonVal=Save <c:out value="${form.label}"/>">
							</c:when>
							<c:otherwise>
								<a href="../referrals/consultationNote.form?formName=&filterFormId=<c:out value="${form.formId}"/>">
							</c:otherwise>
						</c:choose>(Create form)</a>
						 <c:if test="${form.consultationNoteId != null }">
							<a href="../referrals/consultationNote.form?formName=&filterFormId=<c:out value="${form.formId}"/>">(View
							Form)</a>
						</c:if> </span></div>
						<c:forEach var="page" items="${form.pages }">
							<div class="summaryPageContainer ">
							<div class="summaryPageHeader"><span
								class="summaryPageType">Page</span><span
								class="summaryPageTitle"><c:out value="${page.label }"/></span></div>
							<c:forEach var="section" items="${page.sections }">
								<div class="summarySectionContainer ">
								<div class="summarySectionHeader"><span
									class="summarySectionType">Section</span><span
									class="summarySectionTitle"><c:out value="${section.label }"/></span></div>
								<table class="fixedtable summaryFieldTable">
									<c:forEach var="field" items="${section.fields }">

										<%-- check if any of the field values have a value and display if so --%>
										<c:set var="fieldHasData" value="false" />
										<c:forEach var="value" items="${field.values }">
											<c:if test="${! empty value}">
												<c:set var="fieldHasData" value="true" />
											</c:if>
										</c:forEach>

										<c:if test="${ fieldHasData }">

											<tr class="summaryRow">

												<c:if test="${!empty field.values}">
													<td class="summaryFieldTitle"><c:out value="${field.label }"/></td>
													<td class="summaryFieldValue">
														<c:forEach var="value" items="${field.values }">
															<pre><c:out value="${value}"/></pre>
														</c:forEach>
													</td>
												</c:if>

											</tr>
										</c:if>

									</c:forEach>
								</table>
								</div>
							</c:forEach></div>
						</c:forEach></div>
					</c:forEach></td>
				</tr>
			</table>
		</tags:dialogBox></td>
	</tr>
</table>
</div>
