Skip to content
Snippets Groups Projects
Commit 010f0b92 authored by sbobo3's avatar sbobo3
Browse files

Updated causeOfDeathTrendsReport jsp to pass field values (patient, gender,...

Updated causeOfDeathTrendsReport jsp to pass field values (patient, gender, start date, and end date) to DAO class methods. Also modified trends report table by iterating through bean object to retrieve return values from DAO.
parent 7281eda4
No related branches found
No related tags found
2 merge requests!7Uc20,!2UC20 Data Access Object Completed
...@@ -2,10 +2,11 @@ ...@@ -2,10 +2,11 @@
<%@page errorPage="/auth/exceptionHandler.jsp"%> <%@page errorPage="/auth/exceptionHandler.jsp"%>
<%@page import="edu.ncsu.csc.itrust.dao.mysql.CauseOfDeathTrendsReportDAO"%> <%@page import="edu.ncsu.csc.itrust.dao.mysql.CauseOfDeathTrendsReportDAO"%>
<%@page import="edu.ncsu.csc.itrust.beans.CauseOfDeathTrendsReportBean"%>
<%@page import="java.util.List"%> <%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%> <%@page import="java.util.ArrayList"%>
<%@page import="java.sql.Date"%>
<%@page import="java.util.Iterator"%> <%@page import="java.util.Iterator"%>
<%@page import="edu.ncsu.csc.itrust.exception.FormValidationException"%>
<%@include file="/global.jsp" %> <%@include file="/global.jsp" %>
...@@ -19,32 +20,49 @@ String view = request.getParameter("viewSelect"); ...@@ -19,32 +20,49 @@ String view = request.getParameter("viewSelect");
<%@include file="/header.jsp" %> <%@include file="/header.jsp" %>
<% <%
CauseOfDeathTrendsReportDAO report = new CauseOfDeathTrendsReportDAO(prodDAO); CauseOfDeathTrendsReportDAO report = new CauseOfDeathTrendsReportDAO(prodDAO);
ArrayList<String> allDeaths = null; List<CauseOfDeathTrendsReportBean> allDeaths = null;
//get form data //get form data
//Date startDate = Date.valueOf(request.getParameter("startDate")); long mid = Long.valueOf(request.getUserPrincipal().getName());
//Date endDate = Date.valueOf(request.getParameter("endDate"));
//String startDate = request.getParameter("startDate");
//String endDate = request.getParameter("endDate");
Date startDate = Date.valueOf("1910-09-20");
Date endDate = Date.valueOf("2020-11-04");
String gender = request.getParameter("gender"); String startDate = request.getParameter("startDate");
String endDate = request.getParameter("endDate");
allDeaths = (ArrayList) report.getTopTwoDeathsForAll(gender, startDate, endDate); String gender = request.getParameter("gender");
//if (startDate == null) String patients = request.getParameter("patients");
//startDate = ""; if (patients == null)
//if (endDate == null) patients = "";
//endDate = "";
//if (gender == null) //try to get the report. If there's an error, print it. If null is returned, it's the first page load
//gender = ""; if(patients.equalsIgnoreCase("My Patients")) {
try {
allDeaths = report.getTopTwoDeathsForHCP(mid, gender, startDate, endDate);
} catch(FormValidationException e){
e.printHTML(pageContext.getOut());
}
}
if(patients.equalsIgnoreCase("All Patients") || patients.equalsIgnoreCase("")) {
try {
allDeaths = report.getTopTwoDeathsForAll(gender, startDate, endDate);
} catch(FormValidationException e){
e.printHTML(pageContext.getOut());
}
}
if (gender == null)
gender = "";
if (startDate == null)
startDate = "";
if (endDate == null)
endDate = "";
%> %>
<br /> <br />
<form action="causeOfDeathTrendsReport.jsp" method="post" id="formMain"> <form action="causeOfDeathTrendsReport.jsp" method="post" id="formMain">
<input type="hidden" name="viewSelect" value="trends" /> <input type="hidden" name="viewSelect" />
<table class="fTable" align="center" id="causeOfDeathTrendsReportTable"> <table class="fTable" align="center" id="causeOfDeathTrendsReportTable">
<tr> <tr>
<th colspan="4">Cause of Death Trends Report</th> <th colspan="4">Cause of Death Trends Report</th>
...@@ -52,18 +70,60 @@ String view = request.getParameter("viewSelect"); ...@@ -52,18 +70,60 @@ String view = request.getParameter("viewSelect");
<tr class="subHeader"> <tr class="subHeader">
<td>Patients:</td> <td>Patients:</td>
<td> <td>
<select name="viewSelect" style="font-size:10" > <select name="patients" style="font-size:10" >
<option value=""> All Patients </option> <%
<option value=""> My Patients </option> if (patients != null && !patients.equalsIgnoreCase("")) {
if (patients.equalsIgnoreCase("All Patients")) {
%>
<option selected="selected" value="All Patients"> All Patients </option>
<option value="My Patients"> My Patients </option>
<%
} else if (patients.equalsIgnoreCase("My Patients")) {
%>
<option value="All Patients"> All Patients </option>
<option selected="selected" value="My Patients"> My Patients </option>
<%
}
} else {
%>
<option value="All Patients"> All Patients </option>
<option value="My Patients"> My Patients </option>
</select> </select>
<%
}
%>
</td> </td>
<td>Gender:</td> <td>Gender:</td>
<td> <td>
<select name="gender" style="font-size:10" > <select name="gender" style="font-size:10" >
<option value="All"> All </option> <%
if (gender != null && !gender.equalsIgnoreCase("")) {
if (gender.equalsIgnoreCase("All")) {
%>
<option selected="selected" value="All"> All </option>
<option value="Male"> Male </option> <option value="Male"> Male </option>
<option value="Female"> Female </option> <option value="Female"> Female </option>
<%
} else if(gender.equalsIgnoreCase("Male")){
%>
<option value="All"> All </option>
<option selected="selected" value="Male"> Male </option>
<option value="Female"> Female </option>
<%
} else if(gender.equalsIgnoreCase("Female")){
%>
<option value="All"> All </option>
<option value="Male"> Male </option>
<option selected="selected" value="Female"> Female </option>
<%
}
} else {
%>
<option value="All"> All </option>
<option value="Male"> Male </option>
<option value="Female"> Female </option>
</select> </select>
<% } %>
</td> </td>
</tr> </tr>
<tr class="subHeader"> <tr class="subHeader">
...@@ -89,18 +149,24 @@ String view = request.getParameter("viewSelect"); ...@@ -89,18 +149,24 @@ String view = request.getParameter("viewSelect");
<% if (allDeaths != null) { %> <% if (allDeaths != null) { %>
<table class="fTable" align="center" id="causeOfDeathTrendsTable">
<tr>
<th>ICD-9CM Name</th>
<th>ICD-9CM Code</th>
<th>Quantity of Deaths</th>
</tr>
<% <%
Iterator<String> iterator = allDeaths.iterator(); Iterator<CauseOfDeathTrendsReportBean> iterator = allDeaths.iterator();
while(iterator.hasNext()) { %> while(iterator.hasNext()) {
<table class="fTable" align="center" id="trendReport">
<tr> CauseOfDeathTrendsReportBean reports = iterator.next();
<th>Trends Report</th>
</tr>
<% String reports = iterator.next();
%> %>
<tr style="text-align:center;"> <tr style="text-align:center;">
<td><%=reports.toString()%></td> <td><%=reports.getCause()%></td>
<td><%=reports.getCode()%></td>
<td><%=reports.getDeaths()%></td>
</tr> </tr>
<% <%
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment