Skip to content

Commit

Permalink
Review Refactors
Browse files Browse the repository at this point in the history
  • Loading branch information
MontaltoNick committed Feb 26, 2024
1 parent 2055998 commit e33c048
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ public PatientMeasureReportSizeSummary getPatientMeasureReportSizeSummary(
var reportSizes = tenantService.getPatientMeasureReportSize(patientId, reportId, measureId);

var summary = new PatientMeasureReportSizeSummary();
Double sum = 0.0;
double sum = 0.0;
var measureCountMap = summary.getCountReportSizeByMeasureId();
var reportCountMap = summary.getCountReportSizeByReportId();
var patientCountMap = summary.getCountReportSizeByPatientId();
Expand All @@ -431,48 +431,24 @@ public PatientMeasureReportSizeSummary getPatientMeasureReportSizeSummary(

sum += r.getSizeKb();

if(measureCountMap.containsKey(mId))
measureCountMap.put(mId, measureCountMap.get(mId) + 1);
else {
measureCountMap.put(mId, 1);
averageReportSizeByMeasureId.put(mId, 0.0);
}
averageReportSizeByMeasureId.put(mId, averageReportSizeByMeasureId.get(mId) + r.getSizeKb());

if(reportCountMap.containsKey(rId))
reportCountMap.put(rId, reportCountMap.get(rId) + 1);
else {
reportCountMap.put(rId, 1);
averageReportSizeByReportId.put(rId, 0.0);
}
measureCountMap.merge(mId, 1, (count, value) -> count + value);
averageReportSizeByMeasureId.merge(mId, r.getSizeKb(), (size, value) -> size + value);

averageReportSizeByReportId.put(rId, averageReportSizeByReportId.get(rId) + r.getSizeKb());
reportCountMap.merge(rId, 1, (count, value) -> count + value);
averageReportSizeByReportId.merge(rId, r.getSizeKb(), (size, value) -> size + value);

if(patientCountMap.containsKey(pId))
patientCountMap.put(pId, patientCountMap.get(pId) + 1);
else {
patientCountMap.put(pId, 1);
averageReportSizeByPatientId.put(pId, 0.0);
}
averageReportSizeByPatientId.put(pId, averageReportSizeByPatientId.get(pId) + r.getSizeKb());
patientCountMap.merge(pId, 1, (count, value) -> count + value);
averageReportSizeByPatientId.merge(pId, r.getSizeKb(), (size, value) -> size + value);
}

summary.setTotalSize(sum);
summary.setReports(reportSizes);
summary.setReportCount(reportSizes.size());
summary.setAverageReportSize(sum/reportSizes.size());

for(var kv : measureCountMap.entrySet()) {
averageReportSizeByMeasureId.put(kv.getKey(), averageReportSizeByMeasureId.get(kv.getKey())/kv.getValue());
}

for(var kv : reportCountMap.entrySet()) {
averageReportSizeByReportId.put(kv.getKey(), averageReportSizeByReportId.get(kv.getKey())/kv.getValue());
}

for(var kv : patientCountMap.entrySet()) {
averageReportSizeByPatientId.put(kv.getKey(), averageReportSizeByPatientId.get(kv.getKey())/kv.getValue());
}
averageReportSizeByMeasureId.replaceAll((key, value) -> value/measureCountMap.get(key));
averageReportSizeByReportId.replaceAll((key, value) -> value/reportCountMap.get(key));
averageReportSizeByPatientId.replaceAll((key, value) -> value/patientCountMap.get(key));

return summary;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public Row(ResultSet resultSet) {
public String getString(String columnName) throws SQLException {
return resultSet.getNString(columnName);
}
public Double getDouble(String columnName) throws SQLException {
public double getDouble(String columnName) throws SQLException {
return resultSet.getDouble(columnName);
}
public Date getDate(String columnName) throws SQLException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ public PatientMeasureReportSize GetMeasureReportSizeById(String id) {
}

public List<PatientMeasureReportSize> GetMeasureReportSize(String patientId, String reportId, String measureId) {
String sql = "SELECT pmr.patientId, pmr.reportId, pmr.measureID, CAST(SUM(DATALENGTH(pmr.measureReport)) as FLOAT)/1024.0 as sizeKb FROM dbo.patientMeasureReport AS pmr WHERE (ISNULL(:reportId, '') = '' OR reportId = :reportId) AND (ISNULL(:measureId, '') = '' OR measureId = :measureId) AND (ISNULL(:patientId, '') = '' OR patientId = :patientId) GROUP BY pmr.patientId, pmr.reportId, pmr.measureId";
String sql = "SELECT pmr.patientId, pmr.reportId, pmr.measureID, CAST(SUM(DATALENGTH(pmr.measureReport)) as FLOAT)/1024.0 as sizeKb FROM dbo.patientMeasureReport AS pmr WHERE (:reportId = '' OR reportId = :reportId) AND (:measureId = '' OR measureId = :measureId) AND (:patientId = '' OR patientId = :patientId) GROUP BY pmr.patientId, pmr.reportId, pmr.measureId";

if(reportId == null) reportId = "";
if(measureId == null) measureId = "";
if(patientId == null) patientId = "";

HashMap<String, String> parameters = new HashMap<String, String>();
HashMap<String, String> parameters = new HashMap();
parameters.put("reportId", reportId);
parameters.put("patientId", patientId);
parameters.put("measureId", measureId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
@Setter
public class PatientMeasureReportSizeSummary{
private List<PatientMeasureReportSize> Reports;
private Double TotalSize;
private double TotalSize;
private int ReportCount;
private Double AverageReportSize;
private double AverageReportSize;

private HashMap<String, Integer> CountReportSizeByMeasureId= new HashMap<>();
private HashMap<String, Double> AverageReportSizeByMeasureId = new HashMap<>();
Expand Down

0 comments on commit e33c048

Please sign in to comment.