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

[backend] Added action for viewing diagnosis trends

parent 6d72164c
No related branches found
No related tags found
1 merge request!26UC14
...@@ -93,6 +93,43 @@ public class ViewDiagnosisStatisticsAction { ...@@ -93,6 +93,43 @@ public class ViewDiagnosisStatisticsAction {
return dsBean; return dsBean;
} }
public List<DiagnosisStatisticsBean> getDiagnosisTrends(String dateString, String icdCode, String zip) throws FormValidationException, ITrustException {
ArrayList<DiagnosisStatisticsBean> dsBean = null;
if (dateString == null || icdCode == null)
return null;
try {
if (!zip.matches("([0-9]{5})|([0-9]{5}-[0-9]{4})"))
throw new FormValidationException("Zip Code must be 5 digits!");
Date next = new SimpleDateFormat("MM/dd/yyyy").parse(dateString);
dsBean = new ArrayList<>();
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!");
}
Calendar cal = Calendar.getInstance();
cal.setTime(next);
for (int i = 0; i < 8; i++) {
Date weekDate = cal.getTime();
dsBean.add(diagnosesDAO.getCountForWeekBefore(icdCode, zip, weekDate));
cal.add(Calendar.HOUR, -24*7);
}
} catch (ParseException e) {
throw new FormValidationException("Enter dates in MM/dd/yyyy");
}
return dsBean;
}
/** /**
* Gets the local and regional counts for the specified week and calculates the prior average. * Gets the local and regional counts for the specified week and calculates the prior average.
......
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