Skip to content

Commit 33e7ca8

Browse files
Merge 26.2 to develop
2 parents ff96022 + 8c24469 commit 33e7ca8

6 files changed

Lines changed: 263 additions & 0 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!--Report title-->
2+
<query xmlns="http://labkey.org/data/xml/query">
3+
<metadata>
4+
<tables xmlns="http://labkey.org/data/xml">
5+
<table tableName="AssignmentPoolUnderTheAge" tableDbType="TABLE">
6+
<tableTitle>Animals under the age of 2.5 with an assignment pool note</tableTitle>
7+
</table>
8+
</tables>
9+
</metadata>
10+
</query>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/* Added by Kollil, Jan 2026
2+
Refer to tkt # 14056
3+
- Extract animals under the age of 2.5 with an "Assignment pool" note in PRIMe (under general>notes)
4+
*/
5+
6+
SELECT
7+
a.Id,
8+
a.Id.demographics.gender AS Sex,
9+
a.Id.Age.ageinyears,
10+
a.Id.curlocation.room AS Room,
11+
a.Id.curlocation.cage AS Cage,
12+
/* Display the (active) Notes Pertaining to DAR note text */
13+
(
14+
SELECT MAX(n.value)
15+
FROM study.Notes n
16+
WHERE n.Id = a.Id
17+
AND n.category = 'Notes Pertaining to DAR'
18+
AND n.endDate IS NULL
19+
) AS Notes_Pertaining_to_DAR,
20+
/* Concatenate all active cagemate IDs into one cell */
21+
(
22+
SELECT GROUP_CONCAT(DISTINCT CAST(h.roommateId AS VARCHAR), ', ')
23+
FROM housingRoommatesDivider h
24+
WHERE h.Id = a.Id
25+
AND h.removalDate IS NULL
26+
AND h.roommateEnd IS NULL
27+
AND h.roommateId IS NOT NULL
28+
) AS Cagemates,
29+
/* Concatenate all active projects & investigator into one cell */
30+
(
31+
SELECT GROUP_CONCAT(DISTINCT CAST('[' + d.project.protocol.investigatorId.lastname + ']' + d.project.displayname + '' AS VARCHAR), ', ')
32+
FROM housingRoommatesDivider h
33+
LEFT JOIN study.assignment d ON d.Id = h.roommateId
34+
WHERE h.Id = a.Id
35+
AND h.removalDate IS NULL
36+
AND h.roommateEnd IS NULL
37+
AND h.roommateId IS NOT NULL
38+
AND d.enddate IS NULL
39+
AND d.isActive = 1
40+
AND d.project.displayname NOT IN ('0492-02', '0492-03')
41+
) AS Cagemate_Assignments
42+
43+
FROM Assignment a
44+
WHERE
45+
a.Id.Age.ageinyears <= 2.5
46+
AND a.project.displayname NOT IN ('0492-02', '0492-03')
47+
AND a.Id.demographics.species = 'Rhesus Macaque'
48+
AND EXISTS (
49+
SELECT 1
50+
FROM study.Notes n
51+
WHERE n.Id = a.Id
52+
AND n.value LIKE '%Assignment pool%'
53+
AND n.endDate IS NULL
54+
)
55+
56+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!--Report title-->
2+
<query xmlns="http://labkey.org/data/xml/query">
3+
<metadata>
4+
<tables xmlns="http://labkey.org/data/xml">
5+
<table tableName="AssignmentsUnderTheAge" tableDbType="TABLE">
6+
<tableTitle>Animals under the age of 2.5 with an active assignment</tableTitle>
7+
</table>
8+
</tables>
9+
</metadata>
10+
</query>
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
/* Added by Kollil, Jan 2026
2+
Refer to tkt # 14056
3+
- 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.
4+
*/
5+
SELECT
6+
a.Id,
7+
a.Id.demographics.gender AS Sex,
8+
a.Id.Age.ageinyears,
9+
a.Id.curlocation.room AS Room,
10+
a.Id.curlocation.cage AS Cage,
11+
a.project,
12+
a.project.protocol.displayname AS Protocol,
13+
a.project.title AS Title,
14+
a.project.protocol.investigatorId.lastname AS ProjectInvestigator,
15+
CAST(a.date AS DATE) AS AssignDate,
16+
CAST(a.enddate AS DATE) AS ReleaseDate,
17+
CAST(a.projectedRelease AS DATE) AS ProjectedReleaseDate,
18+
a.assignmentType,
19+
a.projectedReleaseCondition.meaning AS ProjectedReleaseCondition,
20+
a.releaseCondition.meaning AS ConditionAtRelease,
21+
/* Concatenate all active cagemate IDs into one cell */
22+
(
23+
SELECT GROUP_CONCAT(DISTINCT CAST(h.roommateId AS VARCHAR), ', ')
24+
FROM housingRoommatesDivider h
25+
WHERE h.Id = a.Id
26+
AND h.removalDate IS NULL
27+
AND h.roommateEnd IS NULL
28+
AND h.roommateId IS NOT NULL
29+
) AS Cagemates,
30+
/* Concatenate all active projects & investigator into one cell */
31+
(
32+
SELECT GROUP_CONCAT(DISTINCT CAST('[' + d.project.protocol.investigatorId.lastname + ']' + d.project.displayname + '' AS VARCHAR), ', ')
33+
FROM housingRoommatesDivider h
34+
LEFT JOIN study.assignment d ON d.Id = h.roommateId
35+
WHERE h.Id = a.Id
36+
AND h.removalDate IS NULL
37+
AND h.roommateEnd IS NULL
38+
AND h.roommateId IS NOT NULL
39+
AND d.enddate IS NULL
40+
AND d.isActive = 1
41+
AND d.project.displayname NOT IN ('0492-02', '0492-03')
42+
) AS Cagemate_Assignments
43+
44+
FROM Assignment a
45+
WHERE
46+
a.Id.Age.ageinyears <= 2.5
47+
AND a.Id.demographics.species = 'Rhesus Macaque'
48+
AND a.enddate IS NULL
49+
AND a.isActive = 1
50+
AND a.project.displayname NOT IN ('0492-02', '0492-03')
51+
52+
53+
54+
55+
56+
57+
58+
59+
60+
61+
62+
63+
64+
65+
66+
67+
68+
69+
70+
71+
72+
-- SELECT
73+
-- a.Id,
74+
-- a.Id.demographics.gender AS Sex,
75+
-- a.Id.Age.ageinyears,
76+
-- a.Id.curlocation.room AS Room,
77+
-- a.Id.curlocation.cage AS Cage,
78+
-- a.project,
79+
-- a.project.protocol.displayname AS Protocol,
80+
-- a.project.title AS Title,
81+
-- a.project.protocol.investigatorId.lastname AS ProjectInvestigator,
82+
-- CAST(a.date AS DATE) AS AssignDate,
83+
-- CAST(a.enddate AS DATE) AS ReleaseDate,
84+
-- CAST(a.projectedRelease AS DATE) AS ProjectedReleaseDate,
85+
-- a.assignmentType,
86+
-- a.projectedReleaseCondition.meaning AS ProjectedReleaseCondition,
87+
-- a.releaseCondition.meaning AS ConditionAtRelease,
88+
-- h.roommateId AS Cagemate,
89+
-- d.use AS Cagemate_Assignment
90+
-- FROM Assignment a
91+
-- LEFT JOIN housingRoommatesDivider h
92+
-- ON h.Id = a.Id
93+
-- AND h.removalDate IS NULL
94+
-- AND h.roommateEnd IS NULL
95+
-- LEFT JOIN study.demographicsUtilization d
96+
-- ON d.Id = h.roommateId
97+
-- WHERE
98+
-- a.Id.Age.ageinyears <= 2.5
99+
-- AND a.Id.demographics.species = 'Rhesus Macaque'
100+
-- AND a.enddate IS NULL
101+
-- AND a.isActive = 1
102+
-- AND a.project.displayname NOT IN ('0492-02', '0492-03')

onprc_ehr/src/org/labkey/onprc_ehr/notification/BehaviorNotification.java

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,61 @@ public String getMessageBodyHTML(Container c, User u)
122122
assignmentsStartingNext1to14Days(c,u,msg);
123123
assignmentsStartedPast1to7Days(c,u,msg);
124124

125+
//Added by Kollil, Jan 2026
126+
//Refer to tkt # 14056
127+
activeAssignmentsUnderTheAge(c,u,msg);
128+
assignmentPoolUnderTheAge(c,u,msg);
129+
125130
notesEndingToday(c, u, msg, Arrays.asList("BSU Notes"), null);
126131
saveValues(c, toSave);
127132

128133
return msg.toString();
129134
}
130135

136+
/* Added by Kollil, Jan 2026
137+
Refer to tkt # 14056
138+
The grid should include:
139+
- 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.
140+
- Animals under the age of 2.5 with an "Assignment pool" note in PRIMe (under general>notes)
141+
*/
142+
private void activeAssignmentsUnderTheAge(final Container c, User u, final StringBuilder msg)
143+
{
144+
TableInfo ti = getStudySchema(c, u).getTable("AssignmentsUnderTheAge");
145+
146+
TableSelector ts = new TableSelector(ti, null, new Sort("Id"));
147+
long total = ts.getRowCount();
148+
149+
if (total > 0)
150+
{
151+
msg.append("<b>Animals under the age of 2.5 with an active assignment excluding the U42 & U42E assignments:</b><p>");
152+
msg.append( total + " entries found. ");
153+
msg.append("<a href='" + getExecuteQueryUrl(c, "study", "AssignmentsUnderTheAge", null) + "'>Click here to view them</a>\n");
154+
msg.append("<hr>\n\n");
155+
}
156+
else {
157+
msg.append("<b>WARNING: No animals under the age of 2.5 with an active assignment!</b><br><hr>\n");
158+
}
159+
}
160+
161+
private void assignmentPoolUnderTheAge(final Container c, User u, final StringBuilder msg)
162+
{
163+
TableInfo ti = getStudySchema(c, u).getTable("AssignmentPoolUnderTheAge");
164+
165+
TableSelector ts = new TableSelector(ti, null, new Sort("Id"));
166+
long total = ts.getRowCount();
167+
168+
if (total > 0)
169+
{
170+
msg.append("<b>Animals under the age of 2.5 with \"Assignment pool\" notes:</b><p>");
171+
msg.append( total + " entries found. ");
172+
msg.append("<a href='" + getExecuteQueryUrl(c, "study", "AssignmentPoolUnderTheAge", null) + "'>Click here to view them</a>\n");
173+
msg.append("<hr>\n\n");
174+
}
175+
else {
176+
msg.append("<b>WARNING: No animals under the age of 2.5 with an \"Assignment pool\" notes!</b><br><hr>\n");
177+
}
178+
}
179+
131180
/* Added by Kollil Nov, 2025
132181
Priority 4: Add links to grids 3 and 4 in daily Behavior Alerts email (do not need to display full grid in email)
133182
- for grid 3 - "There are __ assignments starting in the Next 1-14 days" with a link

onprc_ehr/test/src/org/labkey/test/tests/onprc_ehr/ONPRC_RestrictedIssueTest.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.labkey.test.tests.onprc_ehr;
22

3+
import org.junit.Assert;
34
import org.junit.BeforeClass;
45
import org.junit.Test;
56
import org.junit.experimental.categories.Category;
@@ -11,7 +12,9 @@
1112
import org.labkey.test.pages.issues.DetailsPage;
1213
import org.labkey.test.pages.issues.InsertPage;
1314
import org.labkey.test.pages.issues.UpdatePage;
15+
import org.labkey.test.pages.search.SearchResultsPage;
1416
import org.labkey.test.util.IssuesHelper;
17+
import org.labkey.test.util.SearchHelper;
1518
import org.labkey.test.util.SqlserverOnlyTest;
1619
import org.labkey.test.util.TestUser;
1720

@@ -268,4 +271,37 @@ private Locator getIssueLinkLocator(String issueID)
268271
{
269272
return Locator.tagWithAttributeContaining("a", "href", String.format("issues-details.view?issueId=%s", issueID));
270273
}
274+
275+
@Test
276+
public void restrictedIssueSearchTest()
277+
{
278+
goToProjectHome();
279+
280+
// create a few issues in the restricted list
281+
clickAndWait(Locator.linkContainingText(RESTRICTED_ISSUES_LIST));
282+
DetailsPage detailsPage = _issuesHelper.addIssue("Restricted issue search test #1", USER1.getUserDisplayName());
283+
final String ISSUE_1 = detailsPage.getIssueId();
284+
InsertPage insertPage = detailsPage.clickCreateNewIssue();
285+
insertPage.title().set("Restricted issue search test #2");
286+
insertPage.assignedTo().set(USER2.getUserDisplayName());
287+
detailsPage = insertPage.save();
288+
final String ISSUE_2 = detailsPage.getIssueId();
289+
290+
SearchHelper searchHelper = new SearchHelper(this);
291+
SearchResultsPage resultsPage = searchHelper.searchFor("Restricted issue search test");
292+
293+
// verify that we can return links even if the user doesn't have permission to view a restricted issue
294+
Assert.assertTrue("Number of search results not expected", resultsPage.getResults().size() == 2);
295+
296+
// verify assigned to users will see both results but shouldn't be able to see details of issues not assigned to them
297+
impersonate(USER1.getEmail());
298+
verifyIssueAccess(ISSUE_1, true);
299+
verifyIssueAccess(ISSUE_2, false);
300+
stopImpersonating(false);
301+
302+
impersonate(USER2.getEmail());
303+
verifyIssueAccess(ISSUE_1, false);
304+
verifyIssueAccess(ISSUE_2, true);
305+
stopImpersonating();
306+
}
271307
}

0 commit comments

Comments
 (0)