Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 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
7c46f29
ClinpathRefRange.sql - Added units column to table for data retrieval…
aschmidt34 Nov 25, 2024
5cde29b
ClinpathResultAlertsRevamp.java: Created new revamp notification.
aschmidt34 Dec 4, 2024
d54449e
LargeInfantAlertsRevamp.java: Created new revamped notification.
aschmidt34 Dec 10, 2024
6591ce4
ClinpathAbnormalResultsAlertsRevamp.java: Fixed text display, typos, …
aschmidt34 Dec 12, 2024
b2ffe03
Merge branch 'release24.3-SNAPSHOT' into 24.3_fb_notificationRevamps
aschmidt34 Dec 13, 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
4 changes: 4 additions & 0 deletions WNPRC_EHR/resources/queries/study/ClinpathRefRange.sql
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ c.taskid,
c.qcstate,
c.alertOnAbnormal,
c.alertOnAny,
c.testId.units,
'Chemistry' as dataset,
'Chemistry_'||c.testid as test_key,
from study.chemistryRefRange c
Expand All @@ -59,6 +60,7 @@ c.taskid,
c.qcstate,
c.alertOnAbnormal,
c.alertOnAny,
c.testId.units,
'Hematology' as dataset,
'Hematology_'||c.testid as test_key,
from study.hematologyRefRange c
Expand All @@ -85,6 +87,7 @@ c.taskid,
c.qcstate,
c.alertOnAbnormal,
c.alertOnAny,
c.testId.units,
'Immunology' as dataset,
'Immunology_'||c.testid as test_key,
from study.immunologyRefRange c
Expand All @@ -111,6 +114,7 @@ c.taskid,
c.qcstate,
c.alertOnAbnormal,
c.alertOnAny,
c.testId.units,
'Urinalysis' as dataset,
'Urinalysis_'||c.testid as test_key,
from study.urinalysisRefRange c
Expand Down
6 changes: 5 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 @@ -393,7 +393,11 @@ public void registerNotifications() {
new BloodOverdrawTriggerNotification(this),
new EmptyNotificationRevamp(this),
new AnimalRequestUpdateNotificationRevamp(this),
new TreatmentAlertsNotificationRevamp(this)
new TreatmentAlertsNotificationRevamp(this),
new ClinpathAbnormalResultsAlertsRevamp(this),
new ClinpathAlertsRevamp(this),
new ClinpathResultAlertsRevamp(this),
new LargeInfantAlertsRevamp(this)
);

for (Notification notification : notifications)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
package org.labkey.wnprc_ehr.notification;

import org.checkerframework.checker.units.qual.A;
import org.jetbrains.annotations.Nullable;
import org.labkey.api.data.CompareType;
import org.labkey.api.data.Container;
import org.labkey.api.data.SimpleFilter;
import org.labkey.api.ldk.notification.NotificationService;
import org.labkey.api.module.Module;
import org.labkey.api.security.User;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;

public class ClinpathAbnormalResultsAlertsRevamp extends AbstractEHRNotification {
//Class Variables
NotificationToolkit notificationToolkit = new NotificationToolkit();
NotificationToolkit.DateToolkit dateToolkit = new NotificationToolkit.DateToolkit();
NotificationToolkit.StyleToolkit styleToolkit = new NotificationToolkit.StyleToolkit();





// Constructors
/**
* This constructor is used to register the notification in WNPRC_EHRModule.java.
* @param owner
*/
public ClinpathAbnormalResultsAlertsRevamp(Module owner) {super(owner);}





// Notification Details
@Override
public String getName() {
return "Clinpath Abnormal Results Alerts Notification Revamp";
}
@Override
public String getDescription() {
return "This report is designed to identify potential problems related to clinpath.";
}
@Override
public String getEmailSubject(Container c) {
return "Abnormal Clinpath Results: " + dateToolkit.getCurrentTime();
}
@Override
public String getScheduleDescription() {
return "Daily every hour from 7:05AM - 5:05PM";
}
@Override
public String getCronString() {
return notificationToolkit.createCronString("5", "7,8,9,10,11,12,13,14,15,16,17", "*");
}
@Override
public String getCategory() {
return "Revamped Notifications";
}





// Message Creation
@Override
public String getMessageBodyHTML(Container c, User u) {
// Creates variables & gets data.
final StringBuilder messageBody = new StringBuilder();

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

// Sets up variables.
HashMap<String, HashMap<String, ArrayList<HashMap<String, String>>>> filteredResults = new HashMap<>(); // Areas > Rooms > Results List > Result
Date lastRunDate = new Date(NotificationService.get().getLastRun(this));
Calendar cal = Calendar.getInstance();
cal.setTime(lastRunDate);
cal.add(Calendar.DATE, -7);
Date lastRunMinusWeek = cal.getTime();

// Creates filter.
SimpleFilter myFilter = new SimpleFilter("qcstate/PublicData", true, CompareType.EQUAL);
myFilter.addCondition("taskid/datecompleted", lastRunDate, CompareType.DATE_GTE);
myFilter.addCondition("taskid/datecompleted", "", CompareType.NONBLANK);
myFilter.addCondition("date", lastRunMinusWeek, CompareType.DATE_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.
ArrayList<HashMap<String, String>> returnArray = notificationToolkit.getTableMultiRowMultiColumnWithFieldKeys(c, u, "study", "ClinpathRefRange", myFilter, null, targetColumns);
// Creates URL.
String clinpathTasksUrlView = notificationToolkit.createQueryURL(c, "execute", "study", "ClinpathRefRange", myFilter);

// Organizes results into a list filtered by [Area > Room > Task].
for (HashMap<String, String> 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");
}

// Adds to list if area does not exist yet.
if (!filteredResults.containsKey(result.get("Id/curLocation/area"))) {
// Creates new room results list.
ArrayList<HashMap<String, String>> newRoomList = new ArrayList<>();
newRoomList.add(result);
// Creates new room map.
HashMap<String, ArrayList<HashMap<String, String>>> 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<HashMap<String, String>> 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 + "<br>");
messageBody.append(notificationToolkit.createHyperlink("Click here to view them", clinpathTasksUrlView) + "</a><p>\n");
messageBody.append("<p>Listed below are the abnormal records.</p>\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("<b>" + currentArea + ":</b><br>\n");
for (String currentRoom : notificationToolkit.sortSetWithNulls(filteredResults.get(currentArea).keySet())) {
messageBody.append(currentRoom + ":<br>\n");
// Reformats the hashmap into a String[] List (to be compatible with the table creation function).
ArrayList<String []> currentTableData = new ArrayList<>();
ArrayList<String> rowColorsList = new ArrayList<>();
for (HashMap<String, String> currentRow : filteredResults.get(currentArea).get(currentRoom)) {
String[] newTableRow = new String[] {
currentRow.get("Id"),
currentRow.get("date"),
currentRow.get("taskid/datecompleted"),
currentRow.get("testid"),
currentRow.get("result"),
currentRow.get("units"),
currentRow.get("status"),
currentRow.get("ref_range_min"),
currentRow.get("ref_range_max"),
currentRow.get("ageAtTime"),
};
currentTableData.add(newTableRow);

if (!currentRow.get("ref_range_min").isBlank() && !currentRow.get("result").isBlank()) {
if (Double.parseDouble(currentRow.get("result")) < Double.parseDouble(currentRow.get("ref_range_min"))) {
rowColorsList.add("yellow");
}
}
if (!currentRow.get("ref_range_max").isBlank() && !currentRow.get("result").isBlank()) {
if (Double.parseDouble(currentRow.get("result")) > Double.parseDouble(currentRow.get("ref_range_max"))) {
rowColorsList.add("red");
}
}

if (currentTableData.size() > rowColorsList.size()) {
rowColorsList.add("white");
}
}

// Displays table.
NotificationToolkit.NotificationRevampTable myTable = new NotificationToolkit.NotificationRevampTable(tableColumns, currentTableData);
myTable.rowColors = rowColorsList;
messageBody.append(myTable.createBasicHTMLTable());
}
}

// Returns message.
return messageBody.toString();
}

}
Loading
Loading