Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
4ca3949
- In Blood Draws Today (All, Animal Care, and Vet Staff), I changed '…
aschmidt34 Jul 11, 2024
cef7f29
Migrated automated test changes from 23.11 to 24.3. 23.11_notificati…
aschmidt34 Jul 18, 2024
6b183f3
Merge branch 'release24.3-SNAPSHOT' into 24.3_fb_notificationRevamps
aschmidt34 Jul 23, 2024
223ac88
Added blood overdraw trigger notification.
aschmidt34 Jul 24, 2024
c51cd23
Registered new notification.
aschmidt34 Jul 25, 2024
503747b
Updated code so message sends when testing/running in browser. Updat…
aschmidt34 Jul 26, 2024
8c02d59
Updated overdraw notification. Notification is now created everytime…
aschmidt34 Jul 31, 2024
1940d47
Fixed issue where 'Animal Replacement Fee' showed incorrectly in the …
aschmidt34 Aug 2, 2024
f43ccc2
Reordered messages in BloodDrawReviewDailyNotification.java so overdr…
aschmidt34 Aug 2, 2024
27e8973
-NotificationToolkit.java: Updated getWeightFromAnimalID() and getSex…
aschmidt34 Aug 8, 2024
8e1c364
Merge branch 'release24.3-SNAPSHOT' into 24.3_fb_notificationRevamps
aschmidt34 Aug 8, 2024
cb1aa1a
Removed automated tests that don't aren't finished.
aschmidt34 Aug 8, 2024
12e34ee
Added 2 new functions to NotificationToolkit for creating URL's. Thi…
aschmidt34 Aug 8, 2024
90a923b
Adding automated tests for notifications.
aschmidt34 Aug 16, 2024
feb43b8
- WNPRC_EHRTest.java: Added notification setup function, multiple not…
aschmidt34 Aug 28, 2024
162b199
- DeathNotificationRevamp.java: Added a null check to make sure class…
aschmidt34 Aug 28, 2024
3c7c099
Merge branch 'release24.3-SNAPSHOT' into 24.3_fb_notificationRevamps
aschmidt34 Aug 29, 2024
06a322d
Added null check before sending blood overdraw trigger manually. The…
aschmidt34 Aug 29, 2024
5394f7d
Moved the automated tests to the end of the list and removed the @Tes…
aschmidt34 Aug 30, 2024
acb6cc7
Disabled site-wide notifications. Also disable individual notificati…
aschmidt34 Aug 30, 2024
2fcd5f1
Re-added 'test' tag before function. Originally removed this because…
aschmidt34 Aug 30, 2024
ecc9f76
Added try/catch for insertValueIntoBloodBilledByDataset due to duplic…
aschmidt34 Sep 3, 2024
44ba184
Added try/catch for remaining functions that insert into datasets.
aschmidt34 Sep 3, 2024
4768468
Changed a query function in checkIfAnimalIsAlive() so it no longer re…
aschmidt34 Sep 3, 2024
22939c7
Removing migrated alerts from ehrcron to Java based notifications
dnicolalde Sep 3, 2024
c311ac0
Merge branch 'release24.3-SNAPSHOT' into 24.3_fb_notificationRevamps
aschmidt34 Sep 4, 2024
051bb94
Added comment to leave commented-out code block alone. This will be …
aschmidt34 Sep 5, 2024
8690123
Removed function call for notification tests in doSetup(). This was …
aschmidt34 Sep 16, 2024
47084a5
- TriggerScriptHelper.java: Added trigger call for new AnimalRequestU…
aschmidt34 Sep 25, 2024
de299ac
- TriggerScriptHelper.java: Added 'sendManually' function call that I…
aschmidt34 Sep 26, 2024
3f95248
Merge branch 'release24.3-SNAPSHOT' into 24.3_fb_notificationRevamps
aschmidt34 Sep 26, 2024
dd4be9e
- animal_requests.js: Added fix for fatal issue with qcstatus being d…
aschmidt34 Oct 7, 2024
21b13c3
Merge branch 'release24.3-SNAPSHOT' into 24.3_fb_notificationRevamps
aschmidt34 Oct 11, 2024
1bc7ea8
- WNPRC_EHRModule.java: Registered new notification.
aschmidt34 Oct 30, 2024
64c61a3
Removed joda time import statement because it was unused.
aschmidt34 Nov 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion WNPRC_EHR/resources/queries/wnprc/animal_requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,24 @@ function onAfterInsert(helper,errors,row){
function onAfterUpdate(helper,errors,row,oldRow){
var rowid = row.rowId;
var hostName = 'https://' + LABKEY.serverName;
console.log ("animal_requests.js: New request updated, rowid: "+ rowid);
console.log("animal_requests.js: New request updated, rowid: "+ rowid);

if ("QCStateLabel" in row) {
delete row.QCState;
row["qcstate"] = row["QCStateLabel"];
delete row.QCStateLabel;
}
if ("QCStateLabel" in oldRow) {
oldRow["qcstate"] = oldRow["QCStateLabel"];
delete oldRow.QCStateLabel;
}

if ("_publicData" in row) {
delete row._publicData;
}
if ("_publicData" in oldRow) {
delete oldRow._publicData;
}

WNPRC.Utils.getJavaHelper().sendAnimalRequestNotificationUpdate(rowid, row, oldRow, hostName);
}
3 changes: 2 additions & 1 deletion WNPRC_EHR/src/org/labkey/wnprc_ehr/WNPRC_EHRModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,8 @@ public void registerNotifications() {
new ColonyAlertsLiteNotificationRevamp(this),
new BloodOverdrawTriggerNotification(this),
new EmptyNotificationRevamp(this),
new AnimalRequestUpdateNotificationRevamp(this)
new AnimalRequestUpdateNotificationRevamp(this),
new TreatmentAlertsNotificationRevamp(this)
);

for (Notification notification : notifications)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,17 @@ public String getMessageBodyHTML(Container c, User u) {

// Prints all tables.
if (myBloodDrawNotificationObject.resultsByArea.isEmpty()) {
messageBody.append("There are no scheduled blood draws for this group today.");
messageBody.append("There are no scheduled blood draws today.");
}
else {
messageBody.append("<p><b>REMAINING INCOMPLETE TOTALS:</b><br>\n");
messageBody.append("Animal Care: " + myBloodDrawNotificationObject.numIncompleteAnimalCare + "</br>\n");
messageBody.append("Research Staff: " + myBloodDrawNotificationObject.numIncompleteResearchStaff + "</br>\n");
messageBody.append("SPI: " + myBloodDrawNotificationObject.numIncompleteSPI + "</br>\n");
messageBody.append("Vet Staff: " + myBloodDrawNotificationObject.numIncompleteVetStaff + "</p>");
messageBody.append(myBloodDrawNotificationObject.printTablesAsHTML());
}

// // Creates table.
// String[] myTableColumns = new String[]{"Id", "Blood Remaining", "Project Assignment", "Completion Status", "Group", "Other Groups Drawing Blood Today"};
// NotificationToolkit.NotificationRevampTable myTable = new NotificationToolkit.NotificationRevampTable(myTableColumns, myBloodDrawNotificationObject.myTableData);
// myTable.rowColors = myBloodDrawNotificationObject.myTableRowColors;
// messageBody.append(myTable.createBasicHTMLTable());

return messageBody.toString();
}

Expand All @@ -105,8 +104,11 @@ public static class BloodDrawsTodayObject {
NotificationToolkit.DateToolkit dateToolkit = new NotificationToolkit.DateToolkit();

ArrayList<String[]> myTableData = new ArrayList<>(); // List of all blood draws as [[id, blood remaining, project assignment, completion status, assigned to]]
// ArrayList<String> myTableRowColors = new ArrayList<>(); // List of all row colors (same length as myTableData).
HashMap<String, HashMap<String, ArrayList<String[]>>> resultsByArea = new HashMap<>(); // Area(Room(List of draws))
Integer numIncompleteSPI = 0;
Integer numIncompleteAnimalCare = 0;
Integer numIncompleteVetStaff = 0;
Integer numIncompleteResearchStaff = 0;


//Gets all info for the BloodDrawNotificationObject.
Expand Down Expand Up @@ -145,31 +147,37 @@ public static class BloodDrawsTodayObject {

// Updates id.
myCurrentRow[0] = result.get("id");

// Updates blood remaining.
myCurrentRow[1] = result.get("BloodRemaining/AvailBlood");

// Updates project status (this checks if animal is assigned to a project).
if (!result.get("qcstate/label").equals("Request: Denied") && !result.get("projectStatus").isEmpty()) {
myCurrentRow[2] = "UNASSIGNED";
}
else {
myCurrentRow[2] = "";
}

// Updates completion status (this checks if blood draw has been completed).
if (!result.get("qcstate/label").equals("Completed")) {
myCurrentRow[3] = "INCOMPLETE";
}
else {
myCurrentRow[3] = "";
}

// Updates the current group assigned to this animal.
myCurrentRow[4] = result.get("billedby/title");

// Updates the current area.
if (!result.get("Id/curLocation/area").isEmpty()) {
myCurrentRow[6] = result.get("Id/curLocation/area");
}
else {
myCurrentRow[6] = "Unknown Area";
}

// Updates the current room.
if (!result.get("Id/curLocation/room").isEmpty()) {
myCurrentRow[7] = result.get("Id/curLocation/room");
Expand All @@ -191,18 +199,6 @@ else if (availBlood <= bloodThreshold) {
myCurrentRow[8] = "orange";
}
}
// String currentRowColor = "white";
// if (!result.get("BloodRemaining/AvailBlood").isEmpty()) {
// Float availBlood = Float.parseFloat(result.get("BloodRemaining/AvailBlood"));
// if (availBlood <= 0) {
// // If blood draw is over limit, color it red.
// currentRowColor = "red";
// }
// else if (availBlood <= bloodThreshold) {
// // If blood draw is over threshold limit, color it orange.
// currentRowColor = "orange";
// }
// }

// Adds the current row to myTableData (based on group being queried).
if (assignmentGroup.equals("animalCare")) {
Expand Down Expand Up @@ -234,6 +230,24 @@ else if (assignmentGroup.equals("vetStaff")) {
myTableData.add(myCurrentRow);
}
}

// Updates number of incomplete draws.
if (assignmentGroup.equals("all")) {
if (myCurrentRow[3].equals("INCOMPLETE")) {
if (result.get("billedby/title").equals("SPI")) {
numIncompleteSPI++;
}
else if (result.get("billedby/title").equals("Animal Care")) {
numIncompleteAnimalCare++;
}
else if (result.get("billedby/title").equals("Research Staff")) {
numIncompleteResearchStaff++;
}
else if (result.get("billedby/title").equals("Vet Staff")) {
numIncompleteVetStaff++;
}
}
}
}

//Goes through each draw to find draws scheduled for more than one group, then updates myTableData with information.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,13 @@ public String getMessageBodyHTML(Container c, User u) {

// Creates table.
if (myBloodDrawNotificationObject.resultsByArea.isEmpty()) {
messageBody.append("There are no scheduled blood draws for this group today.");
notificationToolkit.sendEmptyNotificationRevamp(c, u, "Blood Draws Today (Vet Staff)");
return null;
}
else {
messageBody.append(myBloodDrawNotificationObject.printTablesAsHTML());
return messageBody.toString();
}

// String[] myTableColumns = new String[]{"Id", "Blood Remaining", "Project Assignment", "Completion Status", "Group", "Other Groups Drawing Blood Today"};
// NotificationToolkit.NotificationRevampTable myTable = new NotificationToolkit.NotificationRevampTable(myTableColumns, myBloodDrawNotificationObject.myTableData);
// myTable.rowColors = myBloodDrawNotificationObject.myTableRowColors;
// messageBody.append(myTable.createBasicHTMLTable());

return messageBody.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import java.sql.ResultSet;

import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
Expand All @@ -41,6 +43,8 @@

import javax.script.ScriptEngine;

import static org.labkey.api.search.SearchService._log;


/**
* Created by Alex Schmidt on 12/27/23.
Expand Down Expand Up @@ -97,6 +101,12 @@ public String getMessageBodyHTML(Container c, User u) {
final StringBuilder messageBody = new StringBuilder();
ColonyInformationObject myColonyAlertObject = new ColonyInformationObject(c, u, "colonyAlert");

// Creates CSS.
messageBody.append(styleToolkit.beginStyle());
messageBody.append(styleToolkit.setBasicTableStyle());
messageBody.append(styleToolkit.setHeaderRowBackgroundColor("#d9d9d9"));
messageBody.append(styleToolkit.endStyle());

//Begins message info.
messageBody.append("<p> This email contains a series of automatic alerts about the colony. It was run on: " + dateToolkit.getCurrentTime() + ".</p>");

Expand Down Expand Up @@ -373,6 +383,19 @@ public String getMessageBodyHTML(Container c, User u) {
messageBody.append(notificationToolkit.createHyperlink("<p>Click here to view them<br>\n", myColonyAlertObject.totalFinalizedRecordsWithFutureDatesURLView));
messageBody.append("<hr>\n");
}
//38. Find any animals assigned to an inactivated project or deactivated protocol.
if (!myColonyAlertObject.animalsWithInvalidProjectOrProtocol.isEmpty()) {
// Creates HTML table to return.
String[] myTableColumns = new String[]{"Id", "Project", "Project End Date", "Protocol", "Protocol End Date"};
NotificationToolkit.NotificationRevampTable myTable = new NotificationToolkit.NotificationRevampTable(myTableColumns, myColonyAlertObject.animalsWithInvalidProjectOrProtocol);

// Displays message.
messageBody.append("<b>WARNING: There are " + myColonyAlertObject.animalsWithInvalidProjectOrProtocol.size() + " living animals with inactivated projects or deactivated protocols.</b><br>");
messageBody.append(myTable.createBasicHTMLTable());
messageBody.append(notificationToolkit.createHyperlink("<p>Click here to view all Assignments.<br>\n", myColonyAlertObject.animalsWithInvalidProjectOrProtocolURLView));
messageBody.append("<hr>\n");

}

//Returns string.
return messageBody.toString();
Expand Down Expand Up @@ -469,6 +492,8 @@ public ColonyInformationObject(Container currentContainer, User currentUser, Str
getPrenatalDeathsInLastFiveDays();
//37. Find the total finalized records with future dates.
getTotalFinalizedRecordsWithFutureDates();
//38. Find any animals assigned to an inactivated project or deactivated protocol.
getAnimalsWithInvalidProjectOrProtocol();
}
else if (alertType.equals("colonyManagement")) {
// 1. Find all living animals without a weight.
Expand Down Expand Up @@ -1356,6 +1381,83 @@ private void getProtocolsNearingAnimalLimitPercentage() {
this.protocolsNearingAnimalLimitPercentage = returnArray;
this.protocolsNearingAnimalLimitPercentageURLView = viewQueryURL;
}

// Find any animals assigned to an inactivated project or deactivated protocol.
ArrayList<String[]> animalsWithInvalidProjectOrProtocol = new ArrayList<>(); //
String animalsWithInvalidProjectOrProtocolURLView;
private void getAnimalsWithInvalidProjectOrProtocol() {
// Creates filter.
SimpleFilter myFilter = new SimpleFilter("Id/Dataset/Demographics/calculated_status", "Alive", CompareType.EQUAL);
// myFilter.addCondition("project/protocol", "", CompareType.NONBLANK);
// Gets columns to retrieve.
String[] targetColumns = new String[]{"id", "project", "project/protocol", "project/enddate", "project/protocol/enddate"};
// Runs query.
ArrayList<HashMap<String, String>> returnArray = notificationToolkit.getTableMultiRowMultiColumnWithFieldKeys(c, u, "study", "Assignment", myFilter, null, targetColumns);

// Sets up a Try/Catch block to catch date parsing errors.
try {
// Sets variables.
SimpleDateFormat myFormat = new SimpleDateFormat("yyyy-MM-dd");
Date formattedCurrentDate = myFormat.parse(dateToolkit.getCurrentTime());

for (HashMap<String, String> result : returnArray) {
// 0: ID
// 1: Project
// 2: Project End Date
// 3: Protocol
// 4: Protocol End Date
String[] myCurrentRow = new String[5];
myCurrentRow[1] = "";
myCurrentRow[2] = "";
myCurrentRow[3] = "";
myCurrentRow[4] = "";

// Retrieves row data.
String currentID = result.get("id");
String currentProject = result.get("project");
String currentProtocol = result.get("project/protocol");
String currentProjectEnd = result.get("project/enddate");
String currentProtocolEnd = result.get("project/protocol/enddate");
Boolean projectOrProtocolExpired = false;

// Adds id.
myCurrentRow[0] = currentID;
// Checks project.
if (currentProject != null && currentProjectEnd != null) {
if (!currentProject.isEmpty() && !currentProjectEnd.isEmpty()) {
Date formattedProjectEnd = myFormat.parse(currentProjectEnd);
if (formattedCurrentDate.compareTo(formattedProjectEnd) > 0) {
myCurrentRow[1] = currentProject;
myCurrentRow[2] = currentProjectEnd;
projectOrProtocolExpired = true;
}
}
}
// Checks protocol.
if (currentProtocol != null && currentProtocolEnd != null) {
if (!currentProtocol.isEmpty() && !currentProtocolEnd.isEmpty()) {
Date formattedProtocolEnd = myFormat.parse(currentProtocolEnd);
if (formattedCurrentDate.compareTo(formattedProtocolEnd) > 0) {
myCurrentRow[3] = currentProtocol;
myCurrentRow[4] = currentProtocolEnd;
projectOrProtocolExpired = true;
}
}
}

// Adds row to return list if there is an expired project or protocol.
if (projectOrProtocolExpired) {
animalsWithInvalidProjectOrProtocol.add(myCurrentRow);
}
}
}
catch (ParseException e) {
_log.error("There was a parsing exception for: ColonyAlertsNotificationRevamp->getAnimalsWithInvalidProjectOrProtocol", e);
}

// Creates url link to the assignments table.
this.animalsWithInvalidProjectOrProtocolURLView = notificationToolkit.createQueryURL(c, "execute", "study", "Assignment", null);
}
}
}

Loading