diff --git a/WNPRC_EHR/src/org/labkey/wnprc_ehr/notification/ClinpathAbnormalResultsAlertsRevamp.java b/WNPRC_EHR/src/org/labkey/wnprc_ehr/notification/ClinpathAbnormalResultsAlertsRevamp.java index 907663c8b..e9d00279e 100644 --- a/WNPRC_EHR/src/org/labkey/wnprc_ehr/notification/ClinpathAbnormalResultsAlertsRevamp.java +++ b/WNPRC_EHR/src/org/labkey/wnprc_ehr/notification/ClinpathAbnormalResultsAlertsRevamp.java @@ -88,9 +88,9 @@ public String getMessageBodyHTML(Container c, User u) { // Creates filter. SimpleFilter myFilter = new SimpleFilter("qcstate/PublicData", true, CompareType.EQUAL); - myFilter.addCondition("taskid/datecompleted", lastRunDate, CompareType.DATE_GTE); + myFilter.addCondition("taskid/datecompleted", lastRunDate, CompareType.GTE); myFilter.addCondition("taskid/datecompleted", "", CompareType.NONBLANK); - myFilter.addCondition("date", lastRunMinusWeek, CompareType.DATE_GTE); + myFilter.addCondition("date", lastRunMinusWeek, CompareType.GTE); // Creates columns to retrieve. String[] targetColumns = new String[]{"Id", "date", "Id/curLocation/area", "Id/curLocation/room", "Id/curLocation/cage", "alertStatus", "taskid/datecompleted", "testid", "result", "units", "status", "ref_range_min", "ref_range_max", "ageAtTime"}; // Runs query. @@ -102,52 +102,54 @@ public String getMessageBodyHTML(Container c, User u) { for (HashMap result : returnArray) { // Verifies 'alert status' exists before adding results. if (!result.get("alertStatus").isEmpty()) { - // Updates current location. - if (result.get("Id/curLocation/area").isEmpty()) { - result.put("Id/curLocation/area", "No Active Housing"); - } - // Updates current room. - if (result.get("Id/curLocation/room").isEmpty()) { - result.put("Id/curLocation/room", "No Room"); - } + if (result.get("alertStatus").equals("t")) { + // Updates current location. + if (result.get("Id/curLocation/area").isEmpty()) { + result.put("Id/curLocation/area", "No Active Housing"); + } + // Updates current room. + if (result.get("Id/curLocation/room").isEmpty()) { + result.put("Id/curLocation/room", "No Room"); + } - // Adds to list if area does not exist yet. - if (!filteredResults.containsKey(result.get("Id/curLocation/area"))) { - // Creates new room results list. - ArrayList> newRoomList = new ArrayList<>(); - newRoomList.add(result); - // Creates new room map. - HashMap>> newRoom = new HashMap<>(); - newRoom.put(result.get("Id/curLocation/room"), newRoomList); - // Creates new area map and adds to the filtered results. - filteredResults.put(result.get("Id/curLocation/area"), newRoom); - } - // Adds to list if room does not exist yet. - else if (!filteredResults.get(result.get("Id/curLocation/area")).containsKey(result.get("Id/curLocation/room"))) { - // Creates new room results list. - ArrayList> newRoomList = new ArrayList<>(); - newRoomList.add(result); - // Creates new room map and adds to the areas list. - filteredResults.get(result.get("Id/curLocation/area")).put(result.get("Id/curLocation/room"), newRoomList); - } - // Adds to list if area and room exist already. - else { - filteredResults.get(result.get("Id/curLocation/area")).get(result.get("Id/curLocation/room")).add(result); + // Adds to list if area does not exist yet. + if (!filteredResults.containsKey(result.get("Id/curLocation/area"))) { + // Creates new room results list. + ArrayList> newRoomList = new ArrayList<>(); + newRoomList.add(result); + // Creates new room map. + HashMap>> newRoom = new HashMap<>(); + newRoom.put(result.get("Id/curLocation/room"), newRoomList); + // Creates new area map and adds to the filtered results. + filteredResults.put(result.get("Id/curLocation/area"), newRoom); + } + // Adds to list if room does not exist yet. + else if (!filteredResults.get(result.get("Id/curLocation/area")).containsKey(result.get("Id/curLocation/room"))) { + // Creates new room results list. + ArrayList> newRoomList = new ArrayList<>(); + newRoomList.add(result); + // Creates new room map and adds to the areas list. + filteredResults.get(result.get("Id/curLocation/area")).put(result.get("Id/curLocation/room"), newRoomList); + } + // Adds to list if area and room exist already. + else { + filteredResults.get(result.get("Id/curLocation/area")).get(result.get("Id/curLocation/room")).add(result); + } } } } // Prints text. messageBody.append("There have been " + returnArray.size() + " clinpath tasks completed since " + lastRunDate + "
"); - messageBody.append(notificationToolkit.createHyperlink("Click here to view them", clinpathTasksUrlView) + "

\n"); - messageBody.append("

Listed below are the abnormal records.

\n"); + messageBody.append(notificationToolkit.createHyperlink("Click here to view them", clinpathTasksUrlView) + "

\n"); + messageBody.append("

Listed below are the abnormal records.
\n"); // Prints table with all records. String[] tableColumns = new String[]{"Id", "Collect Date", "Date Completed", "Test ID", "Result", "Units", "Status", "Ref Range Min", "Ref Range Max", "Age At Time"}; for (String currentArea : notificationToolkit.sortSetWithNulls(filteredResults.keySet())) { - messageBody.append("" + currentArea + ":
\n"); + messageBody.append("
\n" + currentArea + ":
\n"); for (String currentRoom : notificationToolkit.sortSetWithNulls(filteredResults.get(currentArea).keySet())) { - messageBody.append(currentRoom + ":
\n"); + messageBody.append("
\n" + currentRoom + ":\n"); // Reformats the hashmap into a String[] List (to be compatible with the table creation function). ArrayList currentTableData = new ArrayList<>(); ArrayList rowColorsList = new ArrayList<>(); diff --git a/WNPRC_EHR/src/org/labkey/wnprc_ehr/notification/ClinpathAlertsRevamp.java b/WNPRC_EHR/src/org/labkey/wnprc_ehr/notification/ClinpathAlertsRevamp.java index 04326efc5..a1927bf85 100644 --- a/WNPRC_EHR/src/org/labkey/wnprc_ehr/notification/ClinpathAlertsRevamp.java +++ b/WNPRC_EHR/src/org/labkey/wnprc_ehr/notification/ClinpathAlertsRevamp.java @@ -131,7 +131,7 @@ public ClinpathAlertsObject(Container currentContainer, User currentUser, Date l private void getRecordsRequestedSinceLastEmail() { // Creates filter. SimpleFilter myFilter = new SimpleFilter("qcstate/label", "Request: Pending", CompareType.EQUAL); - myFilter.addCondition("created", dateLastRun, CompareType.DATE_GTE); + myFilter.addCondition("created", dateLastRun, CompareType.GTE); // Creates columns to retrieve. String[] targetColumns = new String[]{"created"}; // Runs query. diff --git a/WNPRC_EHR/src/org/labkey/wnprc_ehr/notification/ClinpathResultAlertsRevamp.java b/WNPRC_EHR/src/org/labkey/wnprc_ehr/notification/ClinpathResultAlertsRevamp.java index 97dea6e8f..8bee3df8d 100644 --- a/WNPRC_EHR/src/org/labkey/wnprc_ehr/notification/ClinpathResultAlertsRevamp.java +++ b/WNPRC_EHR/src/org/labkey/wnprc_ehr/notification/ClinpathResultAlertsRevamp.java @@ -149,9 +149,9 @@ else if (!filteredResults.get(result.get("Id/curLocation/area")).containsKey(res // Creates a table from the data. String[] tableColumns = new String[]{"Id", "Collect Date", "Service Requested", "Requestor", "Date Reviewed", "Reviewed By"}; for (String currentArea : notificationToolkit.sortSetWithNulls(filteredResults.keySet())) { - messageBody.append("" + currentArea + ":
\n"); + messageBody.append("
\n" + currentArea + ":
\n"); for (String currentRoom : notificationToolkit.sortSetWithNulls(filteredResults.get(currentArea).keySet())) { - messageBody.append(currentRoom + ":
\n"); + messageBody.append("
\n" + currentRoom + ":\n"); // Reformats the hashmap into a String[] List (to be compatible with the table creation function). ArrayList currentTableData = new ArrayList<>(); ArrayList rowColorsList = new ArrayList<>(); diff --git a/WNPRC_EHR/src/org/labkey/wnprc_ehr/notification/TreatmentAlertsNotificationRevamp.java b/WNPRC_EHR/src/org/labkey/wnprc_ehr/notification/TreatmentAlertsNotificationRevamp.java index 13412570a..a177fde7d 100644 --- a/WNPRC_EHR/src/org/labkey/wnprc_ehr/notification/TreatmentAlertsNotificationRevamp.java +++ b/WNPRC_EHR/src/org/labkey/wnprc_ehr/notification/TreatmentAlertsNotificationRevamp.java @@ -85,7 +85,7 @@ public String getMessageBodyHTML(Container c, User u) { // 1. Shows all rooms lacking observations today. if (!myTreatmentAlertsObject.roomsLackingObservationsToday.isEmpty()) { messageBody.append("WARNING: The following rooms do not have any obs for today as of: " + dateToolkit.getCurrentTime() + "."); - messageBody.append("" + notificationToolkit.createHyperlink("Click here to view them.

\n", myTreatmentAlertsObject.roomsLackingObservationsTodayUrlView)); + messageBody.append("" + notificationToolkit.createHyperlink(" Click here to view them.

\n", myTreatmentAlertsObject.roomsLackingObservationsTodayUrlView)); for (HashMap result : myTreatmentAlertsObject.roomsLackingObservationsToday) { messageBody.append(result.get("room") + "
"); } @@ -94,7 +94,7 @@ public String getMessageBodyHTML(Container c, User u) { // 2. Shows all treatments where the animal is not assigned to that project. if (!myTreatmentAlertsObject.treatmentsWithAnimalNotAssignedToProject.isEmpty()) { messageBody.append("WARNING: There are " + myTreatmentAlertsObject.treatmentsWithAnimalNotAssignedToProject.size() + " scheduled treatments where the animal is not assigned to the project.

"); - messageBody.append("" + notificationToolkit.createHyperlink("Click here to view them.
\n", myTreatmentAlertsObject.treatmentsWithAnimalNotAssignedToProjectUrlView)); + messageBody.append("" + notificationToolkit.createHyperlink(" Click here to view them.
\n", myTreatmentAlertsObject.treatmentsWithAnimalNotAssignedToProjectUrlView)); messageBody.append("


\n"); } // 3. Shows treatments for each time of day. @@ -106,7 +106,7 @@ public String getMessageBodyHTML(Container c, User u) { Integer totalTreatments = myTreatmentAlertsObject.incompleteTreatmentsForEachTimeOfDay.get(timeOfDay).size() + myTreatmentAlertsObject.completedTreatmentCountsForEachTimeOfDay.get(timeOfDay); if (totalTreatments > 0) { messageBody.append("There are " + totalTreatments + " scheduled " + timeOfDay + " treatments. " + myTreatmentAlertsObject.completedTreatmentCountsForEachTimeOfDay.get(timeOfDay) + " have been completed. "); - messageBody.append("" + notificationToolkit.createHyperlink("Click here to view them.

\n", myTreatmentAlertsObject.treatmentsForEachTimeOfDayUrlView.get(timeOfDay))); + messageBody.append("" + notificationToolkit.createHyperlink("Click here to view them.
\n", myTreatmentAlertsObject.treatmentsForEachTimeOfDayUrlView.get(timeOfDay))); // Creates the current timeOfDay results sorted by (area --> room --> result). HashMap>>> resultsByArea = new HashMap<>(); @@ -141,10 +141,10 @@ else if (!resultsByArea.get(currentArea).containsKey(currentRoom)) { // Iterates through each area (sorted alphabetically). for (String currentArea : notificationToolkit.sortSetWithNulls(resultsByArea.keySet())) { - messageBody.append("" + currentArea + ":
\n"); + messageBody.append("
\n" + currentArea + ":
\n"); // Iterates through each room (sorted alphabetically) for (String currentRoom : notificationToolkit.sortSetWithNulls(resultsByArea.get(currentArea).keySet())) { - messageBody.append(currentRoom + ": " + resultsByArea.get(currentArea).get(currentRoom).size() + "
\n"); + messageBody.append("
\n" + currentRoom + ": " + resultsByArea.get(currentArea).get(currentRoom).size() + "\n"); // Reformats the treatment hashmap into a String[] List (to be compatible with the table creation function). ArrayList formattedResults = new ArrayList<>(); for (HashMap currentTreatment : resultsByArea.get(currentArea).get(currentRoom)) { @@ -188,13 +188,13 @@ else if (!resultsByArea.get(currentArea).containsKey(currentRoom)) { // 5. Shows any treatments where the animal is not alive. if (!myTreatmentAlertsObject.treatmentsWhereAnimalIsNotAlive.isEmpty()) { messageBody.append("WARNING: There are " + myTreatmentAlertsObject.treatmentsWhereAnimalIsNotAlive.size() + " active treatments for animals not currently at WNPRC."); - messageBody.append("" + notificationToolkit.createHyperlink("Click here to view and update them.
\n", myTreatmentAlertsObject.treatmentsWhereAnimalIsNotAliveURLView)); + messageBody.append("" + notificationToolkit.createHyperlink(" Click here to view and update them.
\n", myTreatmentAlertsObject.treatmentsWhereAnimalIsNotAliveURLView)); messageBody.append("
\n"); } // 6. Find any problems where the animal is not alive. if (!myTreatmentAlertsObject.problemsWhereAnimalIsNotAlive.isEmpty()) { messageBody.append("WARNING: There are " + myTreatmentAlertsObject.problemsWhereAnimalIsNotAlive.size() + " unresolved problems for animals not currently at WNPRC."); - messageBody.append("" + notificationToolkit.createHyperlink("Click here to view and update them.
\n", myTreatmentAlertsObject.problemsWhereAnimalIsNotAliveUrlView)); + messageBody.append("" + notificationToolkit.createHyperlink(" Click here to view and update them.
\n", myTreatmentAlertsObject.problemsWhereAnimalIsNotAliveUrlView)); messageBody.append("
\n"); } // 7. Checks for missing In Rooms after 2:30pm, as specified in the SOP.