<%@ include file="/includes.jsp" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ page import="java.util.Date,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>Referral 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>Date Of Information</th>
			<th>Pre-treatment CT Scan</th>
			<th>Pre-treatment MRI Scan</th>
			<th>Pre-treatment PET CT Scan</th>
			<th>Post-Chemo CT Scan</th>
			<th>Post-Chemo MRI Scan</th>
			<th>Other Scan</th>
			<th>Histology</th>
			<th>General Blood Test Result</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.referralsDateOfInformation}"/></td>
			<td>&nbsp;<c:out value="${report.preCTDateOfScan}"/></td>
			<td>&nbsp;<c:out value="${report.preMRIDateOfScan}"/></td>
			<td>&nbsp;<c:out value="${report.prePETCTDateOfScan}"/></td>
			<td>&nbsp;<c:out value="${report.postChemoCTDateOfScan}"/></td>
			<td>&nbsp;<c:out value="${report.postChemoMRIDateOfScan}"/></td>
			<td>&nbsp;<c:out value="${report.otherScanDateOfScan}"/></td>
			<td>&nbsp;<c:out value="${report.dateOfReport}"/></td>
			<td>&nbsp;<c:out value="${report.dateOfDocument}"/></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 referrals waiting for response: <c:out value="${detailReportListDTO.numOfReferralsWaitingResp}"/>
			</td>
			<td rowspan="3" align="right">
				
			</td>
		</tr>
		<tr>
		<td>Total Number of referrals waiting for acknowledgement: <c:out value="${detailReportListDTO.numOfReferralsWaitingAck}"/></td>
		</tr>
		<tr>
			<td>Total Number of referrals completed: <c:out value="${detailReportListDTO.numOfReferralsCompleted}"/>
			</td>
		</tr>
		<tr>
			<td>Total Number of referrals: <c:out value="${detailReportListDTO.numOfReferrals}"/>
			</td>
		</tr>
				<tr>
			<td>Maximum time for referral: <c:out value="${maxTimeTakenForReferral}"/> days
			</td>
		</tr>
		
	</table>

<br/>
<h2>Totals of referrals by hospital</h2>

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

	<tr>
		<th>Hospital Name</th>
		<th>Number of referrals waiting for response</th>
		<th>Number of referrals waiting for acknowledge</th>
		<th>Number of referrals completed</th>
		<th>Number of referrals</th>
	</tr>
	<c:forEach var="hospital" items="${detailReportListDTO.hospitals}" varStatus="line">
		<tr>
			<td>
				<c:out value="${hospital.hospitalName}"/>
			</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.numOfReferrals}"/>
			</td>
			
		</tr>
	</c:forEach>
</table>

<br/>
<br/>

<div id="navigation"  class="navButtonBar noPrint">
	
	<%String str1 = (String)request.getAttribute("module");%>
	<c:set var="str" value="<%=str1%>"/>

	<c:choose>
		<c:when test="${str eq 'referral'}">
			<img src="../images/16x16/arrow_undo.png" />&nbsp;Back to: <a href="../referrals/referralsReportMenu.jsp">Reports main menu</a> &nbsp; &gt; &nbsp;<a href="../referrals/referralsDetailedReport.jsp" class="noPrint"> This report settings</a>
		</c:when>
		<c:otherwise>
			<a href="../emdt/referralsDetailReport.jsp" class="noPrint"><img src="../images/16x16/arrow_undo.png" />&nbsp;&nbsp;Return to previous screen</a>
		</c:otherwise>
	</c:choose>

	&nbsp; &nbsp; &nbsp;
	
	<a href="javascript:print();"><img border="0" alt="Printer icon" src="../images/16x16/printer.png"> Print</a>

	&nbsp; &nbsp; &nbsp;
	

	<c:choose>
		<c:when test="${detailReportListDTO.detailReportList ne null and fn:length(detailReportListDTO.detailReportList) ne 0}">
			<a href="#"  onClick="downloadCSV();" title="Download as CSV"><img src="../images/16x16/page_excel.png" /> Download as CSV</a>
		</c:when>
	</c:choose>

</div>


</form>

</body>
</html>