<%@ include file="/includes.jsp"%>
<link href="../referrals/css/main.css" type="text/css" rel="stylesheet" />
<style type="text/css">
.patientHistoryFormNameTD	{
	padding-left:	20px;
	color: #303070;
	text-align:	left;
}
</style>

<script type="text/javascript">
	function openPatient(id,itemid) {
		if(id) {
			//document.getElementById("id").value=id;
			//document.getElementById("itemId").value=itemid;
			document.location = "../meetings/selectMeeting.form?id="+id+"&forward=selectItem&itemId="+itemid;
			//document.getElementById("formnameId").submit();
		} else {
			window.alert("No patient id");
		}
	}
</script>
<webapp:namedList name="speciality" domain="EMDT" id="specialityNL"/>
<webapp:listToMap var="specialityMap" list="${specialityNL}"/>
<c:set var="sorthref" value="patientInMeeting.form?action=SortAction&sortCol=" ></c:set>
<table width="90%" cellspacing="0" class="table" id="searchTableId" >
	<tr class="tableHeader">
		<th class="tableColHeader">
		<c:choose>
			<c:when test="${param.sortCol == 'surname' && param.sortOrder == 'asc' }">
				<a href="<c:out value="${sorthref}"/>surname&sortOrder=desc">Surname</a>
			</c:when>
			<c:otherwise>
				<a href="<c:out value="${sorthref}"/>surname&sortOrder=asc">Surname</a>
			</c:otherwise>
		</c:choose>
		</th>
		<th class="tableColHeader" >
		<c:choose>
			<c:when test="${param.sortCol == 'forename' && param.sortOrder == 'asc' }">
				<a href="<c:out value="${sorthref}"/>forename&sortOrder=desc">Forename</a>
			</c:when>
			<c:otherwise>
				<a href="<c:out value="${sorthref}"/>forename&sortOrder=asc">Forename</a>
			</c:otherwise>
		</c:choose>
		</th>
		<th class="tableColHeader" >
		<c:choose>
			<c:when test="${param.sortCol == 'hospnum' && param.sortOrder == 'asc' }">
				<a href="<c:out value="${sorthref}"/>hospnum&sortOrder=desc">Patient Hospital Number</a>
			</c:when>
			<c:otherwise>
				<a href="<c:out value="${sorthref}"/>hospnum&sortOrder=asc">Patient Hospital Number</a>
			</c:otherwise>
		</c:choose>
		</th>
		<th class="tableColHeader" >
		<c:choose>
			<c:when test="${param.sortCol == 'dob' && param.sortOrder == 'asc' }">
				<a href="<c:out value="${sorthref}"/>dob&sortOrder=desc">Date&nbsp;of&nbsp;Birth</a>
			</c:when>
			<c:otherwise>
				<a href="<c:out value="${sorthref}"/>dob&sortOrder=asc">Date&nbsp;of&nbsp;Birth</a>
			</c:otherwise>
		</c:choose></th>
		<th class="tableColHeader" >
		<c:choose>
			<c:when test="${param.sortCol == 'speciality' && param.sortOrder == 'asc' }">
				<a href="<c:out value="${sorthref}"/>speciality&sortOrder=desc">Meeting Speciality</a>
			</c:when>
			<c:otherwise>
				<a href="<c:out value="${sorthref}"/>speciality&sortOrder=asc">Meeting Speciality</a>
			</c:otherwise>
		</c:choose>
		</th>
		<th class="tableColHeader">
		<c:choose>
			<c:when test="${param.sortCol == 'meetingDate' && param.sortOrder == 'asc' }">
				<a href="<c:out value="${sorthref}"/>meetingDate&sortOrder=desc">Meeting Date and Time</a>
			</c:when>
			<c:otherwise>
				<a href="<c:out value="${sorthref}"/>meetingDate&sortOrder=asc">Meeting Date and Time</a>
			</c:otherwise>
		</c:choose></th>
		<th class="tableColHeader">
		<c:choose>
			<c:when test="${param.sortCol == 'meetingDate' && param.sortOrder == 'asc' }">
				<a href="<c:out value="${sorthref}"/>hospital&sortOrder=desc">Hospital</a>
			</c:when>
			<c:otherwise>
				<a href="<c:out value="${sorthref}"/>hospital&sortOrder=asc">Hospital</a>
			</c:otherwise>
		</c:choose>
		</th>
	</tr>
	<c:choose>
		<c:when
			test="${(meetingList ne null) and (fn:length(meetingList) gt 0)}">
			<c:forEach var="meetingDTO" items="${meetingList}" >
				<tr class="clickable">
					<td class="tableCell" onclick="openPatient('<c:out value="${meetingDTO.meeting.guid}"/>','<c:out value="${meetingDTO.meetingItem.guid}"/>')"><c:out value="${meetingDTO.meetingItem.patientDiscussed.surname}"/>&nbsp;</td>
					<td class="tableCell" onclick="openPatient('<c:out value="${meetingDTO.meeting.guid}"/>','<c:out value="${meetingDTO.meetingItem.guid}"/>')"><c:out value="${meetingDTO.meetingItem.patientDiscussed.forename}"/>&nbsp;</td>
					<td class="tableCell" align="right" onclick="openPatient('<c:out value="${meetingDTO.meeting.guid}"/>','<c:out value="${meetingDTO.meetingItem.guid}"/>')"><c:out value="${meetingDTO.meetingItem.patientDiscussed.hospitalNumber}"/>&nbsp;</td>
					<td class="tableCell" align="right" onclick="openPatient('<c:out value="${meetingDTO.meeting.guid}"/>','<c:out value="${meetingDTO.meetingItem.guid}"/>')"><fmt:formatDate value="${meetingDTO.meetingItem.patientDiscussed.dateOfBirth}" pattern="dd MMM yyyy" />&nbsp;</td>
					<td class="tableCell" align="center" onclick="openPatient('<c:out value="${meetingDTO.meeting.guid}"/>','<c:out value="${meetingDTO.meetingItem.guid}"/>')">	<c:out value="${specialityMap[meetingDTO.meeting.tumourGroup] }"/>&nbsp;</td>
					<td class="tableCell" align="center" onclick="openPatient('<c:out value="${meetingDTO.meeting.guid}"/>','<c:out value="${meetingDTO.meetingItem.guid}"/>')"><fmt:formatDate pattern="dd MMM yyyy" value="${meetingDTO.meeting.date}" /> - 
					<fmt:formatDate pattern="HH:mm"  value="${meetingDTO.meeting.date}" /></td>
					<td class="tableCell" align="center" onclick="openPatient('<c:out value="${meetingDTO.meeting.guid}"/>','<c:out value="${meetingDTO.meetingItem.guid}"/>')"><c:out value="${meetingDTO.meeting.hospital.hospitalName}"/></td>
				</tr>
			</c:forEach>
		</c:when>
		<c:otherwise>
			<tr>
				<td align="center" class="message" colspan="11">No Patients	Found</td>
			</tr>
		</c:otherwise>
	</c:choose>
	<tr class="tableFooter">
		<td colspan="7" align="left">&nbsp;</td>
	</tr>
</table>
