Skip to content

Commit 1462774

Browse files
authored
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
1 parent 8b42f94 commit 1462774

5 files changed

Lines changed: 226 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: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
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+
) AS Cagemate_Assignments
42+
43+
FROM Assignment a
44+
WHERE
45+
a.Id.Age.ageinyears <= 2.5
46+
AND a.Id.demographics.species = 'Rhesus Macaque'
47+
AND a.enddate IS NULL
48+
AND a.isActive = 1
49+
AND a.project.displayname NOT IN ('0492-02', '0492-03')
50+
51+
52+
53+
54+
55+
56+
57+
58+
59+
60+
61+
62+
63+
64+
65+
66+
67+
68+
69+
70+
71+
-- SELECT
72+
-- a.Id,
73+
-- a.Id.demographics.gender AS Sex,
74+
-- a.Id.Age.ageinyears,
75+
-- a.Id.curlocation.room AS Room,
76+
-- a.Id.curlocation.cage AS Cage,
77+
-- a.project,
78+
-- a.project.protocol.displayname AS Protocol,
79+
-- a.project.title AS Title,
80+
-- a.project.protocol.investigatorId.lastname AS ProjectInvestigator,
81+
-- CAST(a.date AS DATE) AS AssignDate,
82+
-- CAST(a.enddate AS DATE) AS ReleaseDate,
83+
-- CAST(a.projectedRelease AS DATE) AS ProjectedReleaseDate,
84+
-- a.assignmentType,
85+
-- a.projectedReleaseCondition.meaning AS ProjectedReleaseCondition,
86+
-- a.releaseCondition.meaning AS ConditionAtRelease,
87+
-- h.roommateId AS Cagemate,
88+
-- d.use AS Cagemate_Assignment
89+
-- FROM Assignment a
90+
-- LEFT JOIN housingRoommatesDivider h
91+
-- ON h.Id = a.Id
92+
-- AND h.removalDate IS NULL
93+
-- AND h.roommateEnd IS NULL
94+
-- LEFT JOIN study.demographicsUtilization d
95+
-- ON d.Id = h.roommateId
96+
-- WHERE
97+
-- a.Id.Age.ageinyears <= 2.5
98+
-- AND a.Id.demographics.species = 'Rhesus Macaque'
99+
-- AND a.enddate IS NULL
100+
-- AND a.isActive = 1
101+
-- 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", "AssignmentsUnderTheAge", 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

0 commit comments

Comments
 (0)