<%@ include file="/includes.jsp" %>
<jsp:useBean id="today" class="java.util.Date" scope="page" />
<c:set var="patient" value="${emdt.patient}"/>
<fmt:formatDate value="${today}" var="formattedDate" type="date" pattern="MM-dd-yyyy" />
<c:set var="consultationNotePath" value="${fn:replace(consultationNoteForm.view.renderer,'\','/')}"/>
	<head>
		<title>Print Form</title>
		<link rel="stylesheet" href="../css/webapp.css" type="text/css" />
		<link rel="stylesheet" href="printForm.css" type="text/css" />
		<link rel="stylesheet" href="printFormPrint.css" type="text/css" media="print"/>
		<c:if test="${not empty consultationNoteForm.view.form .colourCode }">
			<style>
				.formBgColor {
					background-color:${consultationNoteForm.view.form .colourCode}
				}
					
			</style>
		</c:if>
		<style media="screen">
		<!-- don't print these 'print only' elements -->

		div.printPageHeader {
			display: none;
			}
		div.printPageFooter {
			display: none;
			}
		
		</style>
	</head>
	<body>
	
		<div class="printPageHeader">Patient '<c:out value="${patient.fullName}"/>', hospital number <c:out value="${patient.hospitalNumber}"/>, Date of birth <fmt:formatDate value="${patient.dateOfBirth }" pattern="dd MMM yyyy" /></div>
		<div class="printPageFooter">Page <span id="pagenumber" /> of <span id="pagecount"/> (PDF created <c:out value="${today}"/>)</div>
	
		<div class="printFormPart" align="center">
			<div class="printFormDefinition" align="left">
				<div class="printFormDefinitionTitle formBgColor">
					<c:out value="${consultationNoteForm.view.form.label}"/>
				</div>
				<table border="0" style="width:100%">
					<tr>
						<td style="width:50%" valign="top">
							<table style="width:100%">
								<tr>
									<td class="printFormDefinitionPropertyName">Patient Name:</td>
									<td class="printFormDefinitionPropertyValue"><c:out value="${patient.title}"/> <c:out value="${patient.forename}"/> <c:out value="${patient.surname}"/></td>
								</tr>
								<tr>
									<td class="printFormDefinitionPropertyName">Hospital Number:</td>
									<td class="printFormDefinitionPropertyValue"><c:out value="${patient.hospitalNumber}"/></td>
								</tr>
								<tr>
									<td class="printFormDefinitionPropertyName">NHS Number:</td>
									<td class="printFormDefinitionPropertyValue"><c:out value="${patient.nhsNumber}"/></td>
								</tr>
								<tr>
									<td class="printFormDefinitionPropertyName">Date of Birth:</td>
									<td class="printFormDefinitionPropertyValue"><fmt:formatDate value="${patient.dateOfBirth }" pattern="dd MMM yyyy" /></td>
								</tr>
								<tr>
									<td class="printFormDefinitionPropertyName">Age:</td>
									<td class="printFormDefinitionPropertyValue"><c:out value="${patient.currentAge}"/></td>
								</tr>
								<tr>
									<td class="printFormDefinitionPropertyName">Gender:</td>
									<td class="printFormDefinitionPropertyValue"><webapp:listValue key="${patient.sex}" domain="EMDT" listName="SexCode" /></td>
								</tr>
								<tr>
									<td class="printFormDefinitionPropertyName" valign="top">Address:</td>
									<td class="printFormDefinitionPropertyValue" valign="top">
<pre><c:out value="${patient.address.trim()}"/>
<c:out value="${patient.postcode }"/></pre>
									</td>
								</tr>
								<tr>
									<td class="printFormDefinitionPropertyName">Home phone:</td>
									<td class="printFormDefinitionPropertyValue"><c:out value="${patient.homePhoneNumber}"/></td>
								</tr>
								<tr>
									<td class="printFormDefinitionPropertyName">Mobile phone:</td>
									<td class="printFormDefinitionPropertyValue"><c:out value="${patient.mobilePhoneNumber}"/></td>
								</tr>
								<tr>
									<td class="printFormDefinitionPropertyName">Work phone:</td>
									<td class="printFormDefinitionPropertyValue"><c:out value="${patient.workPhoneNumber}"/></td>
								</tr>
								
							</table>
						</td>
						<td style="width:50%" valign="top">
							<table style="width:100%">
								<tr>
									<td class="printFormDefinitionPropertyName">GP Name:</td>
									<td class="printFormDefinitionPropertyValue"><c:out value="${patient.gpForename}"/> <c:out value="${patient.gpSurname}"/></td>
								</tr>
								<tr>
									<td class="printFormDefinitionPropertyName">GP Code:</td>
									<td class="printFormDefinitionPropertyValue"><c:out value="${patient.gpGmpCode}"/></td>
								</tr>
								<tr>
									<td class="printFormDefinitionPropertyName" valign="top">GP Address:</td>
									<td class="printFormDefinitionPropertyValue"><pre><c:out value="${patient.gpSurgeryAddress}"/><c:out value="${patient.gpPostcode }"/></pre></td>
								</tr>
								<tr>
									<td class="printFormDefinitionPropertyName">GP Phone:</td>
									<td class="printFormDefinitionPropertyValue"><c:out value="${patient.gpTelephoneNumber}"/></td>
								</tr>
								<tr>
									<td class="printFormDefinitionPropertyName">GP Fax:</td>
									<td class="printFormDefinitionPropertyValue"><c:out value="${patient.gpFaxNumber}"/></td>
								</tr>
								<tr>
									<td class="printFormDefinitionPropertyName"> &nbsp;</td>
									<td class="printFormDefinitionPropertyValue"></td>
								</tr>
								<tr>
									<td class="printFormDefinitionPropertyName">Date Form Created:</td>
									<td class="printFormDefinitionPropertyValue"> <fmt:formatDate value="${consultationNoteForm.view.note.creationDate}" type="date" pattern="dd MMM yyyy HH:mm" /></td>
								</tr>
								<tr>
									<td class="printFormDefinitionPropertyName">Date Form Modified:</td>
									<td class="printFormDefinitionPropertyValue"><fmt:formatDate value="${consultationNoteForm.view.note.modifiedDate}" type="date" pattern="dd MMM yyyy HH:mm" /></td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
				<br/>
				</div>
				<div class="printFormDefinition" >
					<table border="0" style="width:100%">
						<tr>
							<td style="width:100%">
								<webapp:namedListByFormDefinition formDefinition="${consultationNoteForm.view.form}" id="namedListMap" filterName="${requestScope.ATT_FilterdCode}" filterHospCode="${emdt.currentUser.hospital.hospitalCode}"/>
								<c:set var="namedListMap" value="${namedListMap}" scope="request"/>
								<c:set var="isPrintPage" value="true" scope="request" />
								<tiles:insertTemplate template="${consultationNotePath}" />
							</td>
						</tr>
					</table>
				</div>
				
				<div>
				<h4>Notes</h4>
				<c:choose>
					<c:when test="${empty commentsList}">
						(none)
					</c:when>
					<c:otherwise>
						<table>
						<c:forEach items="${commentsList}" var="comment" varStatus="c">
							<tr>
								<td colspan="3">
								<hr color="lightgray" size="1" />
								</td>
							</tr>
							<tr>
								<td width="20%" class="commentsUserName"><c:out value="${comment.username}"/><br/><c:out value="${comment.hospitalCode}"/></td>
								<td width="60%" class="commentsText"><pre><c:out value="${comment.comment}"/></pre></td>
								<td width="20%" class="commentsDate"><fmt:formatDate value="${comment.dateOfComment}" pattern="dd MMM yyyy, HH:mm" /></td>
							</tr>
							<tr>
								<td class="commentsText"><input type="hidden" name="fileName" id="fileName" /></td>
								<td class="commentsAttachments">
									<c:if test="${not empty comment.attachedNotes}">
									<img src="../images/16x16/page.png" alt="Document" /> <c:out value="${comment.attachedNotesOriginalName}"/>
									</c:if>
								</td>
								<td></td>
							</tr>
						</c:forEach>
						</table>
					</c:otherwise>				
				</c:choose>
				
				</div>
				
	</div>
	</body>
