Skip to content

Commit

Permalink
SSEMR-549 Fetch regimens in real time
Browse files Browse the repository at this point in the history
  • Loading branch information
Michaelndula committed Feb 12, 2025
1 parent e1c7947 commit 19dcc16
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,24 @@ private Map<String, Object> prepareResults(Map<String, Integer> regimenCounts) {
results.put("results", regimenList);
return results;
}

public static Date[] getStartAndEndDate(String qStartDate, String qEndDate, SimpleDateFormat dateTimeFormatter)
throws ParseException {
Date endDate = (qEndDate != null) ? dateTimeFormatter.parse(qEndDate) : new Date();

// Extend endDate to 23:59:59
Calendar calendar = Calendar.getInstance();
calendar.setTime(endDate);
calendar.set(Calendar.HOUR_OF_DAY, 23);
calendar.set(Calendar.MINUTE, 59);
calendar.set(Calendar.SECOND, 59);
calendar.set(Calendar.MILLISECOND, 999);
endDate = calendar.getTime();

// Set startDate correctly
calendar.set(Calendar.DAY_OF_MONTH, 1);
Date startDate = (qStartDate != null) ? dateTimeFormatter.parse(qStartDate) : calendar.getTime();

return new Date[] { startDate, endDate };
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,12 @@ public Object getPatientsOnAdultRegimenTreatment(HttpServletRequest request,
Date startDate = dateTimeFormatter.parse(qStartDate);
Date endDate = dateTimeFormatter.parse(qEndDate);

// Add 23 hours to endDate
Calendar calendar = Calendar.getInstance();
calendar.setTime(endDate);
calendar.add(Calendar.HOUR_OF_DAY, 23);
endDate = calendar.getTime();

// Get txCurrPatients within the date range
List<GetTxNew.PatientEnrollmentData> txCurrPatients = getTxCurrMain.getTxCurrPatients(startDate, endDate);

Expand All @@ -516,7 +522,6 @@ public Object getPatientsOnAdultRegimenTreatment(HttpServletRequest request,
Arrays.asList(regimen_4A, regimen_4B, regimen_4C, regimen_4D, regimen_4E, regimen_4F, regimen_4G, regimen_4H,
regimen_4I, regimen_4J, regimen_4K, regimen_4L, regimen_5A, regimen_5B, regimen_5C, regimen_5D, regimen_5E,
regimen_5F, regimen_5G, regimen_5H, regimen_5I, regimen_5J),
// regimens
ACTIVE_REGIMEN_CONCEPT_UUID, txCurrPatients, true);
}

Expand All @@ -530,6 +535,12 @@ public Object getPatientsOnChildRegimenTreatment(HttpServletRequest request,
Date startDate = dateTimeFormatter.parse(qStartDate);
Date endDate = dateTimeFormatter.parse(qEndDate);

// Add 23 hours to endDate
Calendar calendar = Calendar.getInstance();
calendar.setTime(endDate);
calendar.add(Calendar.HOUR_OF_DAY, 23);
endDate = calendar.getTime();

// Get txCurrPatients within the date range
List<GetTxNew.PatientEnrollmentData> txCurrPatients = getTxCurrMain.getTxCurrPatients(startDate, endDate);

Expand All @@ -541,7 +552,6 @@ public Object getPatientsOnChildRegimenTreatment(HttpServletRequest request,
Arrays.asList(regimen_4A, regimen_4B, regimen_4C, regimen_4D, regimen_4E, regimen_4F, regimen_4G, regimen_4H,
regimen_4I, regimen_4J, regimen_4K, regimen_4L, regimen_5A, regimen_5B, regimen_5C, regimen_5D, regimen_5E,
regimen_5F, regimen_5G, regimen_5H, regimen_5I, regimen_5J),
// regimens
ACTIVE_REGIMEN_CONCEPT_UUID, txCurrPatients, false);
}

Expand Down

0 comments on commit 19dcc16

Please sign in to comment.