From ec825c595660b7b32dd0a9ce3c476b53952b8007 Mon Sep 17 00:00:00 2001 From: kollil Date: Wed, 29 Oct 2025 10:44:17 -0700 Subject: [PATCH 1/5] Added a new alert section that displays new birth tasks created in last 7 days. --- .../queries/onprc_ehr/NewBirthTasks.query.xml | 55 +++++++++++++++++++ .../queries/onprc_ehr/NewBirthTasks.sql | 21 +++++++ .../ColonyAlertsNotification.java | 27 +++++++++ .../DataValidationNotification.java | 3 + 4 files changed, 106 insertions(+) create mode 100644 onprc_ehr/resources/queries/onprc_ehr/NewBirthTasks.query.xml create mode 100644 onprc_ehr/resources/queries/onprc_ehr/NewBirthTasks.sql diff --git a/onprc_ehr/resources/queries/onprc_ehr/NewBirthTasks.query.xml b/onprc_ehr/resources/queries/onprc_ehr/NewBirthTasks.query.xml new file mode 100644 index 000000000..378eb9dc8 --- /dev/null +++ b/onprc_ehr/resources/queries/onprc_ehr/NewBirthTasks.query.xml @@ -0,0 +1,55 @@ + + + + + New Birth tasks created in last 7 days + + + Task ID + /ehr/dataEntryForm.view?formType=${formtype}&taskid=${taskid} + + + Title + + + Task Type + + + Assigned To + true + + core + PrincipalsWithoutAdmin + UserId + + + + Due Date + true + yyyy-MM-dd HH:mm + + + Created By + + core + users + userid + + + + Created + true + yyyy-MM-dd HH:mm + + + Status + false + true + Status + 50 + + +
+
+
+
diff --git a/onprc_ehr/resources/queries/onprc_ehr/NewBirthTasks.sql b/onprc_ehr/resources/queries/onprc_ehr/NewBirthTasks.sql new file mode 100644 index 000000000..2ec36e8b3 --- /dev/null +++ b/onprc_ehr/resources/queries/onprc_ehr/NewBirthTasks.sql @@ -0,0 +1,21 @@ +/** + * Created by Kollil, 10/25 + * Get a list of tasks daily on a rolling 7 day window to review for QC. + * This will allow techs to see what new IDs were created by whom, and review for accuracy, + * housing history, group ids and flags. + * Refer tkt # 13504 + */ +SELECT + t.taskid, + t.title, + t.formType as TaskType, + t.assignedto, + t.duedate, + t.createdby, + t.created, + t.qcstate as Status +FROM ehr.tasks t +WHERE t.created >= TIMESTAMPADD('day', -7Added new , NOW()) +And t.formtype = 'birth' + + diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/notification/ColonyAlertsNotification.java b/onprc_ehr/src/org/labkey/onprc_ehr/notification/ColonyAlertsNotification.java index 0a40e50fa..e88dc292b 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/notification/ColonyAlertsNotification.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/notification/ColonyAlertsNotification.java @@ -2333,6 +2333,33 @@ protected void duplicateFlags(Container c, User u, final StringBuilder msg) } } + /** + * Created by Kollil, 10/25 + * Get a list of tasks daily on a rolling 7 day window to review for QC. + * This will allow techs to see what new IDs were created by whom, and review for accuracy, + * housing history, group ids and flags. + * Refer tkt # 13504 + */ + protected void newBirthTasks(Container c, User u, final StringBuilder msg) + { + if (QueryService.get().getUserSchema(u, c, "onprc_ehr") == null) { + msg.append("Warning: The onprc_ehr schema has not been enabled in this folder, so the alert cannot run!


"); + return; + } + + //Get birth tasks + TableInfo ti = QueryService.get().getUserSchema(u, c, "onprc_ehr").getTable("NewBirthTasks", ContainerFilter.Type.AllFolders.create(c, u)); + TableSelector ts = new TableSelector(ti); + long count = ts.getRowCount(); + + if (count > 0) + { + msg.append("WARNING: There are " + count + " new birth(s) found in last 7 days.
"); + msg.append("

Click here to view them
\n"); + msg.append("


\n"); + } + } + /** * Created by Kollil, 9/6/23 * Get the new animals found with the flag, "NHPR NOTE: BCG Vaccinated". diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/notification/DataValidationNotification.java b/onprc_ehr/src/org/labkey/onprc_ehr/notification/DataValidationNotification.java index 79b34ea4c..fb0cb6f27 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/notification/DataValidationNotification.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/notification/DataValidationNotification.java @@ -112,6 +112,9 @@ public String getMessageBodyHTML(Container c, User u) birthRecordsNotMatchingHousing(c, u, msg); duplicateGroupMembership(c, u, msg); duplicateFlags(c, u, msg); + //Added by Kolli, Oct 2025 + //Tasks list alert for the new animal births + newBirthTasks(c, u, msg); //only send if there are alerts if (!msg.isEmpty()) From 67d0629620403a86160af97d4123510d8d59c2d2 Mon Sep 17 00:00:00 2001 From: kollil Date: Sat, 1 Nov 2025 13:48:49 -0700 Subject: [PATCH 2/5] Fixed the sql error --- .../queries/onprc_ehr/NewBirthTasks.sql | 2 +- .../notification/ColonyAlertsNotification.java | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/onprc_ehr/resources/queries/onprc_ehr/NewBirthTasks.sql b/onprc_ehr/resources/queries/onprc_ehr/NewBirthTasks.sql index 2ec36e8b3..841349e66 100644 --- a/onprc_ehr/resources/queries/onprc_ehr/NewBirthTasks.sql +++ b/onprc_ehr/resources/queries/onprc_ehr/NewBirthTasks.sql @@ -15,7 +15,7 @@ SELECT t.created, t.qcstate as Status FROM ehr.tasks t -WHERE t.created >= TIMESTAMPADD('day', -7Added new , NOW()) +WHERE t.created >= TIMESTAMPADD('day', -7, NOW()) And t.formtype = 'birth' diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/notification/ColonyAlertsNotification.java b/onprc_ehr/src/org/labkey/onprc_ehr/notification/ColonyAlertsNotification.java index e88dc292b..e84c5b7ac 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/notification/ColonyAlertsNotification.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/notification/ColonyAlertsNotification.java @@ -1551,7 +1551,7 @@ else if (rs.getString("ActiveClinicalTreatment") != null && rs.getString("Active protected void LongTermMedsAlert(final Container c, User u, final StringBuilder msg) { if (QueryService.get().getUserSchema(u, c, "onprc_ehr") == null) { - msg.append("Warning: The study schema has not been enabled in this folder, so the alert cannot run!


"); + msg.append("Warning: The onprc_ehr schema has not been enabled in this folder, so the alert cannot run!


"); return; } @@ -2340,7 +2340,7 @@ protected void duplicateFlags(Container c, User u, final StringBuilder msg) * housing history, group ids and flags. * Refer tkt # 13504 */ - protected void newBirthTasks(Container c, User u, final StringBuilder msg) + protected void newBirthTasks(final Container c, User u, final StringBuilder msg) { if (QueryService.get().getUserSchema(u, c, "onprc_ehr") == null) { msg.append("Warning: The onprc_ehr schema has not been enabled in this folder, so the alert cannot run!


"); @@ -2349,15 +2349,15 @@ protected void newBirthTasks(Container c, User u, final StringBuilder msg) //Get birth tasks TableInfo ti = QueryService.get().getUserSchema(u, c, "onprc_ehr").getTable("NewBirthTasks", ContainerFilter.Type.AllFolders.create(c, u)); - TableSelector ts = new TableSelector(ti); + TableSelector ts = new TableSelector(ti, null, null); long count = ts.getRowCount(); - if (count > 0) - { - msg.append("WARNING: There are " + count + " new birth(s) found in last 7 days.
"); - msg.append("

Click here to view them
\n"); - msg.append("


\n"); + if (count > 0) { + msg.append("
WARNING: There are \" + count + \" new birth(s) found in last 7 days.

"); + msg.append("

Click here to view them

\n"); + msg.append("
"); } + } /** From ca76cce7568abe0cbda486839b8d18154ce4c3d8 Mon Sep 17 00:00:00 2001 From: kollil Date: Sat, 1 Nov 2025 14:50:22 -0700 Subject: [PATCH 3/5] Fixed a missed quote in the message --- .../labkey/onprc_ehr/notification/ColonyAlertsNotification.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/notification/ColonyAlertsNotification.java b/onprc_ehr/src/org/labkey/onprc_ehr/notification/ColonyAlertsNotification.java index e84c5b7ac..8a5363df3 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/notification/ColonyAlertsNotification.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/notification/ColonyAlertsNotification.java @@ -2353,7 +2353,7 @@ protected void newBirthTasks(final Container c, User u, final StringBuilder msg) long count = ts.getRowCount(); if (count > 0) { - msg.append("
WARNING: There are \" + count + \" new birth(s) found in last 7 days.

"); + msg.append("WARNING: There are " + count + " new birth(s) found in last 7 days.
"); msg.append("

Click here to view them

\n"); msg.append("
"); } From 0e8bc007630aa4a969fb011ce4f35079839ed008 Mon Sep 17 00:00:00 2001 From: kollil Date: Mon, 24 Nov 2025 12:07:06 -0800 Subject: [PATCH 4/5] Added a comment --- .../onprc_ehr/notification/DataValidationNotification.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/notification/DataValidationNotification.java b/onprc_ehr/src/org/labkey/onprc_ehr/notification/DataValidationNotification.java index fb0cb6f27..8268a7fc0 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/notification/DataValidationNotification.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/notification/DataValidationNotification.java @@ -113,7 +113,7 @@ public String getMessageBodyHTML(Container c, User u) duplicateGroupMembership(c, u, msg); duplicateFlags(c, u, msg); //Added by Kolli, Oct 2025 - //Tasks list alert for the new animal births + //Tasks list alert for the new animal births, Refer to # 13504 newBirthTasks(c, u, msg); //only send if there are alerts From 959c5fd62e87ac68ca9b9508987ca3ba986f3c1d Mon Sep 17 00:00:00 2001 From: loganb Date: Thu, 27 Nov 2025 09:17:28 -0800 Subject: [PATCH 5/5] Minor comment change --- .../labkey/onprc_ehr/notification/ColonyAlertsNotification.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/notification/ColonyAlertsNotification.java b/onprc_ehr/src/org/labkey/onprc_ehr/notification/ColonyAlertsNotification.java index 8a5363df3..35a6e44a4 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/notification/ColonyAlertsNotification.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/notification/ColonyAlertsNotification.java @@ -2335,7 +2335,7 @@ protected void duplicateFlags(Container c, User u, final StringBuilder msg) /** * Created by Kollil, 10/25 - * Get a list of tasks daily on a rolling 7 day window to review for QC. + * Get a list of tasks daily on a rolling 7-day window to review for QC. * This will allow techs to see what new IDs were created by whom, and review for accuracy, * housing history, group ids and flags. * Refer tkt # 13504