<%@ include file="/includes.jsp" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ page import="java.util.Date" %>
<%@ page import="java.text.SimpleDateFormat" %>

<html>
<head>
	<title>Referral Statistics Detailed Report</title>
	<link rel="icon" href="../images/emdt.ico" type="image/x-icon" >
	<link rel="shortcut icon" href="../../images/emdt.ico" type="image/x-icon" >
	<link rel="stylesheet" href="../referrals/css/reports.css" type="text/css"
		media="screen, print">
	
	<style media="print" type="text/css">
	.noPrint {
		visibility: hidden;
		display: none;
	}
	
	
	</style>
	<script type="text/javascript">
		function downloadCSV(){
			document.getElementById('mode').value = 'CSV';
			document.forms[0].action = '../referrals/refDetailReport.form';
			document.forms[0].submit();
		}
	</script>
</head>

<body>

<form>
<h2>National MDM Submissions Statistics Detailed Report</h2>
<b>Date range: <c:out value="${fromDate}"/> - <c:out value="${toDate}"/></b>

<br/> <br/>

<input type="hidden" name="includeHosp" id="includeHosp" value="<c:out value="${includeHosp}"/>"/>
<input type="hidden" name="sortOption" id="sortOption" value="<c:out value="${sortOption}"/>"/>
<input type="hidden" name="fromDate" id="fromDate" value="<c:out value="${fromDate}"/>"/>
<input type="hidden" name="toDate" id="toDate" value="<c:out value="${toDate}"/>"/>
<input type="hidden" name="mode" id="mode" value=""/>

<table border="1" class="report">

	<tr>
		<c:choose>
			<c:when test="${'yes' eq includeHosp}">
				<th>NHS Number</th>
				<th>Referring Hospital Number</th>
				<th><c:out value="${centralHubHospital.hospitalName}"/> Hospital Number</th>
			</c:when>
			<c:otherwise>
				<th>Record No:</th>
			</c:otherwise>
		</c:choose>
			<th>Referred From</th>
			<th>Referral Date</th>
			<th>Response</th>
			<th>Days taken for Referral</th>
			<th>Acknowledgement</th>
	</tr>
	<c:forEach var="report" items="${detailReportListDTO.detailReportList}" varStatus="line">
		<tr>
			<c:choose>
				<c:when test="${'yes' eq includeHosp}">
					<td>&nbsp;<c:out value="${report.nhsNum}"/></td>
					<td>&nbsp;<c:out value="${report.referringHosiptalNum}"/></td>
					<td>&nbsp;<c:out value="${report.basingstokeHosiptalNum}"/></td>
				</c:when>
				<c:otherwise>
					<td><c:out value="${line.count}"/></td>
				</c:otherwise>
			</c:choose>
			<td>&nbsp;<c:out value="${report.referredFrom}"/></td>
			<td>&nbsp;<c:out value="${report.referralDate}"/></td>
			<td>&nbsp;<c:out value="${report.responseDateOfInformation}"/></td>
			<td>&nbsp;<c:out value="${report.timeTakenForReferral}"/></td>
			<td>&nbsp;<c:out value="${report.acknowlegedDate}"/></td>
		</tr>
	</c:forEach>
</table>
<br/>
	<table border="0" width="100%" style="border-top: 0;border-left: 0;border-right: 0;border-bottom:0">
		<tr>
			<td>Total Number of Incomplete NMDM Submissions  <c:out value="${detailReportListDTO.numOfReferralsInDraft}"/></td>
		</tr>
		<tr>
			<td>Total Number of NMDM Submissions waiting for response: <c:out value="${detailReportListDTO.numOfReferralsWaitingResp}"/>
			</td>
			<td rowspan="3" align="right">
				
			</td>
		</tr>
		<tr>
		<td>Total Number of NMDM Submissions waiting for acknowledgement: <c:out value="${detailReportListDTO.numOfReferralsWaitingAck}"/></td>
		</tr>
		<tr>
			<td>Total Number of NMDM Submissions completed: <c:out value="${detailReportListDTO.numOfReferralsCompleted}"/>
			</td>
		</tr>
		<tr>
			<td>Total Number of NMDM Submissions Assigned: <c:out value="${detailReportListDTO.numOfReferralsAssigned}"/>
			</td>
		</tr>
		<tr>
			<td>Total Number of NMDM Submissions: <c:out value="${detailReportListDTO.numOfReferrals}"/>
			</td>
		</tr>
		<tr>
			<td>Total Number of Actions From Meeting: <c:out value="${detailReportListDTO.numOfActionsFromMeeting}"/>
			</td>
		</tr>
	</table>

<br/>
<c:if test="${detailReportListDTO.numOfActionsFromMeeting gt 0}">
<h2>Actions From Meeting</h2>
<table border="1" class="report">
	<tr>
		<th>No.</th>
		<th>Meeting Date</th>
		<th>Speciality</th>
		<th>Patient Name</th>
		<th>Hospital</th>
		<th>Meeting Item Action</th>
	</tr>
	<c:forEach var="patientInMeetingDTO" items="${detailReportListDTO.meetingDTOList}" varStatus="line">
		<tr>
			<td><c:out value="${line.count}"/></td>
			<td><fmt:formatDate value="${patientInMeetingDTO.meeting.date}" pattern="dd MMM yyyy HH:mm"/></td>
			<td><webapp:listValue domain="emdt" listName="speciality" key="${patientInMeetingDTO.meeting.tumourGroup }" /></td>
			<td><c:out value="${patientInMeetingDTO.meetingItem.patientDiscussed.fullName}"/></td>
			<td><c:out value="${patientInMeetingDTO.meeting.hospital.hospitalName}"/>
			<td><c:out value="${patientInMeetingDTO.meetingItem.meetingItemAction}"/></td>
		</tr>
	</c:forEach>
</table>
<br/>
</c:if>
<h2>Totals of NMDM Submissions by hospital</h2>

<br/>
<table border="1" class="report">

	<tr>
		<th>Hospital Name</th>
		<th>Number of Incomplete NMDM Submissions</th>
		<th>Number of NMDM Submissions waiting for response</th>
		<th>Number of NMDM Submissions waiting for acknowledge</th>
		<th>Number of NMDM Submissions completed</th>
		<th>Number of NMDM Submissions Assigned</th>
		<th>Number of NMDM Submissions</th>
		<th>Number of Actions From Meeting</th>
	</tr>
	<c:forEach var="hospital" items="${detailReportListDTO.hospitals}" varStatus="line">
		<tr>
			<td>
				<c:out value="${hospital.hospitalName}"/>
			</td>
			<td>
				<c:out value="${hospital.numOfReferralsInDraft}"/>
			</td>
			<td>
				<c:out value="${hospital.numOfReferralsWaitingResp}"/>
			</td>
			<td>
				<c:out value="${hospital.numOfReferralsWaitingAck}"/>
			</td>
			<td>
				<c:out value="${hospital.numOfReferralsCompleted}"/>
			</td>
			<td>
				<c:out value="${hospital.numOfReferralsAssigned}"/>
			</td>
			<td>
				<c:out value="${hospital.numOfReferrals}"/>
			</td>
			<td>
				<c:out value="${hospital.numOfActionsFromMeeting}"/>
			</td>
		</tr>
	</c:forEach>
</table>

<br/>
<br/>

<div id="navigation"  class="navButtonBar noPrint">
	<a href="nmdmSubmissionsReport.jsp?reportType=<c:out value="${reportType}"/>" class="noPrint"><img src="../images/16x16/arrow_undo.png" />&nbsp;&nbsp;Return to previous screen</a>
	&nbsp; &nbsp; &nbsp;
	<a href="javascript:print();"><img border="0" alt="Printer icon" src="../images/16x16/printer.png"> Print</a>
	&nbsp; &nbsp; &nbsp;
</div>


</form>

</body>
</html>