diff --git a/onprc_ehr/resources/queries/onprc_ehr/Procedures_Missing_PainLevels.sql b/onprc_ehr/resources/queries/onprc_ehr/Procedures_Missing_PainLevels.sql
new file mode 100644
index 000000000..e01609faf
--- /dev/null
+++ b/onprc_ehr/resources/queries/onprc_ehr/Procedures_Missing_PainLevels.sql
@@ -0,0 +1,13 @@
+-- This query extracts the active procedures with missing USDA pain categories.
+-- Set the date range to 1 year back from curr date
+Select
+ e.id,
+ e.project,
+ e.date,
+ p.name,
+ p.PainCategories
+From study.encounters e, ehr_lookups.procedures p
+Where e.procedureid = p.rowid
+And p.active = 'true'
+And p.PainCategories IS NULL
+And date > timestampadd(SQL_TSI_YEAR,-1,now())
\ No newline at end of file
diff --git a/onprc_ehr/resources/scripts/onprc_ehr/onprc_triggers.js b/onprc_ehr/resources/scripts/onprc_ehr/onprc_triggers.js
index f8d1f8ea6..417b1c01d 100644
--- a/onprc_ehr/resources/scripts/onprc_ehr/onprc_triggers.js
+++ b/onprc_ehr/resources/scripts/onprc_ehr/onprc_triggers.js
@@ -379,6 +379,30 @@ exports.init = function(EHR){
}
});
+ // Added by Kollil, 12/22/2022: USDA Pain category validation:
+ /* This is user input validation for Procedures panel
+ 1. Stop the user if the user attempts to fill in USDA pain level while creating / modifying a procedure other than the IS team personnel.
+ */
+ EHR.Server.TriggerManager.registerHandlerForQuery(EHR.Server.TriggerManager.Events.BEFORE_UPSERT, 'ehr_lookups', 'procedures', function(helper, scriptErrors, row, oldRow) {
+ //console.log(" 0. procedure: " + row.procedureid + ", ins: " + row.instructions);
+
+ // When users other than IS team entering the procedure data, stop them until they clear the USDA pain level field data
+ /*
+ Lakshmi Kolli - 1008
+ Gary Jones - 1011
+ Raymond Blasa - 1007
+ Lindsay Amor - 2217
+ Brent Logan - 2933
+ */
+ if (row.PainCategories != null) {
+ if ( LABKEY.Security.currentUser.id !== 1008 || LABKEY.Security.currentUser.id !== 1007 || LABKEY.Security.currentUser.id !== 1011 || LABKEY.Security.currentUser.id !== 2217 || LABKEY.Security.currentUser.id !== 2933 )
+ {
+ EHR.Server.Utils.addError(scriptErrors, 'PainCategories', 'The USDA pain category field must be left blank if the user is not from ISE team!', 'WARN');
+ }
+ }
+
+ });
+
EHR.Server.TriggerManager.registerHandlerForQuery(EHR.Server.TriggerManager.Events.BEFORE_UPSERT, 'study', 'encounters', function(helper, scriptErrors, row, oldRow)
{
if (row.chargetype == 'Research Staff' && !row.assistingstaff && row.procedureid && triggerHelper.requiresAssistingStaff(row.procedureid))
@@ -1155,7 +1179,6 @@ exports.init = function(EHR){
}
});
-
//Added 3-5-2019 R.Blasa
EHR.Server.TriggerManager.registerHandlerForQuery(EHR.Server.TriggerManager.Events.AFTER_INSERT, 'ehr', 'project', function(helper, scriptErrors, row, oldRow){
diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java b/onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java
index 90e2f2a96..fed9f9c61 100644
--- a/onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java
+++ b/onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java
@@ -200,6 +200,9 @@ protected void doStartupAfterSpringConfig(ModuleContext moduleContext)
//Added Mar 18th, 2021 Kollil
ns.registerNotification(new HousingTransferNotification(this));
+ //Added Dec 2022, Kollil
+ ns.registerNotification(new USDAPainNotification(this));
+
//Added 8-7-2018 R.Blasa
ns.registerNotification(new BirthHousingMismatchNotification(this));
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 91540b6dc..7306ef851 100644
--- a/onprc_ehr/src/org/labkey/onprc_ehr/notification/ColonyAlertsNotification.java
+++ b/onprc_ehr/src/org/labkey/onprc_ehr/notification/ColonyAlertsNotification.java
@@ -722,7 +722,6 @@ protected void recordsEnteredMoreThan7DaysAfter(final Container c, User u, final
}
-
/**
* find the total finalized records with future dates
*/
@@ -1338,7 +1337,74 @@ protected void pmicServicesRequestAlert(final Container c, User u, final StringB
msg.append("WARNING: There are no scheduled PMIC procedures!
Click here to view the procedures in PRIME
\n"); + msg.append("| Id | Center Project | Date | Procedure | USDA Categories | " + PageFlowUtil.filter(rs.getString("Id")) + " | "); + msg.append("" + PageFlowUtil.filter(rs.getString("project")) + " | "); + msg.append("" + PageFlowUtil.filter(rs.getString("date")) + " | "); + msg.append("" + PageFlowUtil.filter(rs.getString("name")) + " | "); + msg.append("" + PageFlowUtil.filter(rs.getString("PainCategories")) + " | "); + msg.append(""); + } + }); + msg.append("