Skip to content
Snippets Groups Projects
Commit 07e4adf8 authored by sbobo3's avatar sbobo3 Committed by adityab3
Browse files

[backend] Overloaded getDiagnosisStatistics to get statistics for 8 weeks prior to given date

parent 75b800c7
No related branches found
No related tags found
1 merge request!26UC14
......@@ -97,6 +97,53 @@ public class ViewDiagnosisStatisticsAction {
return dsBean;
}
/**
* Gets the counts of local and regional diagnoses for the specified input (lower date 8 weeks prior to upper date)
*
* @param upperDate The ending date for the time range
* @param icdCode The diagnosis code to examine
* @param zip The zip code to examine
* @return A bean containing the local and regional counts
* @throws FormValidationException
* @throws ITrustException
*/
public DiagnosisStatisticsBean getDiagnosisStatistics(String upperDate, String icdCode, String zip) throws FormValidationException, ITrustException {
DiagnosisStatisticsBean dsBean;
try {
if (upperDate == null || icdCode == null)
return null;
Date upper = new SimpleDateFormat("MM/dd/yyyy").parse(upperDate);
//calculate lower date by finding the date that is 8 weeks prior to upperDate
Calendar cal = Calendar.getInstance();
cal.setTime(upper);
cal.add(Calendar.HOUR, -56*24);
Date lower = cal.getTime();
if (!zip.matches("([0-9]{5})|([0-9]{5}-[0-9]{4})"))
throw new FormValidationException("Zip Code must be 5 digits!");
boolean validCode = false;
for(DiagnosisBean diag : getDiagnosisCodes()) {
if (diag.getICDCode().equals(icdCode))
validCode = true;
}
if (validCode == false) {
throw new FormValidationException("ICDCode must be valid diagnosis!");
}
dsBean = diagnosesDAO.getDiagnosisCounts(icdCode, zip, lower, upper);
} catch (ParseException e) {
throw new FormValidationException("Enter date in MM/dd/yyyy");
}
return dsBean;
}
public List<DiagnosisStatisticsBean> getDiagnosisTrends(String dateString, String icdCode, String zip) throws FormValidationException, ITrustException {
ArrayList<DiagnosisStatisticsBean> dsBean = null;
if (dateString == null || icdCode == null) {
......
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