Skip to content
Snippets Groups Projects
Commit b31bc61b authored by adityab3's avatar adityab3
Browse files

[code smell] shortened all lines to 100 chars in ViewDiagnosisStatisticsAction

parent 95c244dd
No related branches found
No related tags found
1 merge request!24Code smells iteration 3.1
...@@ -111,7 +111,8 @@ public class ViewDiagnosisStatisticsAction { ...@@ -111,7 +111,8 @@ public class ViewDiagnosisStatisticsAction {
* @throws FormValidationException * @throws FormValidationException
* @throws ITrustException * @throws ITrustException
*/ */
public DiagnosisStatisticsBean getDiagnosisStatistics(String lowerDate, String upperDate, String icdCode, String zip) throws FormValidationException, ITrustException { public DiagnosisStatisticsBean getDiagnosisStatistics(String lowerDate, String upperDate,
String icdCode, String zip) throws FormValidationException, ITrustException {
DiagnosisStatisticsBean dsBean; DiagnosisStatisticsBean dsBean;
if (lowerDate == null || upperDate == null || icdCode == null) { if (lowerDate == null || upperDate == null || icdCode == null) {
return null; return null;
...@@ -178,7 +179,8 @@ public class ViewDiagnosisStatisticsAction { ...@@ -178,7 +179,8 @@ public class ViewDiagnosisStatisticsAction {
return dsBean; return dsBean;
} }
public List<DiagnosisStatisticsBean> getDiagnosisTrends(String dateString, String icdCode, String zip) throws FormValidationException, ITrustException { public List<DiagnosisStatisticsBean> getDiagnosisTrends(String dateString, String icdCode,
String zip) throws FormValidationException, ITrustException {
ArrayList<DiagnosisStatisticsBean> dsBean = null; ArrayList<DiagnosisStatisticsBean> dsBean = null;
if (dateString == null || icdCode == null) { if (dateString == null || icdCode == null) {
return null; return null;
...@@ -212,7 +214,9 @@ public class ViewDiagnosisStatisticsAction { ...@@ -212,7 +214,9 @@ public class ViewDiagnosisStatisticsAction {
* @throws FormValidationException * @throws FormValidationException
* @throws DBException * @throws DBException
*/ */
public ArrayList<DiagnosisStatisticsBean> getEpidemicStatistics(String startDate, String icdCode, String zip, String threshold) throws FormValidationException, DBException { public ArrayList<DiagnosisStatisticsBean> getEpidemicStatistics(String startDate,
String icdCode, String zip, String threshold)
throws FormValidationException, DBException {
if (startDate == null || icdCode == null) { if (startDate == null || icdCode == null) {
return null; return null;
} }
...@@ -300,9 +304,11 @@ public class ViewDiagnosisStatisticsAction { ...@@ -300,9 +304,11 @@ public class ViewDiagnosisStatisticsAction {
int weekOfYr = cal.get(Calendar.WEEK_OF_YEAR); int weekOfYr = cal.get(Calendar.WEEK_OF_YEAR);
double threshold = calcInfluenzaThreshold(weekOfYr); double threshold = calcInfluenzaThreshold(weekOfYr);
DiagnosisStatisticsBean prev1 = diagnosesDAO.getCountForWeekBefore(ICD_INFLUENZA, zip, cal.getTime()); DiagnosisStatisticsBean prev1 =
diagnosesDAO.getCountForWeekBefore(ICD_INFLUENZA, zip, cal.getTime());
cal.add(Calendar.HOUR, -7*24); cal.add(Calendar.HOUR, -7*24);
DiagnosisStatisticsBean prev2 = diagnosesDAO.getCountForWeekBefore(ICD_INFLUENZA, zip, cal.getTime()); DiagnosisStatisticsBean prev2 =
diagnosesDAO.getCountForWeekBefore(ICD_INFLUENZA, zip, cal.getTime());
long weekL1 = prev1.getRegionStats(); long weekL1 = prev1.getRegionStats();
long weekL2 = prev2.getRegionStats(); long weekL2 = prev2.getRegionStats();
...@@ -320,7 +326,10 @@ public class ViewDiagnosisStatisticsAction { ...@@ -320,7 +326,10 @@ public class ViewDiagnosisStatisticsAction {
* @return the epidemic threshold for flu cases * @return the epidemic threshold for flu cases
*/ */
private double calcInfluenzaThreshold(double weekNumber) { private double calcInfluenzaThreshold(double weekNumber) {
return 5.34 + 0.271 * weekNumber + 3.45 * Math.sin(2 * Math.PI * weekNumber / 52.0) + 8.41 * Math.cos(2 * Math.PI * weekNumber / 52.0); return 5.34
+ 0.271 * weekNumber
+ 3.45 * Math.sin(2 * Math.PI * weekNumber / 52.0)
+ 8.41 * Math.cos(2 * Math.PI * weekNumber / 52.0);
} }
/** /**
...@@ -334,7 +343,8 @@ public class ViewDiagnosisStatisticsAction { ...@@ -334,7 +343,8 @@ public class ViewDiagnosisStatisticsAction {
* @throws DBException * @throws DBException
* @throws ParseException * @throws ParseException
*/ */
public boolean isMalariaEpidemic(String weekDate, String zip, String thresholdStr) throws DBException, ParseException { public boolean isMalariaEpidemic(String weekDate, String zip, String thresholdStr)
throws DBException, ParseException {
Date wkDate = new SimpleDateFormat("MM/dd/yyyy").parse(weekDate); Date wkDate = new SimpleDateFormat("MM/dd/yyyy").parse(weekDate);
ArrayList<DiagnosisStatisticsBean> historyWkL1 = new ArrayList<DiagnosisStatisticsBean>(); ArrayList<DiagnosisStatisticsBean> historyWkL1 = new ArrayList<DiagnosisStatisticsBean>();
...@@ -345,13 +355,16 @@ public class ViewDiagnosisStatisticsAction { ...@@ -345,13 +355,16 @@ public class ViewDiagnosisStatisticsAction {
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
cal.setTime(wkDate); cal.setTime(wkDate);
DiagnosisStatisticsBean current = diagnosesDAO.getCountForWeekOf(ICD_MALARIA, zip, cal.getTime()); DiagnosisStatisticsBean current =
diagnosesDAO.getCountForWeekOf(ICD_MALARIA, zip, cal.getTime());
DiagnosisStatisticsBean prev1 = diagnosesDAO.getCountForWeekBefore(ICD_MALARIA, zip, cal.getTime()); DiagnosisStatisticsBean prev1 =
diagnosesDAO.getCountForWeekBefore(ICD_MALARIA, zip, cal.getTime());
long weekTotalL1 = prev1.getRegionStats(); long weekTotalL1 = prev1.getRegionStats();
cal.add(Calendar.HOUR, -7*24); cal.add(Calendar.HOUR, -7*24);
DiagnosisStatisticsBean prev2 = diagnosesDAO.getCountForWeekBefore(ICD_MALARIA, zip, cal.getTime()); DiagnosisStatisticsBean prev2 =
diagnosesDAO.getCountForWeekBefore(ICD_MALARIA, zip, cal.getTime());
long weekTotalL2 = prev2.getRegionStats(); long weekTotalL2 = prev2.getRegionStats();
cal.setTime(wkDate); cal.setTime(wkDate);
...@@ -394,8 +407,10 @@ public class ViewDiagnosisStatisticsAction { ...@@ -394,8 +407,10 @@ public class ViewDiagnosisStatisticsAction {
double avgL1 = ((double)totalHistL1) / ((double)countHistL1); double avgL1 = ((double)totalHistL1) / ((double)countHistL1);
double avgL2 = ((double)totalHistL2) / ((double)countHistL2); double avgL2 = ((double)totalHistL2) / ((double)countHistL2);
boolean epidemicL1 = (weekTotalL1*100.0) / threshold > avgL1 || (countHistL1 == 0 && weekTotalL1 != 0); boolean epidemicL1 = (weekTotalL1*100.0) / threshold > avgL1
boolean epidemicL2 = (weekTotalL2*100.0) / threshold > avgL2 || (countHistL2 == 0 && weekTotalL2 != 0); || (countHistL1 == 0 && weekTotalL1 != 0);
boolean epidemicL2 = (weekTotalL2*100.0) / threshold > avgL2
|| (countHistL2 == 0 && weekTotalL2 != 0);
return epidemicL1 && epidemicL2; return epidemicL1 && epidemicL2;
} }
} }
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