Skip to content

Commit 753fb88

Browse files
aschmidt34csebraneklabkey-martyp
authored
24.11 fb notification revamps (#771)
* Update TeamCity installer URL for docker hub * Update labkey npm dependencies and rehyrdate package-lock.json * explicitly add children as a type * remove placeholder in purchasing module, update react for wnprc_ehr, 16 was causing build issues with @testing-library - perhaps from @labkey/components incompatibility * update to react 18 for virology module, update build script for dockerhub * update react types, update deprecated ReactDOM.render * add test for breeding page * Add notifications provider * - Added new OverdueWeightAlertsRevamp notification. - Registered this new notification in WNPRC_EHRModule.java. * - WNPRC_EHRModule.java: Registered new notification. - ClinpathAbnormalResultsAlertsRevamp.java: Updated CompareTypes to support exact timestamp. - ClinpathAlertsRevamp.java: Updated CompareTypes to support exact timestamp. - OverdueWeightAlertsRevamp.java: Updated CRON times. - SiteErrorAlertsRevamp.java: Created new revamped notification. * Added a space so I can attempt to re-push. * Updated trigger for BloodOverdrawTriggerNotification so it only sends when blood draw is a completed draw. * -WeightAlertsRevamp.java: Created new revamped notification. -WNPRC_EHRModule.java: Registered new notification. * Updated build.gradle, re-pushing for dockerhub. * Updated IJ & build.gradle to fix DockerHub issue. * - Added all automated tests for new notification revamps. - Added a few reusable automated test functions in ReusableTestFunctions class. - Fixed Animal Request Update so no message is sent if there is no data available. * Added documentation for the NotificationRevampTable class in NotificationToolkit.java. * Updated Colony Alerts Notification Revamp with changes requested via ticket 19668. * Muted 4 automated tests that fail due to datasets not being created. I need to manually create the dataset for Colony Alerts, otherwise I opened a ticket with LabKey to see why the other datasets are not being created. --------- Co-authored-by: Chad Sebranek <csebranek@gmail.com> Co-authored-by: Marty Pradere <martyp@labkey.com>
1 parent 92e8993 commit 753fb88

10 files changed

Lines changed: 1270 additions & 294 deletions

File tree

WNPRC_EHR/resources/scripts/wnprc_ehr/wnprc_triggers.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,9 @@ exports.init = function (EHR) {
630630
WNPRC.Utils.getJavaHelper().sendBloodDrawReviewNotification(row.Id, row.project, row.date, row.requestor);
631631
}
632632
// Triggers wnprc_triggers.js to send BloodOverdrawTriggerNotification.java.
633-
WNPRC.Utils.getJavaHelper().sendBloodOverdrawTriggerNotification(row.Id, row.date);
633+
if (row.QCStateLabel === 'Completed') {
634+
WNPRC.Utils.getJavaHelper().sendBloodOverdrawTriggerNotification(row.Id, row.date);
635+
}
634636
})
635637

636638
function getHousingSQL(row) {

WNPRC_EHR/src/org/labkey/wnprc_ehr/WNPRC_EHRModule.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,10 @@ public void registerNotifications() {
397397
new ClinpathAbnormalResultsAlertsRevamp(this),
398398
new ClinpathAlertsRevamp(this),
399399
new ClinpathResultAlertsRevamp(this),
400-
new LargeInfantAlertsRevamp(this)
400+
new LargeInfantAlertsRevamp(this),
401+
new OverdueWeightAlertsRevamp(this),
402+
new SiteErrorAlertsRevamp(this),
403+
new WeightAlertsRevamp(this)
401404
);
402405

403406
for (Notification notification : notifications)

WNPRC_EHR/src/org/labkey/wnprc_ehr/notification/AnimalRequestUpdateNotificationRevamp.java

Lines changed: 58 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ public void sendManually (Container container, User user)
101101
@Override
102102
public String getMessageBodyHTML(Container c, User u)
103103
{
104+
Boolean hasData = true;
104105
// Assigns data if none exists. This is used for testing with the 'Run Report in Browser' option. This compares the two most recent rows.
105106
if ((this.newRow == null) || (this.oldRow == null)) {
106107
// Creates filters. For testing, we retrieve the most recent entry for 1 animal, and the most recent entry for 2 animals.
@@ -127,59 +128,69 @@ public String getMessageBodyHTML(Container c, User u)
127128
put("numberOfAnimals", returnArray2.get(0).get("numberofanimals"));
128129
}};
129130
}
131+
else {
132+
hasData = false;
133+
}
130134
}
131135

132-
//Creates 'single request' URL.
133-
Path singleRequestURL = new Path(ActionURL.getBaseServerURL(), "ehr", c.getPath(), "");
134-
String singleRequestUrlAsString = singleRequestURL.toString() + "manageRecord.view?schemaName=wnprc&queryName=animal_requests&title=Animal%20Requests&keyField=rowid&key=" + this.rowID;
135-
//Creates 'all requests' URL.
136-
Path allRequestsURL = new Path(ActionURL.getBaseServerURL(), "ehr", c.getPath(), "");
137-
String allRequestsUrlAsString = allRequestsURL.toString() + "dataEntry.view?#topTab:Requests&activeReport:AnimalRequests\"";
138-
139-
// Creates variables.
140-
final StringBuilder msg = new StringBuilder();
141-
String updaterName = "";
142-
// Gets the name of the user updating this Animal Request.
143-
if (u != null) {
144-
if (!u.getFullName().isEmpty()) {
145-
updaterName = u.getFullName();
136+
if (hasData) {
137+
//Creates 'single request' URL.
138+
Path singleRequestURL = new Path(ActionURL.getBaseServerURL(), "ehr", c.getPath(), "");
139+
String singleRequestUrlAsString = singleRequestURL.toString() + "manageRecord.view?schemaName=wnprc&queryName=animal_requests&title=Animal%20Requests&keyField=rowid&key=" + this.rowID;
140+
//Creates 'all requests' URL.
141+
Path allRequestsURL = new Path(ActionURL.getBaseServerURL(), "ehr", c.getPath(), "");
142+
String allRequestsUrlAsString = allRequestsURL.toString() + "dataEntry.view?#topTab:Requests&activeReport:AnimalRequests\"";
143+
144+
// Creates variables.
145+
final StringBuilder msg = new StringBuilder();
146+
String updaterName = "";
147+
// Gets the name of the user updating this Animal Request.
148+
if (u != null) {
149+
if (!u.getFullName().isEmpty()) {
150+
updaterName = u.getFullName();
151+
}
152+
else if (!u.getDisplayName(u).isEmpty()) {
153+
updaterName = u.getDisplayName(u);
154+
}
146155
}
147-
else if (!u.getDisplayName(u).isEmpty()) {
148-
updaterName = u.getDisplayName(u);
156+
// Gets the row differences.
157+
TableInfo rowDifferencesTable = QueryService.get().getUserSchema(u, c, "wnprc").getTable("animal_requests");
158+
Map<String, ArrayList<String>> rowDifferences = TriggerScriptHelper.buildDifferencesMap(rowDifferencesTable, this.oldRow, this.newRow);
159+
// Gets the table.
160+
String[] myTableColumns = new String[]{"Field Changed", "Old Value", "New Value"};
161+
List<String[]> myTableData = new ArrayList<>();
162+
for (Map.Entry<String, ArrayList<String>> change : rowDifferences.entrySet()) {
163+
String[] newTableRow = new String[] {
164+
change.getKey(),
165+
change.getValue().get(0),
166+
change.getValue().get(1)
167+
};
168+
myTableData.add(newTableRow);
149169
}
170+
NotificationToolkit.NotificationRevampTable myTable = new NotificationToolkit.NotificationRevampTable(myTableColumns, (ArrayList<String[]>) myTableData);
171+
172+
// Creates CSS.
173+
msg.append(styleToolkit.beginStyle());
174+
msg.append(styleToolkit.setBasicTableStyle());
175+
msg.append(styleToolkit.setHeaderRowBackgroundColor("#d9d9d9"));
176+
msg.append(styleToolkit.endStyle());
177+
178+
// Begins message info.
179+
msg.append("<p>" + updaterName + " updated an animal request entry on: " + dateToolkit.getDateXDaysFromNow(0) + ".</p>");
180+
msg.append("<p> The following changes were made: <br><br>");
181+
msg.append(myTable.createBasicHTMLTable());
182+
msg.append("<p>Click " + notificationToolkit.createHyperlink("here", singleRequestUrlAsString) + " to review the request.</p>");
183+
msg.append("<p>View all of the animal requests " + notificationToolkit.createHyperlink("here", allRequestsUrlAsString) + ".</p>");
184+
185+
//Returns string.
186+
this.resetClass();
187+
return msg.toString();
150188
}
151-
// Gets the row differences.
152-
TableInfo rowDifferencesTable = QueryService.get().getUserSchema(u, c, "wnprc").getTable("animal_requests");
153-
Map<String, ArrayList<String>> rowDifferences = TriggerScriptHelper.buildDifferencesMap(rowDifferencesTable, this.oldRow, this.newRow);
154-
// Gets the table.
155-
String[] myTableColumns = new String[]{"Field Changed", "Old Value", "New Value"};
156-
List<String[]> myTableData = new ArrayList<>();
157-
for (Map.Entry<String, ArrayList<String>> change : rowDifferences.entrySet()) {
158-
String[] newTableRow = new String[] {
159-
change.getKey(),
160-
change.getValue().get(0),
161-
change.getValue().get(1)
162-
};
163-
myTableData.add(newTableRow);
189+
else {
190+
//Returns nothing if there is no data.
191+
this.resetClass();
192+
return null;
164193
}
165-
NotificationToolkit.NotificationRevampTable myTable = new NotificationToolkit.NotificationRevampTable(myTableColumns, (ArrayList<String[]>) myTableData);
166-
167-
// Creates CSS.
168-
msg.append(styleToolkit.beginStyle());
169-
msg.append(styleToolkit.setBasicTableStyle());
170-
msg.append(styleToolkit.setHeaderRowBackgroundColor("#d9d9d9"));
171-
msg.append(styleToolkit.endStyle());
172-
173-
// Begins message info.
174-
msg.append("<p>" + updaterName + " updated an animal request entry on: " + dateToolkit.getDateXDaysFromNow(0) + ".</p>");
175-
msg.append("<p> The following changes were made: <br><br>");
176-
msg.append(myTable.createBasicHTMLTable());
177-
msg.append("<p>Click " + notificationToolkit.createHyperlink("here", singleRequestUrlAsString) + " to review the request.</p>");
178-
msg.append("<p>View all of the animal requests " + notificationToolkit.createHyperlink("here", allRequestsUrlAsString) + ".</p>");
179-
180-
//Returns string.
181-
this.resetClass();
182-
return msg.toString();
183194
}
184195

185196
public void resetClass() {

0 commit comments

Comments
 (0)