Skip to content
Snippets Groups Projects
Commit b3f54433 authored by ahmadaldhalaan's avatar ahmadaldhalaan
Browse files

uploaded deadPatient sql files, updated TestDataGenerator and...

uploaded deadPatient sql files, updated TestDataGenerator and CauseOfDeathTrendsReportTest.java test file
parent 9cffa649
No related branches found
No related tags found
2 merge requests!7Uc20,!2UC20 Data Access Object Completed
INSERT INTO patients (MID, Gender, DateOfDeath, CauseOfDeath)
VALUES (81,'Male','2019-07-01',84.50);
INSERT INTO officevisits(id,HCPID,PatientID)
VALUES (201,9000000000,81);
\ No newline at end of file
INSERT INTO patients (MID, Gender, DateOfDeath, CauseOfDeath)
VALUES (90,'Male','2019-01-01',487.00);
INSERT INTO officevisits(id,HCPID,PatientID)
VALUES (210,9000000001,90);
\ No newline at end of file
INSERT INTO patients (MID, Gender, DateOfDeath, CauseOfDeath)
VALUES (82,'Male','2018-07-01',11.40);
INSERT INTO officevisits(id,HCPID,PatientID)
VALUES (202,9000000000,82);
\ No newline at end of file
INSERT INTO patients (MID, Gender, DateOfDeath, CauseOfDeath)
VALUES (83,'Female','2018-07-01',11.40);
INSERT INTO officevisits(id,HCPID,PatientID)
VALUES (203,9000000000,83);
\ No newline at end of file
INSERT INTO patients (MID, Gender, DateOfDeath, CauseOfDeath)
VALUES (84,'Male','2018-12-01',11.40);
INSERT INTO officevisits(id,HCPID,PatientID)
VALUES (204,9000000000,84);
\ No newline at end of file
INSERT INTO patients (MID, Gender, DateOfDeath, CauseOfDeath)
VALUES (85,'Male','2020-01-01',84.50);
INSERT INTO officevisits(id,HCPID,PatientID)
VALUES (205,9000000000,85);
\ No newline at end of file
INSERT INTO patients (MID, Gender, DateOfDeath, CauseOfDeath)
VALUES (86,'Male','2018-12-01',487.00);
INSERT INTO officevisits(id,HCPID,PatientID)
VALUES (206,9000000000,86);
\ No newline at end of file
INSERT INTO patients (MID, Gender, DateOfDeath, CauseOfDeath)
VALUES (87,'Female','2019-12-01',487.00);
INSERT INTO officevisits(id,HCPID,PatientID)
VALUES (207,9000000001,87);
\ No newline at end of file
INSERT INTO patients (MID, Gender, DateOfDeath, CauseOfDeath)
VALUES (88,'Female','2020-07-01',487.00);
INSERT INTO officevisits(id,HCPID,PatientID)
VALUES (208,9000000001,88);
\ No newline at end of file
INSERT INTO patients (MID, Gender, DateOfDeath, CauseOfDeath)
VALUES (89,'Male','2020-01-01',487.00);
INSERT INTO officevisits(id,HCPID,PatientID)
VALUES (209,9000000001,89);
\ No newline at end of file
package edu.ncsu.csc.itrust.UC20;
import java.util.List;
import java.util.ArrayList;
import java.sql.Date;
import junit.framework.TestCase;
import edu.ncsu.csc.itrust.dao.mysql.CauseOfDeathTrendsReportDAO;
import edu.ncsu.csc.itrust.unit.datagenerators.TestDataGenerator;
import edu.ncsu.csc.itrust.unit.testutils.TestDAOFactory;
import edu.ncsu.csc.itrust.exception.DBException;
public class CauseOfDeathTrendsReportTest extends TestCase {
private TestDataGenerator gen = new TestDataGenerator();
private CauseOfDeathTrendsReportDAO cod;
@Override
protected void setUp() throws Exception {
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 testPatientsForHCPInvalidID() throws Exception {
try {
cod.getPatientsForHCP(Long("0"));
fail("Should have failed but didn't");
} catch (FormValidationException e) {
assertEquals(1, e.getErrorList().size());
assertEquals("HCP ID must be valid!", e.getErrorList().get(0));
}
}
*/
public void testTopTwoCorrectForHCPValid() throws Exception {
List<String> deaths = cod.getTopTwoDeathsForHCP(Long.parseLong("9000000000"), "All", Date.valueOf("2018-01-01"), Date.valueOf("2020-12-31"));
assertEquals(2, deaths.size());
assertEquals("Name: Tuberculosis of the lung, Code: 11.40, Deaths: 3", deaths.get(0));
assertEquals("Name: Malaria, Code: 84.50, Deaths: 2", deaths.get(1));
}
public void testTopTwoCorrectMaleForHCPValid() throws Exception {
List<String> deaths = cod.getTopTwoDeathsForHCP(Long.parseLong("9000000000"), "Male", Date.valueOf("2018-01-01"), Date.valueOf("2020-12-31"));
assertEquals(2, deaths.size());
assertEquals("Name: Malaria, Code: 84.50, Deaths: 2", deaths.get(0));
assertEquals("Name: Tuberculosis of the lung, Code: 11.40, Deaths: 2", deaths.get(1));
}
/*public void testTopTwoCorrectForAllValid() throws Exception {
List<String> deaths = cod.getTopTwoDeathsForAll("All", Date.valueOf("2018-01-01"), Date.valueOf("2020-12-31"));
assertEquals(2, deaths.size());
assertEquals("Name: Influenza, Code: 487.00, Deaths: 5", deaths.get(0));
assertEquals("Name: Tuberculosis of the lung, Code: 11.40, Deaths: 3", deaths.get(1));
}*/
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);
}
}
\ No newline at end of file
......@@ -121,6 +121,46 @@ public class TestDataGenerator {
+ "/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,
FileNotFoundException, IOException {
new DBBuilder(factory).executeSQLFile(DIR
......
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