From 146277408130e6e81e2877638de501dc2b0954ba Mon Sep 17 00:00:00 2001
From: Lakshmi Kolli <69940873+kollil@users.noreply.github.com>
Date: Mon, 2 Feb 2026 12:10:04 -0800
Subject: [PATCH 1/3] BSU assignment dashboard additions (#1622)
* Adding new grid to BSU assignment dashboard and in the alert email.
* Updated queries
* Updated queries with more filters
* Updated queries with final edits
* Updated queries with final edits
* Updated queries- Last edit
---
.../study/AssignmentPoolUnderTheAge.query.xml | 10 ++
.../study/AssignmentPoolUnderTheAge.sql | 56 ++++++++++
.../study/AssignmentsUnderTheAge.query.xml | 10 ++
.../queries/study/AssignmentsUnderTheAge.sql | 101 ++++++++++++++++++
.../notification/BehaviorNotification.java | 49 +++++++++
5 files changed, 226 insertions(+)
create mode 100644 onprc_ehr/resources/queries/study/AssignmentPoolUnderTheAge.query.xml
create mode 100644 onprc_ehr/resources/queries/study/AssignmentPoolUnderTheAge.sql
create mode 100644 onprc_ehr/resources/queries/study/AssignmentsUnderTheAge.query.xml
create mode 100644 onprc_ehr/resources/queries/study/AssignmentsUnderTheAge.sql
diff --git a/onprc_ehr/resources/queries/study/AssignmentPoolUnderTheAge.query.xml b/onprc_ehr/resources/queries/study/AssignmentPoolUnderTheAge.query.xml
new file mode 100644
index 000000000..ee363ecd0
--- /dev/null
+++ b/onprc_ehr/resources/queries/study/AssignmentPoolUnderTheAge.query.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+ Animals under the age of 2.5 with an assignment pool note
+
+
+
+
diff --git a/onprc_ehr/resources/queries/study/AssignmentPoolUnderTheAge.sql b/onprc_ehr/resources/queries/study/AssignmentPoolUnderTheAge.sql
new file mode 100644
index 000000000..bfd3899c1
--- /dev/null
+++ b/onprc_ehr/resources/queries/study/AssignmentPoolUnderTheAge.sql
@@ -0,0 +1,56 @@
+/* Added by Kollil, Jan 2026
+ Refer to tkt # 14056
+ - Extract animals under the age of 2.5 with an "Assignment pool" note in PRIMe (under general>notes)
+ */
+
+SELECT
+ a.Id,
+ a.Id.demographics.gender AS Sex,
+ a.Id.Age.ageinyears,
+ a.Id.curlocation.room AS Room,
+ a.Id.curlocation.cage AS Cage,
+ /* Display the (active) Notes Pertaining to DAR note text */
+ (
+ SELECT MAX(n.value)
+ FROM study.Notes n
+ WHERE n.Id = a.Id
+ AND n.category = 'Notes Pertaining to DAR'
+ AND n.endDate IS NULL
+ ) AS Notes_Pertaining_to_DAR,
+ /* Concatenate all active cagemate IDs into one cell */
+ (
+ SELECT GROUP_CONCAT(DISTINCT CAST(h.roommateId AS VARCHAR), ', ')
+ FROM housingRoommatesDivider h
+ WHERE h.Id = a.Id
+ AND h.removalDate IS NULL
+ AND h.roommateEnd IS NULL
+ AND h.roommateId IS NOT NULL
+ ) AS Cagemates,
+ /* Concatenate all active projects & investigator into one cell */
+ (
+ SELECT GROUP_CONCAT(DISTINCT CAST('[' + d.project.protocol.investigatorId.lastname + ']' + d.project.displayname + '' AS VARCHAR), ', ')
+ FROM housingRoommatesDivider h
+ LEFT JOIN study.assignment d ON d.Id = h.roommateId
+ WHERE h.Id = a.Id
+ AND h.removalDate IS NULL
+ AND h.roommateEnd IS NULL
+ AND h.roommateId IS NOT NULL
+ AND d.enddate IS NULL
+ AND d.isActive = 1
+ AND d.project.displayname NOT IN ('0492-02', '0492-03')
+ ) AS Cagemate_Assignments
+
+FROM Assignment a
+WHERE
+ a.Id.Age.ageinyears <= 2.5
+ AND a.project.displayname NOT IN ('0492-02', '0492-03')
+ AND a.Id.demographics.species = 'Rhesus Macaque'
+ AND EXISTS (
+ SELECT 1
+ FROM study.Notes n
+ WHERE n.Id = a.Id
+ AND n.value LIKE '%Assignment pool%'
+ AND n.endDate IS NULL
+ )
+
+
diff --git a/onprc_ehr/resources/queries/study/AssignmentsUnderTheAge.query.xml b/onprc_ehr/resources/queries/study/AssignmentsUnderTheAge.query.xml
new file mode 100644
index 000000000..62259a6b4
--- /dev/null
+++ b/onprc_ehr/resources/queries/study/AssignmentsUnderTheAge.query.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+ Animals under the age of 2.5 with an active assignment
+
+
+
+
diff --git a/onprc_ehr/resources/queries/study/AssignmentsUnderTheAge.sql b/onprc_ehr/resources/queries/study/AssignmentsUnderTheAge.sql
new file mode 100644
index 000000000..3131b0081
--- /dev/null
+++ b/onprc_ehr/resources/queries/study/AssignmentsUnderTheAge.sql
@@ -0,0 +1,101 @@
+/* Added by Kollil, Jan 2026
+ Refer to tkt # 14056
+ - Extract animals under the age of 2.5 with an active assignment. Exclude the U42 and U42E colony maintenance assignments, i.e, center projects for these are 0492-02 and 0492-03.
+ */
+ SELECT
+ a.Id,
+ a.Id.demographics.gender AS Sex,
+ a.Id.Age.ageinyears,
+ a.Id.curlocation.room AS Room,
+ a.Id.curlocation.cage AS Cage,
+ a.project,
+ a.project.protocol.displayname AS Protocol,
+ a.project.title AS Title,
+ a.project.protocol.investigatorId.lastname AS ProjectInvestigator,
+ CAST(a.date AS DATE) AS AssignDate,
+ CAST(a.enddate AS DATE) AS ReleaseDate,
+ CAST(a.projectedRelease AS DATE) AS ProjectedReleaseDate,
+ a.assignmentType,
+ a.projectedReleaseCondition.meaning AS ProjectedReleaseCondition,
+ a.releaseCondition.meaning AS ConditionAtRelease,
+ /* Concatenate all active cagemate IDs into one cell */
+ (
+ SELECT GROUP_CONCAT(DISTINCT CAST(h.roommateId AS VARCHAR), ', ')
+ FROM housingRoommatesDivider h
+ WHERE h.Id = a.Id
+ AND h.removalDate IS NULL
+ AND h.roommateEnd IS NULL
+ AND h.roommateId IS NOT NULL
+ ) AS Cagemates,
+ /* Concatenate all active projects & investigator into one cell */
+ (
+ SELECT GROUP_CONCAT(DISTINCT CAST('[' + d.project.protocol.investigatorId.lastname + ']' + d.project.displayname + '' AS VARCHAR), ', ')
+ FROM housingRoommatesDivider h
+ LEFT JOIN study.assignment d ON d.Id = h.roommateId
+ WHERE h.Id = a.Id
+ AND h.removalDate IS NULL
+ AND h.roommateEnd IS NULL
+ AND h.roommateId IS NOT NULL
+ AND d.enddate IS NULL
+ AND d.isActive = 1
+ ) AS Cagemate_Assignments
+
+FROM Assignment a
+WHERE
+ a.Id.Age.ageinyears <= 2.5
+ AND a.Id.demographics.species = 'Rhesus Macaque'
+ AND a.enddate IS NULL
+ AND a.isActive = 1
+ AND a.project.displayname NOT IN ('0492-02', '0492-03')
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+-- SELECT
+-- a.Id,
+-- a.Id.demographics.gender AS Sex,
+-- a.Id.Age.ageinyears,
+-- a.Id.curlocation.room AS Room,
+-- a.Id.curlocation.cage AS Cage,
+-- a.project,
+-- a.project.protocol.displayname AS Protocol,
+-- a.project.title AS Title,
+-- a.project.protocol.investigatorId.lastname AS ProjectInvestigator,
+-- CAST(a.date AS DATE) AS AssignDate,
+-- CAST(a.enddate AS DATE) AS ReleaseDate,
+-- CAST(a.projectedRelease AS DATE) AS ProjectedReleaseDate,
+-- a.assignmentType,
+-- a.projectedReleaseCondition.meaning AS ProjectedReleaseCondition,
+-- a.releaseCondition.meaning AS ConditionAtRelease,
+-- h.roommateId AS Cagemate,
+-- d.use AS Cagemate_Assignment
+-- FROM Assignment a
+-- LEFT JOIN housingRoommatesDivider h
+-- ON h.Id = a.Id
+-- AND h.removalDate IS NULL
+-- AND h.roommateEnd IS NULL
+-- LEFT JOIN study.demographicsUtilization d
+-- ON d.Id = h.roommateId
+-- WHERE
+-- a.Id.Age.ageinyears <= 2.5
+-- AND a.Id.demographics.species = 'Rhesus Macaque'
+-- AND a.enddate IS NULL
+-- AND a.isActive = 1
+-- AND a.project.displayname NOT IN ('0492-02', '0492-03')
diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/notification/BehaviorNotification.java b/onprc_ehr/src/org/labkey/onprc_ehr/notification/BehaviorNotification.java
index 958d70a3f..4d49b7781 100644
--- a/onprc_ehr/src/org/labkey/onprc_ehr/notification/BehaviorNotification.java
+++ b/onprc_ehr/src/org/labkey/onprc_ehr/notification/BehaviorNotification.java
@@ -122,12 +122,61 @@ public String getMessageBodyHTML(Container c, User u)
assignmentsStartingNext1to14Days(c,u,msg);
assignmentsStartedPast1to7Days(c,u,msg);
+ //Added by Kollil, Jan 2026
+ //Refer to tkt # 14056
+ activeAssignmentsUnderTheAge(c,u,msg);
+ assignmentPoolUnderTheAge(c,u,msg);
+
notesEndingToday(c, u, msg, Arrays.asList("BSU Notes"), null);
saveValues(c, toSave);
return msg.toString();
}
+ /* Added by Kollil, Jan 2026
+ Refer to tkt # 14056
+ The grid should include:
+ - Animals under the age of 2.5 with an active assignment. Exclude the U42 and U42E colony maintenance assignments, I believe the center projects for these are 0492-02 and 0492-03.
+ - Animals under the age of 2.5 with an "Assignment pool" note in PRIMe (under general>notes)
+ */
+ private void activeAssignmentsUnderTheAge(final Container c, User u, final StringBuilder msg)
+ {
+ TableInfo ti = getStudySchema(c, u).getTable("AssignmentsUnderTheAge");
+
+ TableSelector ts = new TableSelector(ti, null, new Sort("Id"));
+ long total = ts.getRowCount();
+
+ if (total > 0)
+ {
+ msg.append("Animals under the age of 2.5 with an active assignment excluding the U42 & U42E assignments:
");
+ msg.append( total + " entries found. ");
+ msg.append("Click here to view them\n");
+ msg.append("
\n\n");
+ }
+ else {
+ msg.append("WARNING: No animals under the age of 2.5 with an active assignment!
\n");
+ }
+ }
+
+ private void assignmentPoolUnderTheAge(final Container c, User u, final StringBuilder msg)
+ {
+ TableInfo ti = getStudySchema(c, u).getTable("AssignmentPoolUnderTheAge");
+
+ TableSelector ts = new TableSelector(ti, null, new Sort("Id"));
+ long total = ts.getRowCount();
+
+ if (total > 0)
+ {
+ msg.append("Animals under the age of 2.5 with \"Assignment pool\" notes:");
+ msg.append( total + " entries found. ");
+ msg.append("Click here to view them\n");
+ msg.append("
\n\n");
+ }
+ else {
+ msg.append("WARNING: No animals under the age of 2.5 with an \"Assignment pool\" notes!
\n");
+ }
+ }
+
/* Added by Kollil Nov, 2025
Priority 4: Add links to grids 3 and 4 in daily Behavior Alerts email (do not need to display full grid in email)
- for grid 3 - "There are __ assignments starting in the Next 1-14 days" with a link
From 20cf8d7e0afbbeed84488b90fa9b074716242a3f Mon Sep 17 00:00:00 2001
From: Lakshmi Kolli <69940873+kollil@users.noreply.github.com>
Date: Tue, 3 Feb 2026 13:58:40 -0800
Subject: [PATCH 2/3] Behavior alert assignment pool note link update (#1626)
* Fixed the query link
* Added a query condition
---
onprc_ehr/resources/queries/study/AssignmentsUnderTheAge.sql | 1 +
.../org/labkey/onprc_ehr/notification/BehaviorNotification.java | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/onprc_ehr/resources/queries/study/AssignmentsUnderTheAge.sql b/onprc_ehr/resources/queries/study/AssignmentsUnderTheAge.sql
index 3131b0081..f9405ee3a 100644
--- a/onprc_ehr/resources/queries/study/AssignmentsUnderTheAge.sql
+++ b/onprc_ehr/resources/queries/study/AssignmentsUnderTheAge.sql
@@ -38,6 +38,7 @@
AND h.roommateId IS NOT NULL
AND d.enddate IS NULL
AND d.isActive = 1
+ AND d.project.displayname NOT IN ('0492-02', '0492-03')
) AS Cagemate_Assignments
FROM Assignment a
diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/notification/BehaviorNotification.java b/onprc_ehr/src/org/labkey/onprc_ehr/notification/BehaviorNotification.java
index 4d49b7781..b9d63e2a5 100644
--- a/onprc_ehr/src/org/labkey/onprc_ehr/notification/BehaviorNotification.java
+++ b/onprc_ehr/src/org/labkey/onprc_ehr/notification/BehaviorNotification.java
@@ -169,7 +169,7 @@ private void assignmentPoolUnderTheAge(final Container c, User u, final StringBu
{
msg.append("Animals under the age of 2.5 with \"Assignment pool\" notes:");
msg.append( total + " entries found. ");
- msg.append("Click here to view them\n");
+ msg.append("Click here to view them\n");
msg.append("
\n\n");
}
else {
From 801333ea1302153454364e76627500703187c64f Mon Sep 17 00:00:00 2001
From: Karl Lum
Date: Fri, 6 Feb 2026 08:36:01 -0800
Subject: [PATCH 3/3] Suppress restricted issue exception on search (#1629)
---
.../onprc_ehr/ONPRC_RestrictedIssueTest.java | 36 +++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/onprc_ehr/test/src/org/labkey/test/tests/onprc_ehr/ONPRC_RestrictedIssueTest.java b/onprc_ehr/test/src/org/labkey/test/tests/onprc_ehr/ONPRC_RestrictedIssueTest.java
index 7e54dae2c..5d0abf4a0 100644
--- a/onprc_ehr/test/src/org/labkey/test/tests/onprc_ehr/ONPRC_RestrictedIssueTest.java
+++ b/onprc_ehr/test/src/org/labkey/test/tests/onprc_ehr/ONPRC_RestrictedIssueTest.java
@@ -1,5 +1,6 @@
package org.labkey.test.tests.onprc_ehr;
+import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -11,7 +12,9 @@
import org.labkey.test.pages.issues.DetailsPage;
import org.labkey.test.pages.issues.InsertPage;
import org.labkey.test.pages.issues.UpdatePage;
+import org.labkey.test.pages.search.SearchResultsPage;
import org.labkey.test.util.IssuesHelper;
+import org.labkey.test.util.SearchHelper;
import org.labkey.test.util.SqlserverOnlyTest;
import org.labkey.test.util.TestUser;
@@ -265,4 +268,37 @@ private Locator getIssueLinkLocator(String issueID)
{
return Locator.tagWithAttributeContaining("a", "href", String.format("issues-details.view?issueId=%s", issueID));
}
+
+ @Test
+ public void restrictedIssueSearchTest()
+ {
+ goToProjectHome();
+
+ // create a few issues in the restricted list
+ clickAndWait(Locator.linkContainingText(RESTRICTED_ISSUES_LIST));
+ DetailsPage detailsPage = _issuesHelper.addIssue("Restricted issue search test #1", USER1.getUserDisplayName());
+ final String ISSUE_1 = detailsPage.getIssueId();
+ InsertPage insertPage = detailsPage.clickCreateNewIssue();
+ insertPage.title().set("Restricted issue search test #2");
+ insertPage.assignedTo().set(USER2.getUserDisplayName());
+ detailsPage = insertPage.save();
+ final String ISSUE_2 = detailsPage.getIssueId();
+
+ SearchHelper searchHelper = new SearchHelper(this);
+ SearchResultsPage resultsPage = searchHelper.searchFor("Restricted issue search test");
+
+ // verify that we can return links even if the user doesn't have permission to view a restricted issue
+ Assert.assertTrue("Number of search results not expected", resultsPage.getResults().size() == 2);
+
+ // verify assigned to users will see both results but shouldn't be able to see details of issues not assigned to them
+ impersonate(USER1.getEmail());
+ verifyIssueAccess(ISSUE_1, true);
+ verifyIssueAccess(ISSUE_2, false);
+ stopImpersonating(false);
+
+ impersonate(USER2.getEmail());
+ verifyIssueAccess(ISSUE_1, false);
+ verifyIssueAccess(ISSUE_2, true);
+ stopImpersonating();
+ }
}