Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!--Report title-->
<query xmlns="http://labkey.org/data/xml/query">
<metadata>
<tables xmlns="http://labkey.org/data/xml">
<table tableName="AssignmentPoolUnderTheAge" tableDbType="TABLE">
<tableTitle>Animals under the age of 2.5 with an assignment pool note</tableTitle>
</table>
</tables>
</metadata>
</query>
48 changes: 48 additions & 0 deletions onprc_ehr/resources/queries/study/AssignmentPoolUnderTheAge.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
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 & groups into one cell */
(
SELECT GROUP_CONCAT(DISTINCT CAST(d.use AS VARCHAR), ', ')
FROM housingRoommatesDivider h
LEFT JOIN study.demographicsUtilization 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
) 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
)


10 changes: 10 additions & 0 deletions onprc_ehr/resources/queries/study/AssignmentsUnderTheAge.query.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!--Report title-->
<query xmlns="http://labkey.org/data/xml/query">
<metadata>
<tables xmlns="http://labkey.org/data/xml">
<table tableName="AssignmentsUnderTheAge" tableDbType="TABLE">
<tableTitle>Animals under the age of 2.5 with an active assignment</tableTitle>
</table>
</tables>
</metadata>
</query>
95 changes: 95 additions & 0 deletions onprc_ehr/resources/queries/study/AssignmentsUnderTheAge.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
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 & groups into one cell */
(
SELECT GROUP_CONCAT(DISTINCT CAST(d.use AS VARCHAR), ', ')
FROM housingRoommatesDivider h
LEFT JOIN study.demographicsUtilization 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
) 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')
Original file line number Diff line number Diff line change
Expand Up @@ -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("<b>Animals under the age of 2.5 with an active assignment excluding the U42 & U42E assignments:</b><p>");
msg.append( total + " entries found. ");
msg.append("<a href='" + getExecuteQueryUrl(c, "study", "AssignmentsUnderTheAge", null) + "'>Click here to view them</a>\n");
msg.append("<hr>\n\n");
}
else {
msg.append("<b>WARNING: No animals under the age of 2.5 with an active assignment!</b><br><hr>\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("<b>Animals under the age of 2.5 with \"Assignment pool\" notes:</b><p>");
msg.append( total + " entries found. ");
msg.append("<a href='" + getExecuteQueryUrl(c, "study", "AssignmentsUnderTheAge", null) + "'>Click here to view them</a>\n");
msg.append("<hr>\n\n");
}
else {
msg.append("<b>WARNING: No animals under the age of 2.5 with an \"Assignment pool\" notes!</b><br><hr>\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
Expand Down