UC20 Data Access Object Completed
Data Access Object for UC20 completed and can be found at: src/edu/ncsu/csc/itrust/dao/mysql/CauseOfDeathTrendsReportDAO.java
All JUnit tests pass with a code coverage of 91%. Test file can be found at: test/edu/ncsu/csc/itrust/unit/dao/deaths/CauseOfDeathTrendsReportTest.java
To test:
Repopulate the database, as dead patients are created specifically for testing:
java -cp "$(mvn -q dependency:build-classpath -Dmdep.outputFile=/dev/stdout)":target/classes:target/test-classes edu.ncsu.csc.itrust.unit.datagenerators.TestDataGenerator
Then run the unit test file:
mvn -Dtest=CauseOfDeathTrendsReportTest test
Output should be:
Tests run: 9, Failures: 0, Errors: 0, Skipped: 0
Code coverage:
Merge request reports
Activity
62 * @param endDate End date of search. 63 * @return A java.util.List of TopTwoDeathsForHCP. 64 * @throws DBException 65 */ 66 public List<String> getTopTwoDeathsForHCP(long hcpMID, String gender, Date startDate, Date endDate) throws DBException { 67 Connection conn = null; 68 PreparedStatement stmt = null; 69 List<Long> patients = this.getPatientsForHCP(hcpMID); 70 List<String> causes = new ArrayList<String>(); 71 String query = null; 72 73 try { 74 conn = factory.getConnection(); 75 76 if(gender.equalsIgnoreCase("All")){ 77 query = "SELECT DISTINCT CauseOfDeath, COUNT(CauseOfDeath) FROM patients WHERE MID IN ("; 64 * @throws DBException 65 */ 66 public List<String> getTopTwoDeathsForHCP(long hcpMID, String gender, Date startDate, Date endDate) throws DBException { 67 Connection conn = null; 68 PreparedStatement stmt = null; 69 List<Long> patients = this.getPatientsForHCP(hcpMID); 70 List<String> causes = new ArrayList<String>(); 71 String query = null; 72 73 try { 74 conn = factory.getConnection(); 75 76 if(gender.equalsIgnoreCase("All")){ 77 query = "SELECT DISTINCT CauseOfDeath, COUNT(CauseOfDeath) FROM patients WHERE MID IN ("; 78 for(int i = 0; i < patients.size(); i++) 79 { 80 if (i+1 == patients.size()){ 81 query += patients.get(i); 82 } 83 else{ 84 query += patients.get(i) + ","; 85 } 86 87 } 88 query += ") AND DateOfDeath IS NOT NULL AND YEAR(DateOfDeath) >= YEAR(?) AND YEAR(DateOfDeath) <= YEAR(?)" 89 + "GROUP BY CauseOfDeath ORDER BY COUNT(CauseOfDeath) DESC"; 90 stmt = conn.prepareStatement(query); 91 stmt.setDate(1, startDate); 92 stmt.setDate(2, endDate); 93 } 94 95 else{ 144 List<String> causes = new ArrayList<String>(); 145 String query = null; 146 147 try { 148 conn = factory.getConnection(); 149 150 if(gender.equalsIgnoreCase("All")){ 151 query = "SELECT DISTINCT CauseOfDeath, COUNT(CauseOfDeath) FROM patients" 152 + " WHERE DateOfDeath IS NOT NULL AND YEAR(DateOfDeath) >= YEAR(?) AND YEAR(DateOfDeath) <= YEAR(?)" 153 + "GROUP BY CauseOfDeath ORDER BY COUNT(CauseOfDeath) DESC"; 154 stmt = conn.prepareStatement(query); 155 stmt.setDate(1, startDate); 156 stmt.setDate(2, endDate); 157 } 158 159 else{ 8 import edu.ncsu.csc.itrust.dao.mysql.CauseOfDeathTrendsReportDAO; 9 import edu.ncsu.csc.itrust.unit.datagenerators.TestDataGenerator; 10 import edu.ncsu.csc.itrust.unit.testutils.TestDAOFactory; 11 import edu.ncsu.csc.itrust.unit.testutils.EvilDAOFactory; 12 import edu.ncsu.csc.itrust.exception.DBException; 13 14 15 public class CauseOfDeathTrendsReportTest extends TestCase { 16 17 private TestDataGenerator gen = new TestDataGenerator(); 18 private CauseOfDeathTrendsReportDAO cod; 19 20 private CauseOfDeathTrendsReportDAO evilDAO = new CauseOfDeathTrendsReportDAO(EvilDAOFactory.getEvilInstance()); 21 22 @Override 23 protected void setUp() throws Exception { added 1 commit
- 63a6dc53 - Updated cause-of-death trends report to return report results (dates are...
added 1 commit
- 7281eda4 - Modified CauseOfDeathTrendsReportDAO getTopTwoDeaths methods to format dates in proper format
added 1 commit
- 010f0b92 - Updated causeOfDeathTrendsReport jsp to pass field values (patient, gender,...
added 1 commit
- 201a4f98 - Updated patients 1-8 to add death date and cause of death data. Also updated...
added 1 commit
- 208d6acb - Added event logging for CauseOfDeathTrendsReport jsp file.
added 1 commit
- 44d02901 - Updated unit tests to get results from CauseOfDeathTrendsReportBean
added 1 commit
- 76889cca - reverted patient1-8 sql files to original entry and updated deadPatient sql files
added 1 commit
- 38ab3386 - Updated testFilterByGender unit test to reflect the addition of three dead...
added 1 commit
- 57e4959c - Added Selenium tests for different combinations of selections on screen, as...
added 1 commit
- 5e04f75c - updated deadPatient SQL files and updated...
added 2 commits
- dad19424 - Three code smells identified and fixed. 1- multiple occurrences of the same...
- 0aa9ed68 - Merge branch 'UC20' of https://gitlab.engr.illinois.edu/htmoss2/cs427fa20team22 into UC20
added 1 commit
- 9475e137 - returning PatientBean.java to original form with no code smells and pushing...