> 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.
diff --git a/WNPRC_EHR/test/src/org/labkey/test/tests/wnprc_ehr/WNPRC_EHRTest.java b/WNPRC_EHR/test/src/org/labkey/test/tests/wnprc_ehr/WNPRC_EHRTest.java
index 152886b6e..f0b114751 100644
--- a/WNPRC_EHR/test/src/org/labkey/test/tests/wnprc_ehr/WNPRC_EHRTest.java
+++ b/WNPRC_EHR/test/src/org/labkey/test/tests/wnprc_ehr/WNPRC_EHRTest.java
@@ -3700,6 +3700,105 @@ public void testBloodDrawAPI() throws Exception
*/
}
+
+ // Note: there is one flaw with this test below w.r.t the dates.
+ // the idea is to test two dates within the same day under a couple constraints,
+ // one is there can be no blood requests in the past, and another is it can only go up to 60 days into the future,
+ // so setting a date in the distant past or future is not possible, so we have to do a dynamic date using
+ // new Date() and offsetting the hours. If the first date happens to run within an hour before midnight, this test will fail.
+ @Test
+ public void testBloodDrawDoubleScheduleWarning() throws Exception
+ {
+ goToProjectHome();
+ ReusableTestFunctions myReusableFunctions = new ReusableTestFunctions();
+
+ Integer numTubes = 1;
+ String tubeType = "EDTA";
+ Integer project = 640991;
+ String account = "acct102";
+ Double tubeVolOK = 1.0;
+ Double quantityOK = tubeVolOK * numTubes;
+ InsertRowsCommand bloodCmd = new InsertRowsCommand("study", "blood");
+ Date dt = prepareDate(new Date(), 10, 0);
+ Integer requestPending = myReusableFunctions.getQCStateRowID("Request: Pending");
+ Integer scheduled = myReusableFunctions.getQCStateRowID("Scheduled");
+
+
+ bloodCmd.addRow(new HashMap()
+ {
+ {
+ put("Id", TEST_SUBJECTS[0]);
+ put("date", dt);
+ put("project", project);
+ put("account", account);
+ put("tube_type", tubeType);
+ put("tube_vol", tubeVolOK);
+ put("num_tubes", numTubes);
+ put("quantity", quantityOK);
+ put("additionalServices", null);
+ put("restraint", "Chemical");
+ put("restraintDuration", "< 30 min");
+ put("instructions", "test special instruction");
+ put("remark", "test remark");
+ put("performedby", "autotest");
+ put("QCState", requestPending);
+
+ }
+ });
+ Date d2 = prepareDate(new Date(), 10, 1);
+ bloodCmd.addRow(new HashMap()
+ {
+ {
+ put("Id", TEST_SUBJECTS[0]);
+ put("date", d2);
+ put("project", project);
+ put("account", account);
+ put("tube_type", tubeType);
+ put("tube_vol", tubeVolOK);
+ put("num_tubes", numTubes);
+ put("quantity", quantityOK);
+ put("additionalServices", null);
+ put("restraint", "Chemical");
+ put("restraintDuration", "< 30 min");
+ put("instructions", "test special instruction");
+ put("remark", "test remark");
+ put("performedby", "autotest");
+ put("QCState", scheduled);
+
+ }
+ });
+ bloodCmd.execute(getApiHelper().getConnection(), getContainerPath());
+
+ SelectRowsCommand sr = new SelectRowsCommand("study","blood");
+ sr.addFilter("Id", TEST_SUBJECTS[0], Filter.Operator.EQUAL);
+ sr.addFilter("date", dt, Filter.Operator.EQUAL);
+ SelectRowsResponse resp2 = sr.execute(getApiHelper().getConnection(), EHR_FOLDER_PATH);
+ Assert.assertEquals(1, resp2.getRowCount());
+ Assert.assertEquals(requestPending, resp2.getRows().get(0).get("QCState"));
+
+
+ //approve some draws
+ goToEHRFolder();
+ waitAndClickAndWait(Locator.linkWithText("Enter Data"));
+ waitAndClick(Locator.linkWithText("Blood Draw Requests"));
+ //clickBootstrapTab("Blood Draw Requests");
+ waitForText(TEST_SUBJECTS[0]);
+
+ WebElement parentDiv = getDriver().findElement(By.cssSelector("div[id*='lk-gen'][class='tab-pane active']"));
+
+ // Locate the form element within the parent div
+ WebElement formElement = parentDiv.findElement(By.xpath(".//form[contains(@id, 'lk-region-')]"));
+
+ // Get the value of the "lk-region-form" attribute
+ String formAttribute = formElement.getAttribute("lk-region-form");
+ DataRegionTable dataRegionTable = new DataRegionTable.DataRegionFinder(getDriver()).withName(formAttribute).find();
+
+ dataRegionTable.checkCheckbox(0);
+
+ dataRegionTable.clickHeaderMenu("More Actions", false, "Change Request Status");
+ waitForText(TEST_SUBJECTS[0] + " has 2 draws on the same day but at different times");
+ assertTextPresent(TEST_SUBJECTS[0] + " has 2 draws on the same day but at different times");
+ }
protected String generateGUID()
{
return (String)executeScript("return LABKEY.Utils.generateUUID().toUpperCase()");