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..48765931d --- /dev/null +++ b/onprc_ehr/resources/queries/study/AssignmentPoolUnderTheAge.sql @@ -0,0 +1,49 @@ +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.displayname AS 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, + + /* 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, + + 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.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..441ddd847 --- /dev/null +++ b/onprc_ehr/resources/queries/study/AssignmentsUnderTheAge.sql @@ -0,0 +1,31 @@ +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.displayname AS 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..f2e8e57f5 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 and U42E assignments, and animals with an \"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 active assignment, and with an \"Assignment pool\" notes!

\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