Skip to content
Snippets Groups Projects
Commit 9c652e5e authored by htmoss2's avatar htmoss2
Browse files

Merge branch 'UC20' into 'master'

Uc20

See merge request !7
parents fadf979b 668b23fd
No related branches found
No related tags found
1 merge request!7Uc20
Showing
with 1176 additions and 3 deletions
<%@taglib uri="/WEB-INF/tags.tld" prefix="itrust"%>
<%@page errorPage="/auth/exceptionHandler.jsp"%>
<%@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.ArrayList"%>
<%@page import="java.util.Iterator"%>
<%@page import="edu.ncsu.csc.itrust.exception.FormValidationException"%>
<%@include file="/global.jsp" %>
<%
pageTitle = "iTrust - View Cause-Of-Death Trends Report";
String view = request.getParameter("viewSelect");
%>
<%@include file="/header.jsp" %>
<%
//log the page view
loggingAction.logEvent(TransactionType.DEATH_TRENDS_VIEW, loggedInMID.longValue(), 0, "View cause-of-death trends report");
CauseOfDeathTrendsReportDAO report = new CauseOfDeathTrendsReportDAO(prodDAO);
List<CauseOfDeathTrendsReportBean> allDeaths = null;
//get form data
long mid = Long.valueOf(request.getUserPrincipal().getName());
String startDate = request.getParameter("startDate");
String endDate = request.getParameter("endDate");
String gender = request.getParameter("gender");
String patients = request.getParameter("patients");
if (patients == null)
patients = "";
//try to get the report. If there's an error, print it. If null is returned, it's the first page load
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 />
<form action="causeOfDeathTrendsReport.jsp" method="post" id="formMain">
<input type="hidden" name="viewSelect" />
<table class="fTable" align="center" id="causeOfDeathTrendsReportTable">
<tr>
<th colspan="4">Cause of Death Trends Report</th>
</tr>
<tr class="subHeader">
<td>Patients:</td>
<td>
<select name="patients" style="font-size:10" >
<%
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>
<%
}
%>
</td>
<td>Gender:</td>
<td>
<select name="gender" style="font-size:10" >
<%
if (gender != null && !gender.equalsIgnoreCase("")) {
if (gender.equalsIgnoreCase("All")) {
%>
<option selected="selected" value="All"> All </option>
<option value="Male"> Male </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>
<% } %>
</td>
</tr>
<tr class="subHeader">
<td>Start Date:</td>
<td>
<input name="startDate" value="<%= StringEscapeUtils.escapeHtml("" + (startDate)) %>" size="10">
<input type=button value="Select Date" onclick="displayDatePicker('startDate');">
</td>
<td>End Date:</td>
<td>
<input name="endDate" value="<%= StringEscapeUtils.escapeHtml("" + (endDate)) %>" size="10">
<input type=button value="Select Date" onclick="displayDatePicker('endDate');">
</td>
</tr>
<tr>
<td colspan="4" style="text-align: center;"><input type="submit" id="view_report" value="View Report"></td>
</tr>
</table>
</form>
<br />
<% 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<CauseOfDeathTrendsReportBean> iterator = allDeaths.iterator();
while(iterator.hasNext()) {
CauseOfDeathTrendsReportBean reports = iterator.next();
%>
<tr style="text-align:center;">
<td><%=reports.getCause()%></td>
<td><%=reports.getCode()%></td>
<td><%=reports.getDeaths()%></td>
</tr>
<%
}
%>
</table>
<% } %>
<br />
<%@include file="/footer.jsp" %>
\ No newline at end of file
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
<li><a href="/iTrust/auth/hcp-nutritionist/macronutrients.jsp">Patient Macronutrient Intake</a> <li><a href="/iTrust/auth/hcp-nutritionist/macronutrients.jsp">Patient Macronutrient Intake</a>
<li><a href="/iTrust/auth/hcp-fitness/viewExerciseDiaries.jsp">Patient Exercise Diaries</a> <li><a href="/iTrust/auth/hcp-fitness/viewExerciseDiaries.jsp">Patient Exercise Diaries</a>
<li><a href="/iTrust/auth/hcp/viewSleepDiaries.jsp">Patient Sleep Diaries</a> <li><a href="/iTrust/auth/hcp/viewSleepDiaries.jsp">Patient Sleep Diaries</a>
<li><a href="/iTrust/auth/hcp/causeOfDeathTrendsReport.jsp">Cause-Of-Death Trends Report</a>
</ul> </ul>
</div> </div>
</div> </div>
......
DELETE FROM users WHERE MID = 81;
DELETE FROM officevisits WHERE PatientID = 81;
DELETE FROM patients WHERE MID = 81;
INSERT INTO users(MID, password, role, sQuestion, sAnswer)
VALUES (81, '30c952fab122c3f9759f02a6d95c3758b246b4fee239957b2d4fee46e26170c4', 'patient', 'what is your favorite color?', 'blue')
ON DUPLICATE KEY UPDATE MID = MID;
INSERT INTO patients (MID, Gender, DateOfDeath, CauseOfDeath)
VALUES (81,'Male','2019-07-01',84.50)
ON DUPLICATE KEY UPDATE MID = MID;
INSERT INTO officevisits(id,visitDate,HCPID,notes,HospitalID,PatientID)
VALUES (20771,'2019-07-01',9000000000,'died','1',81)
ON DUPLICATE KEY UPDATE id = id;
\ No newline at end of file
DELETE FROM users WHERE MID = 90;
DELETE FROM officevisits WHERE PatientID = 90;
DELETE FROM patients WHERE MID = 90;
INSERT INTO users(MID, password, role, sQuestion, sAnswer)
VALUES (90, '30c952fab122c3f9759f02a6d95c3758b246b4fee239957b2d4fee46e26170c4', 'patient', 'what is your favorite color?', 'blue')
ON DUPLICATE KEY UPDATE MID = MID;
INSERT INTO patients (MID, Gender, DateOfDeath, CauseOfDeath)
VALUES (90,'Male','2019-01-01',487.00)
ON DUPLICATE KEY UPDATE MID = MID;
INSERT INTO officevisits(id,visitDate,HCPID,notes,HospitalID,PatientID)
VALUES (20780,'2019-01-01',9000000003,'died','1',90)
ON DUPLICATE KEY UPDATE id = id;
\ No newline at end of file
DELETE FROM users WHERE MID = 82;
DELETE FROM officevisits WHERE PatientID = 82;
DELETE FROM patients WHERE MID = 82;
INSERT INTO users(MID, password, role, sQuestion, sAnswer)
VALUES (82, '30c952fab122c3f9759f02a6d95c3758b246b4fee239957b2d4fee46e26170c4', 'patient', 'what is your favorite color?', 'blue')
ON DUPLICATE KEY UPDATE MID = MID;
INSERT INTO patients (MID, Gender, DateOfDeath, CauseOfDeath)
VALUES (82,'Male','2018-07-01',11.40)
ON DUPLICATE KEY UPDATE MID = MID;
INSERT INTO officevisits(id,visitDate,HCPID,notes,HospitalID,PatientID)
VALUES (20772,'2018-07-01',9000000000,'died','1',82)
ON DUPLICATE KEY UPDATE id = id;
\ No newline at end of file
DELETE FROM users WHERE MID = 83;
DELETE FROM officevisits WHERE PatientID = 83;
DELETE FROM patients WHERE MID = 83;
INSERT INTO users(MID, password, role, sQuestion, sAnswer)
VALUES (83, '30c952fab122c3f9759f02a6d95c3758b246b4fee239957b2d4fee46e26170c4', 'patient', 'what is your favorite color?', 'blue')
ON DUPLICATE KEY UPDATE MID = MID;
INSERT INTO patients (MID, Gender, DateOfDeath, CauseOfDeath)
VALUES (83,'Female','2018-07-01',11.40)
ON DUPLICATE KEY UPDATE MID = MID;
INSERT INTO officevisits(id,visitDate,HCPID,notes,HospitalID,PatientID)
VALUES (20773,'2018-07-01',9000000000,'died','1',83)
ON DUPLICATE KEY UPDATE id = id;
\ No newline at end of file
DELETE FROM users WHERE MID = 84;
DELETE FROM officevisits WHERE PatientID = 84;
DELETE FROM patients WHERE MID = 84;
INSERT INTO users(MID, password, role, sQuestion, sAnswer)
VALUES (84, '30c952fab122c3f9759f02a6d95c3758b246b4fee239957b2d4fee46e26170c4', 'patient', 'what is your favorite color?', 'blue')
ON DUPLICATE KEY UPDATE MID = MID;
INSERT INTO patients (MID, Gender, DateOfDeath, CauseOfDeath)
VALUES (84,'Male','2018-12-01',11.40)
ON DUPLICATE KEY UPDATE MID = MID;
INSERT INTO officevisits(id,visitDate,HCPID,notes,HospitalID,PatientID)
VALUES (20774,'2018-12-01',9000000000,'died','1',84)
ON DUPLICATE KEY UPDATE id = id;
\ No newline at end of file
DELETE FROM users WHERE MID = 85;
DELETE FROM officevisits WHERE PatientID = 85;
DELETE FROM patients WHERE MID = 85;
INSERT INTO users(MID, password, role, sQuestion, sAnswer)
VALUES (85, '30c952fab122c3f9759f02a6d95c3758b246b4fee239957b2d4fee46e26170c4', 'patient', 'what is your favorite color?', 'blue')
ON DUPLICATE KEY UPDATE MID = MID;
INSERT INTO patients (MID, Gender, DateOfDeath, CauseOfDeath)
VALUES (85,'Male','2020-01-01',84.50)
ON DUPLICATE KEY UPDATE MID = MID;
INSERT INTO officevisits(id,visitDate,HCPID,notes,HospitalID,PatientID)
VALUES (20775,'2020-01-01',9000000000,'died','1',85)
ON DUPLICATE KEY UPDATE id = id;
\ No newline at end of file
DELETE FROM users WHERE MID = 86;
DELETE FROM officevisits WHERE PatientID = 86;
DELETE FROM patients WHERE MID = 86;
INSERT INTO users(MID, password, role, sQuestion, sAnswer)
VALUES (86, '30c952fab122c3f9759f02a6d95c3758b246b4fee239957b2d4fee46e26170c4', 'patient', 'what is your favorite color?', 'blue')
ON DUPLICATE KEY UPDATE MID = MID;
INSERT INTO patients (MID, Gender, DateOfDeath, CauseOfDeath)
VALUES (86,'Male','2018-12-01',487.00)
ON DUPLICATE KEY UPDATE MID = MID;
INSERT INTO officevisits(id,visitDate,HCPID,notes,HospitalID,PatientID)
VALUES (20776,'2018-12-01',9000000000,'died','1',86)
ON DUPLICATE KEY UPDATE id = id;
\ No newline at end of file
DELETE FROM users WHERE MID = 87;
DELETE FROM officevisits WHERE PatientID = 87;
DELETE FROM patients WHERE MID = 87;
INSERT INTO users(MID, password, role, sQuestion, sAnswer)
VALUES (87, '30c952fab122c3f9759f02a6d95c3758b246b4fee239957b2d4fee46e26170c4', 'patient', 'what is your favorite color?', 'blue')
ON DUPLICATE KEY UPDATE MID = MID;
INSERT INTO patients (MID, Gender, DateOfDeath, CauseOfDeath)
VALUES (87,'Female','2019-12-01',487.00)
ON DUPLICATE KEY UPDATE MID = MID;
INSERT INTO officevisits(id,visitDate,HCPID,notes,HospitalID,PatientID)
VALUES (20777,'2019-12-01',9000000003,'died','1',87)
ON DUPLICATE KEY UPDATE id = id;
DELETE FROM users WHERE MID = 88;
DELETE FROM officevisits WHERE PatientID = 88;
DELETE FROM patients WHERE MID = 88;
INSERT INTO users(MID, password, role, sQuestion, sAnswer)
VALUES (88, '30c952fab122c3f9759f02a6d95c3758b246b4fee239957b2d4fee46e26170c4', 'patient', 'what is your favorite color?', 'blue')
ON DUPLICATE KEY UPDATE MID = MID;
INSERT INTO patients (MID, Gender, DateOfDeath, CauseOfDeath)
VALUES (88,'Female','2020-07-01',487.00)
ON DUPLICATE KEY UPDATE MID = MID;
INSERT INTO officevisits(id,visitDate,HCPID,notes,HospitalID,PatientID)
VALUES (20778,'2020-07-01',9000000003,'died','1',88)
ON DUPLICATE KEY UPDATE id = id;
\ No newline at end of file
DELETE FROM users WHERE MID = 89;
DELETE FROM officevisits WHERE PatientID = 89;
DELETE FROM patients WHERE MID = 89;
INSERT INTO users(MID, password, role, sQuestion, sAnswer)
VALUES (89, '30c952fab122c3f9759f02a6d95c3758b246b4fee239957b2d4fee46e26170c4', 'patient', 'what is your favorite color?', 'blue')
ON DUPLICATE KEY UPDATE MID = MID;
INSERT INTO patients (MID, Gender, DateOfDeath, CauseOfDeath)
VALUES (89,'Male','2020-01-01',487.00)
ON DUPLICATE KEY UPDATE MID = MID;
INSERT INTO officevisits(id,visitDate,HCPID,notes,HospitalID,PatientID)
VALUES (20779,'2020-01-01',9000000003,'died','1',89)
ON DUPLICATE KEY UPDATE id = id;
\ No newline at end of file
package edu.ncsu.csc.itrust.beans;
public class CauseOfDeathTrendsReportBean {
/** The name of the diagnosis cause of death */
String cause;
/** The code of the diagnosis cause of death */
String code;
/** The quantity of the deaths */
String deaths;
/**
* Constructor for an empty bean
*/
public CauseOfDeathTrendsReportBean() {
}
/**
* Constructor for the bean. Accepts cause of death name, cause of death code, and quantity of deaths
* @param cause The cause of death name
* @param code The cause of death code
* @param deaths The quantity of deaths for the chosen death code
*/
public CauseOfDeathTrendsReportBean(String cause, String code, String deaths) {
this.cause = cause;
this.code = code;
this.deaths = deaths;
}
/**
* Getter for cause of death name
* @return The stored cause of death name
*/
public String getCause() {
return cause;
}
/**
* Setter for cause of death name
* @param cause The cause of death name to be stored
*/
public void setCause(String cause) {
this.cause = cause;
}
/**
* Getter for cause of death code
* @return The stored cause of death code
*/
public String getCode() {
return code;
}
/**
* Setter for cause of death name
* @param code The cause of death name to be stored
*/
public void setCode(String code) {
this.code = code;
}
/**
* Getter for quantity of deaths
* @return The stored quantity of deaths
*/
public String getDeaths() {
return deaths;
}
/**
* Setter for quantity of deaths
* @param deaths The stored quantity of deaths
*/
public void setDeaths(String deaths) {
this.deaths = deaths;
}
}
...@@ -499,4 +499,4 @@ public class PatientBean implements Serializable, Comparable<PatientBean> { ...@@ -499,4 +499,4 @@ public class PatientBean implements Serializable, Comparable<PatientBean> {
return 42; // any arbitrary constant will do return 42; // any arbitrary constant will do
} }
} }
\ No newline at end of file
package edu.ncsu.csc.itrust.dao.mysql;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Date;
import java.time.format.DateTimeFormatter;
import java.time.LocalDate;
import java.util.List;
import java.util.ArrayList;
import edu.ncsu.csc.itrust.DBUtil;
import edu.ncsu.csc.itrust.beans.CauseOfDeathTrendsReportBean;
import edu.ncsu.csc.itrust.dao.DAOFactory;
import edu.ncsu.csc.itrust.exception.DBException;
import edu.ncsu.csc.itrust.exception.FormValidationException;
import edu.ncsu.csc.itrust.exception.ITrustException;
import java.time.format.DateTimeParseException;
public class CauseOfDeathTrendsReportDAO {
private DAOFactory factory;
/**
* The typical constructor.
* @param factory The {@link DAOFactory} associated with this DAO, which is used for obtaining SQL connections, etc.
*/
public CauseOfDeathTrendsReportDAO(DAOFactory factory) {
this.factory = factory;
}
/**
* Returns a list of patients for a particular HCP
*
* @param hcpMID The MID of the HCP to look up.
* @return A java.util.List of PatientsForHCP.
* @throws DBException
*/
public List<Long> getPatientsForHCP(long hcpMID) throws DBException {
Connection conn = null;
PreparedStatement stmt = null;
List<Long> patients = new ArrayList<Long>();
try {
conn = factory.getConnection();
stmt = conn.prepareStatement("SELECT DISTINCT PatientID FROM officevisits WHERE HCPID = ?");
stmt.setLong(1, hcpMID);
ResultSet rs = stmt.executeQuery();
while(rs.next()) {
Long patient = rs.getLong("PatientID");
patients.add(patient);
}
rs.close();
} catch (SQLException e) {
throw new DBException(e);
} finally {
DBUtil.closeConnection(conn, stmt);
}
return patients;
}
/**
* Returns a list of the top two causes of deaths for a particular HCP
*
* @param hcpMID The MID of the HCP to look up.
* @param gender Gender of the patients - All, Female, Male
* @param startingDate Start date of search.
* @param endingDate End date of search.
* @return A java.util.List of TopTwoDeathsForHCP.
* @throws DBException
*/
public ArrayList<CauseOfDeathTrendsReportBean> getTopTwoDeathsForHCP(long hcpMID, String gender, String startingDate, String endingDate) throws FormValidationException, ITrustException {
Connection conn = null;
PreparedStatement stmt = null;
List<Long> patients = this.getPatientsForHCP(hcpMID);
ArrayList<CauseOfDeathTrendsReportBean> causes;
String query = null;
java.sql.Date startDate;
java.sql.Date endDate;
try {
if (startingDate == null || endingDate == null)
return null;
causes = new ArrayList<>();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
DateTimeFormatter formatter2 = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String lower = LocalDate.parse(startingDate, formatter).format(formatter2);
String upper = LocalDate.parse(endingDate, formatter).format(formatter2);
startDate = Date.valueOf(lower);
endDate = Date.valueOf(upper);
if (startDate.after(endDate))
throw new FormValidationException("Start date must be before end date!");
conn = factory.getConnection();
if(gender.equalsIgnoreCase("All")){
query = "SELECT DISTINCT CauseOfDeath, COUNT(CauseOfDeath) FROM patients WHERE MID IN (";
for(int i = 0; i < patients.size(); i++)
{
if (i+1 == patients.size()){
query += patients.get(i);
}
else{
query += patients.get(i) + ",";
}
}
query += ") AND DateOfDeath IS NOT NULL AND YEAR(DateOfDeath) >= YEAR(?) AND YEAR(DateOfDeath) <= YEAR(?)"
+ "GROUP BY CauseOfDeath ORDER BY COUNT(CauseOfDeath) DESC";
stmt = conn.prepareStatement(query);
stmt.setDate(1, startDate);
stmt.setDate(2, endDate);
}
else{
query = "SELECT DISTINCT CauseOfDeath, COUNT(CauseOfDeath) FROM patients WHERE MID IN (";
for(int i = 0; i < patients.size(); i++)
{
if (i+1 == patients.size()){
query += patients.get(i);
}
else{
query += patients.get(i) + ",";
}
}
query += ") AND DateOfDeath IS NOT NULL AND Gender = ? AND YEAR(DateOfDeath) >= YEAR(?) AND YEAR(DateOfDeath) <= YEAR(?)"
+ "GROUP BY CauseOfDeath ORDER BY COUNT(CauseOfDeath) DESC";
stmt = conn.prepareStatement(query);
stmt.setString(1, gender);
stmt.setDate(2, startDate);
stmt.setDate(3, endDate);
}
ResultSet rs = stmt.executeQuery();
int count = 0;
while(rs.next() && count < 2) {
String cause = rs.getString("CauseOfDeath");
String deaths = rs.getString("COUNT(CauseOfDeath)");
String name = this.getCodeName(cause);
causes.add(new CauseOfDeathTrendsReportBean(name, cause, deaths));
count++;
}
if (causes.isEmpty())
throw new FormValidationException("No results returned");
rs.close();
stmt.close();
} catch (SQLException e) {
throw new DBException(e);
} catch (DateTimeParseException e) {
throw new FormValidationException("Enter dates in MM/dd/yyyy");
} finally {
DBUtil.closeConnection(conn, stmt);
}
return causes;
}
/**
* Returns a list of the top two causes of deaths for a all HCPs
*
* @param gender Gender of the patients - All, Female, Male
* @param startingDate Start date of search.
* @param endingDate End date of search.
* @return A java.util.List of TopTwoDeathsForAll.
* @throws DBException
*/
public ArrayList<CauseOfDeathTrendsReportBean> getTopTwoDeathsForAll(String gender, String startingDate, String endingDate) throws FormValidationException, ITrustException {
Connection conn = null;
PreparedStatement stmt = null;
ArrayList<CauseOfDeathTrendsReportBean> causes;
String query = null;
java.sql.Date startDate;
java.sql.Date endDate;
try {
if (startingDate == null || endingDate == null)
return null;
causes = new ArrayList<>();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
DateTimeFormatter formatter2 = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String lower = LocalDate.parse(startingDate, formatter).format(formatter2);
String upper = LocalDate.parse(endingDate, formatter).format(formatter2);
startDate = Date.valueOf(lower);
endDate = Date.valueOf(upper);
if (startDate.after(endDate))
throw new FormValidationException("Start date must be before end date!");
conn = factory.getConnection();
if(gender.equalsIgnoreCase("All")){
query = "SELECT DISTINCT CauseOfDeath, COUNT(CauseOfDeath) FROM patients"
+ " WHERE DateOfDeath IS NOT NULL AND YEAR(DateOfDeath) >= YEAR(?) AND YEAR(DateOfDeath) <= YEAR(?)"
+ "GROUP BY CauseOfDeath ORDER BY COUNT(CauseOfDeath) DESC";
stmt = conn.prepareStatement(query);
stmt.setDate(1, startDate);
stmt.setDate(2, endDate);
}
else{
query = "SELECT DISTINCT CauseOfDeath, COUNT(CauseOfDeath) FROM patients"
+ " WHERE DateOfDeath IS NOT NULL AND Gender = ? AND YEAR(DateOfDeath) >= YEAR(?) AND YEAR(DateOfDeath) <= YEAR(?)"
+ "GROUP BY CauseOfDeath ORDER BY COUNT(CauseOfDeath) DESC";
stmt = conn.prepareStatement(query);
stmt.setString(1, gender);
stmt.setDate(2, startDate);
stmt.setDate(3, endDate);
}
ResultSet rs = stmt.executeQuery();
int count = 0;
while(rs.next() && count < 2) {
String cause = rs.getString("CauseOfDeath");
String deaths = rs.getString("COUNT(CauseOfDeath)");
String name = this.getCodeName(cause);
causes.add(new CauseOfDeathTrendsReportBean(name, cause, deaths));
count++;
}
if (causes.isEmpty())
throw new FormValidationException("No results returned");
rs.close();
stmt.close();
} catch (SQLException e) {
throw new DBException(e);
} catch (DateTimeParseException e) {
throw new FormValidationException("Enter dates in MM/dd/yyyy");
} finally {
DBUtil.closeConnection(conn, stmt);
}
return causes;
}
/**
* Returns the code name for a particular ICD-9CM code.
*
* @param code ICD-9CM code.
* @return the name of the ICD-9CM code.
* @throws DBException
*/
public String getCodeName(String code) throws DBException {
Connection conn = null;
PreparedStatement stmt = null;
String result = null;
try {
conn = factory.getConnection();
stmt = conn.prepareStatement("SELECT Description FROM icdcodes WHERE Code = ?");
stmt.setString(1, code);
ResultSet rs = stmt.executeQuery();
if(rs.next()){
result = rs.getString("Description");
rs.close();
stmt.close();
}
else{
rs.close();
stmt.close();
return null;
}
} catch (SQLException e) {
throw new DBException(e);
} finally {
DBUtil.closeConnection(conn, stmt);
}
return result;
}
}
package edu.ncsu.csc.itrust.selenium;
import edu.ncsu.csc.itrust.enums.TransactionType;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.openqa.selenium.support.ui.Select;
public class CauseOfDeathTrendsReportSeleniumTest extends iTrustSeleniumTest {
private HtmlUnitDriver driver;
@Override
protected void setUp() throws Exception {
super.setUp();
gen.clearAllTables();
gen.standardData();
}
public void testViewCODTrendsReports_AllPatientsAllGenders() throws Exception {
driver = (HtmlUnitDriver)login("9000000000", "pw");
// Click Diagnosis Trends
driver.findElement(By.cssSelector("h2.panel-title")).click();
driver.findElement(By.xpath("//div[@class='panel-body']/ul/li[11]")).click();
driver.findElement(By.linkText("Cause-Of-Death Trends Report")).click();
// View Cause of Death Trends Report
assertTrue(driver.getCurrentUrl().equals(ADDRESS + "auth/hcp/causeOfDeathTrendsReport.jsp"));
driver.findElement(By.name("startDate")).clear();
driver.findElement(By.name("startDate")).sendKeys("01/01/2000");
driver.findElement(By.name("endDate")).sendKeys("12/31/2020");
driver.findElement(By.id("view_report")).click();
assertTrue(driver.getCurrentUrl().equals(ADDRESS + "auth/hcp/causeOfDeathTrendsReport.jsp"));
assertLogged(TransactionType.DEATH_TRENDS_VIEW, 9000000000L, 0L,
"View cause-of-death trends report");
WebElement table = driver.findElement(By.id("causeOfDeathTrendsTable"));
String cause1 = table.findElements(By.tagName("td")).get(0).getText();
double code1 = Double.parseDouble(table.findElements(By.tagName("td")).get(1).getText());
int deaths1 = Integer.parseInt(table.findElements(By.tagName("td")).get(2).getText());
assertEquals(cause1, "Influenza");
assertEquals(code1, 487.00);
assertEquals(deaths1, 5);
String cause2 = table.findElements(By.tagName("td")).get(3).getText();
double code2 = Double.parseDouble(table.findElements(By.tagName("td")).get(4).getText());
int deaths2 = Integer.parseInt(table.findElements(By.tagName("td")).get(5).getText());
assertEquals(cause2, "Tuberculosis of the lung");
assertEquals(code2, 11.40);
assertEquals(deaths2, 3);
}
public void testViewCODTrendsReports_AllPatientsOnlyMale() throws Exception {
driver = (HtmlUnitDriver)login("9000000000", "pw");
// Click Diagnosis Trends
driver.findElement(By.cssSelector("h2.panel-title")).click();
driver.findElement(By.xpath("//div[@class='panel-body']/ul/li[11]")).click();
driver.findElement(By.linkText("Cause-Of-Death Trends Report")).click();
// View Cause of Death Trends Report
assertTrue(driver.getCurrentUrl().equals(ADDRESS + "auth/hcp/causeOfDeathTrendsReport.jsp"));
new Select(driver.findElement(By.name("gender"))).selectByVisibleText("Male");
driver.findElement(By.name("startDate")).clear();
driver.findElement(By.name("startDate")).sendKeys("01/01/2000");
driver.findElement(By.name("endDate")).sendKeys("12/31/2020");
driver.findElement(By.id("view_report")).click();
assertTrue(driver.getCurrentUrl().equals(ADDRESS + "auth/hcp/causeOfDeathTrendsReport.jsp"));
assertLogged(TransactionType.DEATH_TRENDS_VIEW, 9000000000L, 0L,
"View cause-of-death trends report");
WebElement table = driver.findElement(By.id("causeOfDeathTrendsTable"));
String cause1 = table.findElements(By.tagName("td")).get(0).getText();
double code1 = Double.parseDouble(table.findElements(By.tagName("td")).get(1).getText());
int deaths1 = Integer.parseInt(table.findElements(By.tagName("td")).get(2).getText());
assertEquals(cause1, "Influenza");
assertEquals(code1, 487.00);
assertEquals(deaths1, 3);
String cause2 = table.findElements(By.tagName("td")).get(3).getText();
double code2 = Double.parseDouble(table.findElements(By.tagName("td")).get(4).getText());
int deaths2 = Integer.parseInt(table.findElements(By.tagName("td")).get(5).getText());
assertEquals(cause2, "Malaria");
assertEquals(code2, 84.50);
assertEquals(deaths2, 2);
}
public void testViewCODTrendsReports_AllPatientsOnlyFemale() throws Exception {
driver = (HtmlUnitDriver)login("9000000003", "pw");
// Click Diagnosis Trends
driver.findElement(By.cssSelector("h2.panel-title")).click();
driver.findElement(By.xpath("//div[@class='panel-body']/ul/li[11]")).click();
driver.findElement(By.linkText("Cause-Of-Death Trends Report")).click();
// View Cause of Death Trends Report
assertTrue(driver.getCurrentUrl().equals(ADDRESS + "auth/hcp/causeOfDeathTrendsReport.jsp"));
new Select(driver.findElement(By.name("gender"))).selectByVisibleText("Female");
driver.findElement(By.name("startDate")).clear();
driver.findElement(By.name("startDate")).sendKeys("01/01/2000");
driver.findElement(By.name("endDate")).sendKeys("12/31/2020");
driver.findElement(By.id("view_report")).click();
assertTrue(driver.getCurrentUrl().equals(ADDRESS + "auth/hcp/causeOfDeathTrendsReport.jsp"));
assertLogged(TransactionType.DEATH_TRENDS_VIEW, 9000000003L, 0L,
"View cause-of-death trends report");
WebElement table = driver.findElement(By.id("causeOfDeathTrendsTable"));
String cause1 = table.findElements(By.tagName("td")).get(0).getText();
double code1 = Double.parseDouble(table.findElements(By.tagName("td")).get(1).getText());
int deaths1 = Integer.parseInt(table.findElements(By.tagName("td")).get(2).getText());
assertEquals(cause1, "Influenza");
assertEquals(code1, 487.00);
assertEquals(deaths1, 2);
String cause2 = table.findElements(By.tagName("td")).get(3).getText();
double code2 = Double.parseDouble(table.findElements(By.tagName("td")).get(4).getText());
int deaths2 = Integer.parseInt(table.findElements(By.tagName("td")).get(5).getText());
assertEquals(cause2, "Tuberculosis of the lung");
assertEquals(code2, 11.40);
assertEquals(deaths2, 1);
}
public void testViewCODTrendsReports_MyPatientsAllGenders() throws Exception {
driver = (HtmlUnitDriver)login("9000000003", "pw");
// Click Diagnosis Trends
driver.findElement(By.cssSelector("h2.panel-title")).click();
driver.findElement(By.xpath("//div[@class='panel-body']/ul/li[11]")).click();
driver.findElement(By.linkText("Cause-Of-Death Trends Report")).click();
// View Cause of Death Trends Report
assertTrue(driver.getCurrentUrl().equals(ADDRESS + "auth/hcp/causeOfDeathTrendsReport.jsp"));
new Select(driver.findElement(By.name("patients"))).selectByVisibleText("My Patients");
driver.findElement(By.name("startDate")).clear();
driver.findElement(By.name("startDate")).sendKeys("01/01/2000");
driver.findElement(By.name("endDate")).sendKeys("12/31/2020");
driver.findElement(By.id("view_report")).click();
assertTrue(driver.getCurrentUrl().equals(ADDRESS + "auth/hcp/causeOfDeathTrendsReport.jsp"));
assertLogged(TransactionType.DEATH_TRENDS_VIEW, 9000000003L, 0L,
"View cause-of-death trends report");
WebElement table = driver.findElement(By.id("causeOfDeathTrendsTable"));
String cause1 = table.findElements(By.tagName("td")).get(0).getText();
double code1 = Double.parseDouble(table.findElements(By.tagName("td")).get(1).getText());
int deaths1 = Integer.parseInt(table.findElements(By.tagName("td")).get(2).getText());
assertEquals(cause1, "Influenza");
assertEquals(code1, 487.00);
assertEquals(deaths1, 4);
String cause2 = table.findElements(By.tagName("td")).get(3).getText();
double code2 = Double.parseDouble(table.findElements(By.tagName("td")).get(4).getText());
int deaths2 = Integer.parseInt(table.findElements(By.tagName("td")).get(5).getText());
assertEquals(cause2, "Diabetes with ketoacidosis");
assertEquals(code2, 250.10);
assertEquals(deaths2, 1);
}
public void testViewCODTrendsReports_MyPatientsOnlyMale() throws Exception {
driver = (HtmlUnitDriver)login("9000000003", "pw");
// Click Diagnosis Trends
driver.findElement(By.cssSelector("h2.panel-title")).click();
driver.findElement(By.xpath("//div[@class='panel-body']/ul/li[11]")).click();
driver.findElement(By.linkText("Cause-Of-Death Trends Report")).click();
// View Cause of Death Trends Report
assertTrue(driver.getCurrentUrl().equals(ADDRESS + "auth/hcp/causeOfDeathTrendsReport.jsp"));
new Select(driver.findElement(By.name("patients"))).selectByVisibleText("My Patients");
new Select(driver.findElement(By.name("gender"))).selectByVisibleText("Male");
driver.findElement(By.name("startDate")).clear();
driver.findElement(By.name("startDate")).sendKeys("01/01/2000");
driver.findElement(By.name("endDate")).sendKeys("12/31/2020");
driver.findElement(By.id("view_report")).click();
assertTrue(driver.getCurrentUrl().equals(ADDRESS + "auth/hcp/causeOfDeathTrendsReport.jsp"));
assertLogged(TransactionType.DEATH_TRENDS_VIEW, 9000000003L, 0L,
"View cause-of-death trends report");
WebElement table = driver.findElement(By.id("causeOfDeathTrendsTable"));
String cause1 = table.findElements(By.tagName("td")).get(0).getText();
double code1 = Double.parseDouble(table.findElements(By.tagName("td")).get(1).getText());
int deaths1 = Integer.parseInt(table.findElements(By.tagName("td")).get(2).getText());
assertEquals(cause1, "Influenza");
assertEquals(code1, 487.00);
assertEquals(deaths1, 2);
String cause2 = table.findElements(By.tagName("td")).get(3).getText();
double code2 = Double.parseDouble(table.findElements(By.tagName("td")).get(4).getText());
int deaths2 = Integer.parseInt(table.findElements(By.tagName("td")).get(5).getText());
assertEquals(cause2, "Diabetes with ketoacidosis");
assertEquals(code2, 250.10);
assertEquals(deaths2, 1);
}
public void testViewCODTrendsReports_MyPatientsOnlyFemale() throws Exception {
driver = (HtmlUnitDriver)login("9000000003", "pw");
// Click Diagnosis Trends
driver.findElement(By.cssSelector("h2.panel-title")).click();
driver.findElement(By.xpath("//div[@class='panel-body']/ul/li[11]")).click();
driver.findElement(By.linkText("Cause-Of-Death Trends Report")).click();
// View Cause of Death Trends Report
assertTrue(driver.getCurrentUrl().equals(ADDRESS + "auth/hcp/causeOfDeathTrendsReport.jsp"));
new Select(driver.findElement(By.name("patients"))).selectByVisibleText("My Patients");
new Select(driver.findElement(By.name("gender"))).selectByVisibleText("Female");
driver.findElement(By.name("startDate")).clear();
driver.findElement(By.name("startDate")).sendKeys("01/01/2000");
driver.findElement(By.name("endDate")).sendKeys("12/31/2020");
driver.findElement(By.id("view_report")).click();
assertTrue(driver.getCurrentUrl().equals(ADDRESS + "auth/hcp/causeOfDeathTrendsReport.jsp"));
assertLogged(TransactionType.DEATH_TRENDS_VIEW, 9000000003L, 0L,
"View cause-of-death trends report");
WebElement table = driver.findElement(By.id("causeOfDeathTrendsTable"));
String cause1 = table.findElements(By.tagName("td")).get(0).getText();
double code1 = Double.parseDouble(table.findElements(By.tagName("td")).get(1).getText());
int deaths1 = Integer.parseInt(table.findElements(By.tagName("td")).get(2).getText());
assertEquals(cause1, "Influenza");
assertEquals(code1, 487.00);
assertEquals(deaths1, 2);
}
public void testViewCODTrendsReports_EmptyDates() throws Exception {
driver = (HtmlUnitDriver)login("9000000003", "pw");
// Click Diagnosis Trends
driver.findElement(By.cssSelector("h2.panel-title")).click();
driver.findElement(By.xpath("//div[@class='panel-body']/ul/li[11]")).click();
driver.findElement(By.linkText("Cause-Of-Death Trends Report")).click();
// View Cause of Death Trends Report
assertTrue(driver.getCurrentUrl().equals(ADDRESS + "auth/hcp/causeOfDeathTrendsReport.jsp"));
driver.findElement(By.name("startDate")).clear();
driver.findElement(By.name("startDate")).sendKeys("");
driver.findElement(By.name("endDate")).sendKeys("");
driver.findElement(By.id("view_report")).click();
assertTrue(driver.getCurrentUrl().equals(ADDRESS + "auth/hcp/causeOfDeathTrendsReport.jsp"));
assertLogged(TransactionType.DEATH_TRENDS_VIEW, 9000000003L, 0L,
"View cause-of-death trends report");
assertTrue(driver.getPageSource().contains("Enter dates in MM/dd/yyyy"));
}
public void testViewCODTrendsReports_InvalidDateFormat() throws Exception {
driver = (HtmlUnitDriver)login("9000000003", "pw");
// Click Diagnosis Trends
driver.findElement(By.cssSelector("h2.panel-title")).click();
driver.findElement(By.xpath("//div[@class='panel-body']/ul/li[11]")).click();
driver.findElement(By.linkText("Cause-Of-Death Trends Report")).click();
// View Cause of Death Trends Report
assertTrue(driver.getCurrentUrl().equals(ADDRESS + "auth/hcp/causeOfDeathTrendsReport.jsp"));
driver.findElement(By.name("startDate")).clear();
driver.findElement(By.name("startDate")).sendKeys("01-01-2000");
driver.findElement(By.name("endDate")).sendKeys("12-31-2020");
driver.findElement(By.id("view_report")).click();
assertTrue(driver.getCurrentUrl().equals(ADDRESS + "auth/hcp/causeOfDeathTrendsReport.jsp"));
assertLogged(TransactionType.DEATH_TRENDS_VIEW, 9000000003L, 0L,
"View cause-of-death trends report");
assertTrue(driver.getPageSource().contains("Enter dates in MM/dd/yyyy"));
}
public void testViewCODTrendsReports_StartDateAfterEndDate() throws Exception {
driver = (HtmlUnitDriver)login("9000000003", "pw");
// Click Diagnosis Trends
driver.findElement(By.cssSelector("h2.panel-title")).click();
driver.findElement(By.xpath("//div[@class='panel-body']/ul/li[11]")).click();
driver.findElement(By.linkText("Cause-Of-Death Trends Report")).click();
// View Cause of Death Trends Report
assertTrue(driver.getCurrentUrl().equals(ADDRESS + "auth/hcp/causeOfDeathTrendsReport.jsp"));
driver.findElement(By.name("startDate")).clear();
driver.findElement(By.name("startDate")).sendKeys("01/01/2021");
driver.findElement(By.name("endDate")).sendKeys("12/31/2020");
driver.findElement(By.id("view_report")).click();
assertTrue(driver.getCurrentUrl().equals(ADDRESS + "auth/hcp/causeOfDeathTrendsReport.jsp"));
assertLogged(TransactionType.DEATH_TRENDS_VIEW, 9000000003L, 0L,
"View cause-of-death trends report");
assertTrue(driver.getPageSource().contains("Start date must be before end date!"));
}
}
...@@ -41,7 +41,7 @@ public class ViewPatientOfficeVisitHistoryActionTest extends TestCase{ ...@@ -41,7 +41,7 @@ public class ViewPatientOfficeVisitHistoryActionTest extends TestCase{
*/ */
public void testGetPatients() throws Exception { public void testGetPatients() throws Exception {
List<PatientVisitBean> list = action.getPatients(); List<PatientVisitBean> list = action.getPatients();
assertEquals(57, list.size()); assertEquals(67, list.size());
assertEquals("31", list.get(21).getLastOVDateD()); assertEquals("31", list.get(21).getLastOVDateD());
assertEquals("03", list.get(21).getLastOVDateM()); assertEquals("03", list.get(21).getLastOVDateM());
} }
......
package edu.ncsu.csc.itrust.unit.dao.deaths;
import java.util.List;
import junit.framework.TestCase;
import edu.ncsu.csc.itrust.dao.mysql.CauseOfDeathTrendsReportDAO;
import edu.ncsu.csc.itrust.beans.CauseOfDeathTrendsReportBean;
import edu.ncsu.csc.itrust.unit.datagenerators.TestDataGenerator;
import edu.ncsu.csc.itrust.unit.testutils.TestDAOFactory;
import edu.ncsu.csc.itrust.unit.testutils.EvilDAOFactory;
import edu.ncsu.csc.itrust.exception.DBException;
public class CauseOfDeathTrendsReportTest extends TestCase {
private CauseOfDeathTrendsReportDAO cod;
private CauseOfDeathTrendsReportDAO evilDAO = new CauseOfDeathTrendsReportDAO(EvilDAOFactory.getEvilInstance());
@Override
protected void setUp() throws Exception {
TestDataGenerator gen = new TestDataGenerator();
gen.clearAllTables();
gen.deadPatient1();
gen.deadPatient2();
gen.deadPatient3();
gen.deadPatient4();
gen.deadPatient5();
gen.deadPatient6();
gen.deadPatient7();
gen.deadPatient8();
gen.deadPatient9();
gen.deadPatient10();
gen.icd9cmCodes();
cod = new CauseOfDeathTrendsReportDAO(TestDAOFactory.getTestInstance());
}
public void testPatientsForHCPValid() throws Exception {
List<Long> deaths = cod.getPatientsForHCP(Long.parseLong("9000000000"));
assertEquals(6, deaths.size());
assertEquals(Long.valueOf(81), deaths.get(0));
assertEquals(Long.valueOf(82), deaths.get(1));
assertEquals(Long.valueOf(83), deaths.get(2));
assertEquals(Long.valueOf(84), deaths.get(3));
assertEquals(Long.valueOf(85), deaths.get(4));
assertEquals(Long.valueOf(86), deaths.get(5));
}
public void testPatientsForHCPException() throws Exception {
try {
evilDAO.getPatientsForHCP(Long.parseLong("0000000000"));
fail("DBException should have been thrown");
} catch (DBException e) {
assertEquals(EvilDAOFactory.MESSAGE, e.getSQLException().getMessage());
}
}
public void testCodeNameExists() throws Exception {
String deaths = cod.getCodeName("84.50");
assertEquals("Malaria", deaths);
}
public void testCodeNameDoesNotExist() throws Exception {
String deaths = cod.getCodeName("8450");
assertEquals(null, deaths);
}
public void testTopTwoDeathsForHCPValid() throws Exception {
List<CauseOfDeathTrendsReportBean> deaths = cod.getTopTwoDeathsForHCP(Long.parseLong("9000000000"), "All", "01/01/2018", "12/31/2020");
assertEquals(2, deaths.size());
assertEquals("11.40", deaths.get(0).getCode());
assertEquals("Tuberculosis of the lung", deaths.get(0).getCause());
assertEquals("3", deaths.get(0).getDeaths());
assertEquals("84.50", deaths.get(1).getCode());
assertEquals("Malaria", deaths.get(1).getCause());
assertEquals("2", deaths.get(1).getDeaths());
}
public void testTopTwoDeathsForHCPMaleValid() throws Exception {
List<CauseOfDeathTrendsReportBean> deaths = cod.getTopTwoDeathsForHCP(Long.parseLong("9000000000"), "Male", "01/01/2018", "12/31/2020");
assertEquals(2, deaths.size());
assertEquals("84.50", deaths.get(0).getCode());
assertEquals("Malaria", deaths.get(0).getCause());
assertEquals("2", deaths.get(0).getDeaths());
assertEquals("11.40", deaths.get(1).getCode());
assertEquals("Tuberculosis of the lung", deaths.get(1).getCause());
assertEquals("2", deaths.get(1).getDeaths());
}
public void testTopTwoDeathsForHCPException() throws Exception {
try {
evilDAO.getTopTwoDeathsForHCP(Long.parseLong("0000000000"), "All", "01/01/1990", "12/31/2020");
fail("DBException should have been thrown");
} catch (DBException e) {
assertEquals(EvilDAOFactory.MESSAGE, e.getSQLException().getMessage());
}
}
public void testTopTwoDeathsForHCPNullDate() throws Exception {
List<CauseOfDeathTrendsReportBean> deaths = cod.getTopTwoDeathsForHCP(Long.parseLong("9000000000"), "Male", null, "12/31/2020");
assertEquals(null, deaths);
}
public void testTopTwoDeathsForAllValid() throws Exception {
List<CauseOfDeathTrendsReportBean> deaths = cod.getTopTwoDeathsForAll("All", "01/01/2018", "12/31/2020");
assertEquals(2, deaths.size());
assertEquals("487.00", deaths.get(0).getCode());
assertEquals("Influenza", deaths.get(0).getCause());
assertEquals("5", deaths.get(0).getDeaths());
assertEquals("11.40", deaths.get(1).getCode());
assertEquals("Tuberculosis of the lung", deaths.get(1).getCause());
assertEquals("3", deaths.get(1).getDeaths());
}
public void testTopTwoDeathsForAllFemaleValid() throws Exception {
List<CauseOfDeathTrendsReportBean> deaths = cod.getTopTwoDeathsForAll("Female", "01/01/2018", "12/31/2020");
assertEquals(2, deaths.size());
assertEquals("487.00", deaths.get(0).getCode());
assertEquals("Influenza", deaths.get(0).getCause());
assertEquals("2", deaths.get(0).getDeaths());
assertEquals("11.40", deaths.get(1).getCode());
assertEquals("Tuberculosis of the lung", deaths.get(1).getCause());
assertEquals("1", deaths.get(1).getDeaths());
}
public void testTopTwoDeathsForAllNullDate() throws Exception {
List<CauseOfDeathTrendsReportBean> deaths = cod.getTopTwoDeathsForAll("Male", null, "12/31/2020");
assertEquals(null, deaths);
}
}
\ No newline at end of file
...@@ -121,6 +121,46 @@ public class TestDataGenerator { ...@@ -121,6 +121,46 @@ public class TestDataGenerator {
+ "/deadRecurringPatients.sql"); + "/deadRecurringPatients.sql");
} }
public void deadPatient1() throws FileNotFoundException, SQLException, IOException {
new DBBuilder(factory).executeSQLFile(DIR + "/deadPatient1.sql");
}
public void deadPatient2() throws FileNotFoundException, SQLException, IOException {
new DBBuilder(factory).executeSQLFile(DIR + "/deadPatient2.sql");
}
public void deadPatient3() throws FileNotFoundException, SQLException, IOException {
new DBBuilder(factory).executeSQLFile(DIR + "/deadPatient3.sql");
}
public void deadPatient4() throws FileNotFoundException, SQLException, IOException {
new DBBuilder(factory).executeSQLFile(DIR + "/deadPatient4.sql");
}
public void deadPatient5() throws FileNotFoundException, SQLException, IOException {
new DBBuilder(factory).executeSQLFile(DIR + "/deadPatient5.sql");
}
public void deadPatient6() throws FileNotFoundException, SQLException, IOException {
new DBBuilder(factory).executeSQLFile(DIR + "/deadPatient6.sql");
}
public void deadPatient7() throws FileNotFoundException, SQLException, IOException {
new DBBuilder(factory).executeSQLFile(DIR + "/deadPatient7.sql");
}
public void deadPatient8() throws FileNotFoundException, SQLException, IOException {
new DBBuilder(factory).executeSQLFile(DIR + "/deadPatient8.sql");
}
public void deadPatient9() throws FileNotFoundException, SQLException, IOException {
new DBBuilder(factory).executeSQLFile(DIR + "/deadPatient9.sql");
}
public void deadPatient10() throws FileNotFoundException, SQLException, IOException {
new DBBuilder(factory).executeSQLFile(DIR + "/deadPatient10.sql");
}
public void diagnosedPatient_OldAndNewVisit() throws SQLException, public void diagnosedPatient_OldAndNewVisit() throws SQLException,
FileNotFoundException, IOException { FileNotFoundException, IOException {
new DBBuilder(factory).executeSQLFile(DIR new DBBuilder(factory).executeSQLFile(DIR
...@@ -1113,6 +1153,18 @@ public class TestDataGenerator { ...@@ -1113,6 +1153,18 @@ public class TestDataGenerator {
patient28(); patient28();
patient29(); patient29();
patient30(); patient30();
//Added for UC 20
deadPatient1();
deadPatient2();
deadPatient3();
deadPatient4();
deadPatient5();
deadPatient6();
deadPatient7();
deadPatient8();
deadPatient9();
deadPatient10();
} }
public void uc47SetUp() throws FileNotFoundException, SQLException, public void uc47SetUp() throws FileNotFoundException, SQLException,
......
...@@ -225,10 +225,11 @@ public class DemographicReportFilterTest extends TestCase { ...@@ -225,10 +225,11 @@ public class DemographicReportFilterTest extends TestCase {
assertTrue(res.isEmpty()); assertTrue(res.isEmpty());
} }
//Updated assertEquals(24, res.size()) to assertEquals(27, res.size()) to reflect the 3 female patients added for UC20
public void testFilterByGender() throws Exception { public void testFilterByGender() throws Exception {
filter = new DemographicReportFilter(DemographicReportFilterType.GENDER, "Female", factory); filter = new DemographicReportFilter(DemographicReportFilterType.GENDER, "Female", factory);
List<PatientBean> res = filter.filter(allPatients); List<PatientBean> res = filter.filter(allPatients);
assertEquals(24, res.size()); assertEquals(27, res.size());
assertTrue(res.get(0).getMID() == 1L); assertTrue(res.get(0).getMID() == 1L);
assertTrue(res.get(1).getMID() == 5L); assertTrue(res.get(1).getMID() == 5L);
assertTrue(res.get(2).getMID() == 6L); assertTrue(res.get(2).getMID() == 6L);
......
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