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
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>
44 changes: 44 additions & 0 deletions onprc_ehr/resources/queries/study/AssignmentsUnderTheAge.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
SELECT
Id,
Id.demographics.gender as Sex,
Id.Age.ageinyears,
Id.curlocation.room as Room,
Id.curlocation.cage as Cage,
project.displayname as project,
project.protocol.displayname as Protocol,
project.title as Title,
project.protocol.investigatorId.lastname as ProjectInvestigator,
CAST(date AS DATE) AS AssignDate,
CAST(enddate AS DATE) AS ReleaseDate,
CAST(projectedRelease AS DATE) AS ProjectedReleaseDate,
assignmentType,
assignCondition.meaning as AssignCondition,
projectedReleaseCondition.meaning as ProjectedReleaseCondition,
releaseCondition.meaning as ConditionAtRelease,
/* Display the (active) Assignment pool note text */
(
SELECT MAX(n.value)
FROM study.Notes n
WHERE n.Id = Assignment.Id
AND n.value LIKE '%Assignment pool%'
AND n.endDate IS NULL
) AS BSU_Notes
FROM Assignment
WHERE Id.Age.ageinyears <= 2.5
AND enddate IS NULL
AND
(
(
/* Active assignment, excluding U42/U42E colony maintenance center projects */
project.displayname NOT IN ('0492-02', '0492-03')
)
OR
/* Has "Assignment pool" note in study.Notes */
EXISTS (
SELECT 1
FROM study.Notes n
WHERE n.Id = Assignment.Id
AND n.value LIKE '%Assignment pool%'
AND n.endDate IS NULL --active
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,41 @@ public String getMessageBodyHTML(Container c, User u)
assignmentsStartingNext1to14Days(c,u,msg);
assignmentsStartedPast1to7Days(c,u,msg);

//Added by Kollil, Jan 2026
//Refer to tkt # 14056
assignmentsUnderTheAge(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 assignmentsUnderTheAge(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 and U42E assignments, and animals with an \"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 active assignment, and 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