From ec2a8ed70ed2109c45da1a913b3099ab885d84fe Mon Sep 17 00:00:00 2001 From: Lakshmi Kolli <69940873+kollil@users.noreply.github.com> Date: Wed, 8 Jun 2022 19:32:43 -0700 Subject: [PATCH 01/12] Added a trigger to enter the snomed code entry into snomed_tags table. --- .../scripts/onprc_ehr/onprc_triggers.js | 9 ++++ .../query/ONPRC_EHRTriggerHelper.java | 47 +++++++++++++++++-- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/onprc_ehr/resources/scripts/onprc_ehr/onprc_triggers.js b/onprc_ehr/resources/scripts/onprc_ehr/onprc_triggers.js index 712852b0b..725ffba94 100644 --- a/onprc_ehr/resources/scripts/onprc_ehr/onprc_triggers.js +++ b/onprc_ehr/resources/scripts/onprc_ehr/onprc_triggers.js @@ -699,6 +699,15 @@ exports.init = function(EHR){ } }); + //Added: By Kollil on 5/31/2022 + //When the Tattoo procedure is selected, add snomedcode: P-12090 TATTOOING + EHR.Server.TriggerManager.registerHandlerForQuery(EHR.Server.TriggerManager.Events.AFTER_UPSERT, 'study', 'encounters', function(helper, errors, row, oldRow){ + if (row.procedureid == 760){ + //Add snomed code. + triggerHelper.addTattooSnomedCode(row.Id, row); + } + }); + EHR.Server.TriggerManager.registerHandlerForQuery(EHR.Server.TriggerManager.Events.BEFORE_UPSERT, 'study', 'drug', function(helper, scriptErrors, row, oldRow){ if (row.outcome && row.outcome != 'Normal' && !row.remark){ EHR.Server.Utils.addError(scriptErrors, 'remark', 'A remark is required if a non-normal outcome is reported', 'WARN'); diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/query/ONPRC_EHRTriggerHelper.java b/onprc_ehr/src/org/labkey/onprc_ehr/query/ONPRC_EHRTriggerHelper.java index d70ffb5d5..6de098989 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/query/ONPRC_EHRTriggerHelper.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/query/ONPRC_EHRTriggerHelper.java @@ -185,7 +185,8 @@ public Map getExtraContext() return map; } - //Added by Kolli 3/3/20 + + //Added by Kolli 3/3/20 //This function automatically sets the study details endDate if previous study details endDate is empty when a new study is created. public void closeStudyDetailsRecords(List> records) throws Exception { @@ -1093,6 +1094,7 @@ private Date maxDate(Date d1, Date d2) return (d1.after(d2)) ? d1 : d2; } + public void closeActiveAssignmentRecords(String id, Date deathDate, String causeOfDeath) throws Exception { try @@ -1147,6 +1149,44 @@ public void closeActiveAssignmentRecords(String id, Date deathDate, String cause } } + /*Added by Kolli 3/3/20 + When a tattoo procedure is entered into study.encounters table enter a snomed code into ehr.snomed_tags + Id - Animalid + Date - now() + code - TATTOOING + code/code - P-12090 + */ + public void addTattooSnomedCode(String id, @NotNull Map row) throws QueryUpdateServiceException, DuplicateKeyException, SQLException, BatchValidationException + { + if (id != null) + { + _log.info("Animal Id thats tattooed: " + id); + Map snomedProps = new HashMap(); + + snomedProps.put("Id", row.get("Id")); + snomedProps.put("date", row.get("date")); + snomedProps.put("code", "TATTOOING"); + //snomedProps.put("code/code", "P-12090"); + + _log.info("props: " + snomedProps); + + TableInfo ti = getTableInfo("ehr", "snomed_tags"); + Map new_row = new CaseInsensitiveHashMap<>(); + new_row.putAll(snomedProps); + + List> rows = new ArrayList<>(); + rows.add(new_row); + + BatchValidationException errors = new BatchValidationException(); + //Insert row into the db table + ti.getUpdateService().insertRows(getUser(), getContainer(), rows, errors, null, getExtraContext()); + + if (errors.hasErrors()) + throw errors; + + } + } + //Added on 10/5/2016, L.Kolli public Map onAnimalArrival_AddDemographics(String id, Map row) throws QueryUpdateServiceException, DuplicateKeyException, SQLException, BatchValidationException { @@ -1228,6 +1268,7 @@ public void createBirthRecord_ONPRC(String id, Map props) throws } } + // Added: 6-27-2017 F.Blasa Process when transitioning from Prenatal - Fetus to Live public void doBirthConditionAfterPrenatal(String id, Date date, String dam, Date Arrival_Date, String birthCondition, boolean isBecomingPublic) throws Exception { @@ -2119,6 +2160,7 @@ public String validateCaseNo(String caseNo, String type, String objectid) { SimpleFilter filter = new SimpleFilter(FieldKey.fromString("caseno"), caseNo); filter.addCondition(FieldKey.fromString("type"), type); + if (objectid != null) { filter.addCondition(FieldKey.fromString("objectid"), objectid, CompareType.NEQ_OR_NULL); @@ -2128,8 +2170,6 @@ public String validateCaseNo(String caseNo, String type, String objectid) { return "There is already an existing case with the number: " + caseNo; } - - return null; } @@ -2337,7 +2377,6 @@ public void exec(ResultSet rs) throws SQLException } - //Added 3-6-2019 Blasa public void sendProjectNotifications(Integer projectid) { From e4d4e9a3ea515c2fc41037573bb11914831eb998 Mon Sep 17 00:00:00 2001 From: Lakshmi Kolli <69940873+kollil@users.noreply.github.com> Date: Mon, 20 Jun 2022 16:47:23 -0700 Subject: [PATCH 02/12] Added GUID and container data. --- .../org/labkey/onprc_ehr/query/ONPRC_EHRTriggerHelper.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/query/ONPRC_EHRTriggerHelper.java b/onprc_ehr/src/org/labkey/onprc_ehr/query/ONPRC_EHRTriggerHelper.java index 6de098989..3c708058b 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/query/ONPRC_EHRTriggerHelper.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/query/ONPRC_EHRTriggerHelper.java @@ -1149,7 +1149,7 @@ public void closeActiveAssignmentRecords(String id, Date deathDate, String cause } } - /*Added by Kolli 3/3/20 + /*Added by Kolli 6/3/22 When a tattoo procedure is entered into study.encounters table enter a snomed code into ehr.snomed_tags Id - Animalid Date - now() @@ -1166,6 +1166,8 @@ public void addTattooSnomedCode(String id, @NotNull Map row) thr snomedProps.put("Id", row.get("Id")); snomedProps.put("date", row.get("date")); snomedProps.put("code", "TATTOOING"); + snomedProps.put("objectId", new GUID()); + snomedProps.put("container", "CD17027B-C55F-102F-9907-5107380A54BE"); //snomedProps.put("code/code", "P-12090"); _log.info("props: " + snomedProps); From 1e642bfba88096364f182172f5f6b929fe526e98 Mon Sep 17 00:00:00 2001 From: Lakshmi Kolli <69940873+kollil@users.noreply.github.com> Date: Tue, 21 Jun 2022 14:27:27 -0700 Subject: [PATCH 03/12] Added the container global variable. --- .../labkey/onprc_ehr/query/ONPRC_EHRTriggerHelper.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/query/ONPRC_EHRTriggerHelper.java b/onprc_ehr/src/org/labkey/onprc_ehr/query/ONPRC_EHRTriggerHelper.java index 3c708058b..ca58d900a 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/query/ONPRC_EHRTriggerHelper.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/query/ONPRC_EHRTriggerHelper.java @@ -1160,17 +1160,16 @@ public void addTattooSnomedCode(String id, @NotNull Map row) thr { if (id != null) { - _log.info("Animal Id thats tattooed: " + id); + //_log.info("Animal Id thats tattooed: " + id); Map snomedProps = new HashMap(); snomedProps.put("Id", row.get("Id")); snomedProps.put("date", row.get("date")); - snomedProps.put("code", "TATTOOING"); + snomedProps.put("code", "P-12090"); snomedProps.put("objectId", new GUID()); - snomedProps.put("container", "CD17027B-C55F-102F-9907-5107380A54BE"); - //snomedProps.put("code/code", "P-12090"); + snomedProps.put("container", _container.getId()); - _log.info("props: " + snomedProps); + //_log.info("props: " + snomedProps); TableInfo ti = getTableInfo("ehr", "snomed_tags"); Map new_row = new CaseInsensitiveHashMap<>(); From 1cf123506fffca3cb72c69f0a0f9f8da340aca33 Mon Sep 17 00:00:00 2001 From: Lakshmi Kolli <69940873+kollil@users.noreply.github.com> Date: Wed, 22 Jun 2022 15:48:32 -0700 Subject: [PATCH 04/12] Added the alert code --- .../resources/queries/study/TattooAlert.sql | 4 ++ .../RoutineClinicalTestsNotification.java | 48 ++++++++++++++++++- 2 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 onprc_ehr/resources/queries/study/TattooAlert.sql diff --git a/onprc_ehr/resources/queries/study/TattooAlert.sql b/onprc_ehr/resources/queries/study/TattooAlert.sql new file mode 100644 index 000000000..89924cbda --- /dev/null +++ b/onprc_ehr/resources/queries/study/TattooAlert.sql @@ -0,0 +1,4 @@ +Select Id, birth, gender from study.demographics a +Where a.calculated_status = 'Alive' + And a.id not in (Select id from study.arrival where acquisitiontype = 6) --6= Purchase + And a.id not in (Select id from study.encounters where procedureid = 760) \ No newline at end of file diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/notification/RoutineClinicalTestsNotification.java b/onprc_ehr/src/org/labkey/onprc_ehr/notification/RoutineClinicalTestsNotification.java index e3ccb637a..99339d388 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/notification/RoutineClinicalTestsNotification.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/notification/RoutineClinicalTestsNotification.java @@ -18,6 +18,7 @@ import org.labkey.api.data.ColumnInfo; import org.labkey.api.data.CompareType; import org.labkey.api.data.Container; +import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.ResultsImpl; import org.labkey.api.data.Selector; import org.labkey.api.data.SimpleFilter; @@ -92,8 +93,7 @@ public String getMessageBodyHTML(Container c, User u) getTbAlerts(sb, c, u); getPEAlerts(sb, c, u); getAnimalsNotWeightedInPast60Days(sb, c, u); - - //getVirologyAlerts(sb, c, u); + getTattooAlerts(sb, c, u); return sb.toString(); } @@ -295,4 +295,48 @@ protected void getAnimalsNotWeightedInPast60Days(StringBuilder msg, Container c, msg.append("
\n"); } + + /** + * Kollil, 6/01/22 : List the animalIds with missing Tattoos, i.e, Animals with no Tattoo procedure, ProcedureId = 760 + */ + protected void getTattooAlerts(StringBuilder msg, Container c, User u) + { + msg.append("Animals with missing Tattoo procedure:

\n"); + + if (QueryService.get().getUserSchema(u, c, "study") == null) { + msg.append("Warning: The study schema has not been enabled in this folder, so the alert cannot run!


"); + return; + } + //Tattoo query + TableInfo ti = QueryService.get().getUserSchema(u, c, "study").getTable("TattooAlert", ContainerFilter.Type.AllFolders.create(c, u)); + Set cols = appendLocationCols(ti); + TableSelector ts = new TableSelector(ti, cols, null, null); + long count = ts.getRowCount(); + + //Get num of rows + if (count > 0) + { + msg.append("ALERT: " + count + " animals found with no Tattoo procedure recorded in Prime:"); + msg.append("

Click here to view them

\n"); + //String url = getExecuteQueryUrl(c, "study", "Demographics", "By Location") + "&query.Id/MostRecentWeight/DaysSinceWeight~gt=75&query.calculated_status~eq=Alive&query.Id/curLocation/Room/housingType/value~eq=Cage Location"; + String url = getExecuteQueryUrl(c, "study", "TattooAlert", null) + "&query.containerFilterName=AllFolders"; + msg.append("Click here to view them.

\n"); + + msg.append("Summary by area:
\n"); + msg.append(""); + Map areaMap = getAreaMap(ts, cols); + for (String area : areaMap.keySet()) + { + String newUrl = url + "&query.Id/curLocation/area~eq=" + area; + msg.append("\n"); + } + msg.append("
" + area + ": " + areaMap.get(area) + "
"); + msg.append("

"); + } + else + { + msg.append(" All live animals at the center are tattooed! "); + } + msg.append("
\n"); + } } From 12443729ea99b6ab08a4aefcae50240bcb6573bd Mon Sep 17 00:00:00 2001 From: Lakshmi Kolli <69940873+kollil@users.noreply.github.com> Date: Wed, 22 Jun 2022 21:18:29 -0700 Subject: [PATCH 05/12] Deleted the duplicate link on the alert --- .../onprc_ehr/notification/RoutineClinicalTestsNotification.java | 1 - 1 file changed, 1 deletion(-) diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/notification/RoutineClinicalTestsNotification.java b/onprc_ehr/src/org/labkey/onprc_ehr/notification/RoutineClinicalTestsNotification.java index 99339d388..66359d2ab 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/notification/RoutineClinicalTestsNotification.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/notification/RoutineClinicalTestsNotification.java @@ -317,7 +317,6 @@ protected void getTattooAlerts(StringBuilder msg, Container c, User u) if (count > 0) { msg.append("ALERT: " + count + " animals found with no Tattoo procedure recorded in Prime:"); - msg.append("

Click here to view them

\n"); //String url = getExecuteQueryUrl(c, "study", "Demographics", "By Location") + "&query.Id/MostRecentWeight/DaysSinceWeight~gt=75&query.calculated_status~eq=Alive&query.Id/curLocation/Room/housingType/value~eq=Cage Location"; String url = getExecuteQueryUrl(c, "study", "TattooAlert", null) + "&query.containerFilterName=AllFolders"; msg.append("Click here to view them.

\n"); From 7dd3595fcc2f578215b56b7f333d2ec36a44579a Mon Sep 17 00:00:00 2001 From: Lakshmi Kolli <69940873+kollil@users.noreply.github.com> Date: Fri, 15 Jul 2022 12:26:29 -0700 Subject: [PATCH 06/12] Updated tattoo sql --- onprc_ehr/resources/queries/study/TattooAlert.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onprc_ehr/resources/queries/study/TattooAlert.sql b/onprc_ehr/resources/queries/study/TattooAlert.sql index 89924cbda..dc0d791da 100644 --- a/onprc_ehr/resources/queries/study/TattooAlert.sql +++ b/onprc_ehr/resources/queries/study/TattooAlert.sql @@ -1,4 +1,4 @@ Select Id, birth, gender from study.demographics a Where a.calculated_status = 'Alive' And a.id not in (Select id from study.arrival where acquisitiontype = 6) --6= Purchase - And a.id not in (Select id from study.encounters where procedureid = 760) \ No newline at end of file + And a.id not in (Select id from study.encounters where procedureid = 760) -- TATTOO procedure \ No newline at end of file From 03f1d45b0218533e95e396bbc4f64e28346906d0 Mon Sep 17 00:00:00 2001 From: kollil Date: Mon, 8 Aug 2022 12:56:44 -0700 Subject: [PATCH 07/12] Added the alert msg --- onprc_ehr/resources/queries/study/TattooAlert.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/onprc_ehr/resources/queries/study/TattooAlert.sql b/onprc_ehr/resources/queries/study/TattooAlert.sql index dc0d791da..10fdc10a6 100644 --- a/onprc_ehr/resources/queries/study/TattooAlert.sql +++ b/onprc_ehr/resources/queries/study/TattooAlert.sql @@ -1,3 +1,4 @@ +-- Displays animals with no tattoo proc recorded Select Id, birth, gender from study.demographics a Where a.calculated_status = 'Alive' And a.id not in (Select id from study.arrival where acquisitiontype = 6) --6= Purchase From c9abd51b19843090d37a67cfe398165aba2cde56 Mon Sep 17 00:00:00 2001 From: kollil Date: Tue, 30 Aug 2022 15:53:53 -0700 Subject: [PATCH 08/12] Added the alert msg --- onprc_ehr/resources/queries/study/TattooAlert.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onprc_ehr/resources/queries/study/TattooAlert.sql b/onprc_ehr/resources/queries/study/TattooAlert.sql index 10fdc10a6..bfb0475cd 100644 --- a/onprc_ehr/resources/queries/study/TattooAlert.sql +++ b/onprc_ehr/resources/queries/study/TattooAlert.sql @@ -1,4 +1,4 @@ --- Displays animals with no tattoo proc recorded +-- Displays all animals with no tattoo procedure recorded excluding the purchased animals Select Id, birth, gender from study.demographics a Where a.calculated_status = 'Alive' And a.id not in (Select id from study.arrival where acquisitiontype = 6) --6= Purchase From fd0ed7fa164713be75d1b5a12a577ac9838550a5 Mon Sep 17 00:00:00 2001 From: kollil Date: Thu, 13 Oct 2022 17:44:29 -0700 Subject: [PATCH 09/12] Changed the notifications. --- .../web/onprc_ehr/model/sources/PMIC_PET.js | 4 +- .../ClinicalRoundsNotification.java | 115 +++++++++++++++++- .../notification/VetReviewNotification.java | 9 +- 3 files changed, 120 insertions(+), 8 deletions(-) diff --git a/onprc_ehr/resources/web/onprc_ehr/model/sources/PMIC_PET.js b/onprc_ehr/resources/web/onprc_ehr/model/sources/PMIC_PET.js index 33402f046..4ad181461 100644 --- a/onprc_ehr/resources/web/onprc_ehr/model/sources/PMIC_PET.js +++ b/onprc_ehr/resources/web/onprc_ehr/model/sources/PMIC_PET.js @@ -34,8 +34,8 @@ EHR.model.DataModelManager.registerMetadata('PET', { chargeType: { allowBlank: true, hidden: false, - defaultValue: 'PMIC' - + defaultValue: 'PMIC', + editable: false }, examNum: { diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/notification/ClinicalRoundsNotification.java b/onprc_ehr/src/org/labkey/onprc_ehr/notification/ClinicalRoundsNotification.java index 2c719c49d..fb3ad3192 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/notification/ClinicalRoundsNotification.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/notification/ClinicalRoundsNotification.java @@ -62,21 +62,27 @@ public String getEmailSubject(Container c) } @Override +// public String getCronString() +// { +// return "0 0 15 * * ?"; +// } + + //Kollil 10/13: Changed the daily alert to Tuesdays and Thursdays public String getCronString() { - return "0 0 15 * * ?"; + return "0 0 15 ? * TUE,THU"; } @Override public String getScheduleDescription() { - return "every day at 3PM"; + return "every Tuesday & Thursday at 3PM"; } @Override public String getDescription() { - return "The report is designed alert if there are any animals without rounds observations entered or lacking vet review"; + return "The report is designed to alert if there are any animals without rounds observations entered or lacking vet review. Also, contains the report to alert for Clinical rounds observations entered today, and not entered recently"; } @Override @@ -88,6 +94,10 @@ public String getMessageBodyHTML(Container c, User u) animalsWithoutRounds(c, u, msg); //animalsWithoutVetReview(c, u, msg); + //Clinical process alerts : kollil byt 10/13 + animalsWithRounds(c, u, msg); //Added: 8-22-2016 R.Blasa + animalsWithoutRounds2(c, u, msg); //Added 8-29-2016 + return msg.toString(); } @@ -188,4 +198,101 @@ public void exec(ResultSet object) throws SQLException msg.append("
\n"); } } -} + + //Clinical process alerts + protected void animalsWithoutRounds2(final Container c, User u, final StringBuilder msg) + { + SimpleFilter filter = new SimpleFilter(FieldKey.fromString("daysSinceLastRounds"), 0, CompareType.GT); + filter.addCondition(FieldKey.fromString("isActive"), true, CompareType.EQUAL); + filter.addCondition(FieldKey.fromString("category"), "Clinical", CompareType.EQUAL); + filter.addCondition(FieldKey.fromString("Id/demographics/calculated_status"), "Alive", CompareType.EQUAL); + + TableInfo ti = getStudySchema(c, u).getTable("cases"); + Set keys = new HashSet<>(); + keys.add(FieldKey.fromString("Id")); + keys.add(FieldKey.fromString("Id/curLocation/room")); + keys.add(FieldKey.fromString("Id/curLocation/cage")); + keys.add(FieldKey.fromString("daysSinceLastRounds")); + keys.add(FieldKey.fromString("assignedvet/DisplayName")); + keys.add(FieldKey.fromString("allProblemCategories")); + final Map cols = QueryService.get().getColumns(ti, keys); + + TableSelector ts = new TableSelector(ti, cols.values(), filter, new Sort("Id/curLocation/room_sortValue,Id/curLocation/cage_sortValue")); + long count = ts.getRowCount(); + if (count > 0) + { + msg.append("WARNING: There are " + count + " active cases that do not have obs entered today.
"); + msg.append(""); + msg.append(""); + + ts.forEach(new Selector.ForEachBlock() + { + @Override + public void exec(ResultSet object) throws SQLException + { + Results rs = new ResultsImpl(object, cols); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); + } + }); + + msg.append("
RoomCageIdAssigned VetProblem(s)Days Since Last Rounds
" + safeAppend(rs.getString(FieldKey.fromString("Id/curLocation/room")), "None") + "" + safeAppend(rs.getString(FieldKey.fromString("Id/curLocation/cage")), "") + "" + rs.getString(FieldKey.fromString("Id")) + "" + safeAppend(rs.getString(FieldKey.fromString("assignedvet/DisplayName")), "None") + "" + safeAppend(rs.getString(FieldKey.fromString("allProblemCategories")), "None") + "" + safeAppend(rs.getString(FieldKey.fromString("daysSinceLastRounds")), "") + "
"); + msg.append("
\n"); + } + } + + //Modified: 8-15-2016 R.Blasa Show Clinical open cases that were entered + protected void animalsWithRounds(final Container c, User u, final StringBuilder msg) + { + SimpleFilter filter = new SimpleFilter(FieldKey.fromString("daysSinceLastRounds"), 0, CompareType.EQUAL); + filter.addCondition(FieldKey.fromString("isActive"), true, CompareType.EQUAL); + filter.addCondition(FieldKey.fromString("category"), "Clinical", CompareType.EQUAL); + filter.addCondition(FieldKey.fromString("Id/demographics/calculated_status"), "Alive", CompareType.EQUAL); + + TableInfo ti = getStudySchema(c, u).getTable("cases"); + Set keys = new HashSet<>(); + keys.add(FieldKey.fromString("Id")); + keys.add(FieldKey.fromString("Id/curLocation/room")); + keys.add(FieldKey.fromString("Id/curLocation/cage")); + keys.add(FieldKey.fromString("daysSinceLastRounds")); + keys.add(FieldKey.fromString("assignedvet/DisplayName")); + keys.add(FieldKey.fromString("allProblemCategories")); + final Map cols = QueryService.get().getColumns(ti, keys); + + TableSelector ts = new TableSelector(ti, cols.values(), filter, new Sort("Id/curLocation/room_sortValue,Id/curLocation/cage_sortValue")); + long count = ts.getRowCount(); + if (count > 0) + { + msg.append("CONFIRMATION: There are " + count + " active cases that have their obs entered today.
"); + msg.append(""); + msg.append(""); + + ts.forEach(new Selector.ForEachBlock() + { + @Override + public void exec(ResultSet object) throws SQLException + { + Results rs = new ResultsImpl(object, cols); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); + + msg.append(""); + } + }); + + msg.append("
RoomCageIdAssigned VetProblem(s)
" + safeAppend(rs.getString(FieldKey.fromString("Id/curLocation/room")), "None") + "" + safeAppend(rs.getString(FieldKey.fromString("Id/curLocation/cage")), "") + "" + rs.getString(FieldKey.fromString("Id")) + "" + safeAppend(rs.getString(FieldKey.fromString("assignedvet/DisplayName")), "None") + "" + safeAppend(rs.getString(FieldKey.fromString("allProblemCategories")), "None") + "
"); + msg.append("
\n"); + } + } + + } diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/notification/VetReviewNotification.java b/onprc_ehr/src/org/labkey/onprc_ehr/notification/VetReviewNotification.java index 3e30b8c7e..e454b213d 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/notification/VetReviewNotification.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/notification/VetReviewNotification.java @@ -63,15 +63,20 @@ public String getEmailSubject(Container c) } @Override +// public String getCronString() +// { +// return "0 0 15 * * ?"; +// } + //Kollil 10/13: Changed the daily alert to once a week, Wednesdays public String getCronString() { - return "0 0 15 * * ?"; + return "0 0 15 ? * WED"; } @Override public String getScheduleDescription() { - return "daily at 3PM"; + return "every Wednesday at 3PM"; } @Override From 31394bb47742122edaaf0a932d0e8d61f15a9784 Mon Sep 17 00:00:00 2001 From: kollil Date: Mon, 17 Oct 2022 15:55:01 -0700 Subject: [PATCH 10/12] Update the alert code. --- .../ClinicalRoundsNotification.java | 109 ++++++++++-------- 1 file changed, 59 insertions(+), 50 deletions(-) diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/notification/ClinicalRoundsNotification.java b/onprc_ehr/src/org/labkey/onprc_ehr/notification/ClinicalRoundsNotification.java index fb3ad3192..7bfbfce88 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/notification/ClinicalRoundsNotification.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/notification/ClinicalRoundsNotification.java @@ -90,13 +90,13 @@ public String getMessageBodyHTML(Container c, User u) { StringBuilder msg = new StringBuilder(); - duplicateCases(c, u, msg); + //duplicateCases(c, u, msg); animalsWithoutRounds(c, u, msg); - //animalsWithoutVetReview(c, u, msg); + animalsWithoutVetReview(c, u, msg); - //Clinical process alerts : kollil byt 10/13 + //Clinical process alerts : Kollil, 10/13/22 animalsWithRounds(c, u, msg); //Added: 8-22-2016 R.Blasa - animalsWithoutRounds2(c, u, msg); //Added 8-29-2016 + //animalsWithoutRounds2(c, u, msg); //Added 8-29-2016 return msg.toString(); } @@ -122,6 +122,7 @@ protected void animalsWithoutRounds(final Container c, User u, final StringBuild long count = ts.getRowCount(); if (count > 0) { + msg.append("Clinical Rounds Alerts: Active cases that do not have observations.
"); msg.append("WARNING: There are " + count + " active cases that do not have obs entered today.
"); msg.append(""); msg.append(""); @@ -173,6 +174,7 @@ protected void animalsWithoutVetReview(final Container c, User u, final StringBu long count = ts.getRowCount(); if (count > 0) { + msg.append("Clinical Rounds Alerts: Active cases with no Vet review.
"); msg.append("WARNING: There are " + count + " active cases that have not been vet reviewed in the past 7 days.
"); msg.append("
RoomCageIdAssigned VetProblem(s)Days Since Last Rounds
"); msg.append(""); @@ -200,52 +202,7 @@ public void exec(ResultSet object) throws SQLException } //Clinical process alerts - protected void animalsWithoutRounds2(final Container c, User u, final StringBuilder msg) - { - SimpleFilter filter = new SimpleFilter(FieldKey.fromString("daysSinceLastRounds"), 0, CompareType.GT); - filter.addCondition(FieldKey.fromString("isActive"), true, CompareType.EQUAL); - filter.addCondition(FieldKey.fromString("category"), "Clinical", CompareType.EQUAL); - filter.addCondition(FieldKey.fromString("Id/demographics/calculated_status"), "Alive", CompareType.EQUAL); - - TableInfo ti = getStudySchema(c, u).getTable("cases"); - Set keys = new HashSet<>(); - keys.add(FieldKey.fromString("Id")); - keys.add(FieldKey.fromString("Id/curLocation/room")); - keys.add(FieldKey.fromString("Id/curLocation/cage")); - keys.add(FieldKey.fromString("daysSinceLastRounds")); - keys.add(FieldKey.fromString("assignedvet/DisplayName")); - keys.add(FieldKey.fromString("allProblemCategories")); - final Map cols = QueryService.get().getColumns(ti, keys); - - TableSelector ts = new TableSelector(ti, cols.values(), filter, new Sort("Id/curLocation/room_sortValue,Id/curLocation/cage_sortValue")); - long count = ts.getRowCount(); - if (count > 0) - { - msg.append("WARNING: There are " + count + " active cases that do not have obs entered today.
"); - msg.append("
RoomCageIdAssigned VetProblem(s)Days Since last Vet Review
"); - msg.append(""); - - ts.forEach(new Selector.ForEachBlock() - { - @Override - public void exec(ResultSet object) throws SQLException - { - Results rs = new ResultsImpl(object, cols); - msg.append(""); - msg.append(""); - msg.append(""); - msg.append(""); - msg.append(""); - msg.append(""); - msg.append(""); - msg.append(""); - } - }); - - msg.append("
RoomCageIdAssigned VetProblem(s)Days Since Last Rounds
" + safeAppend(rs.getString(FieldKey.fromString("Id/curLocation/room")), "None") + "" + safeAppend(rs.getString(FieldKey.fromString("Id/curLocation/cage")), "") + "" + rs.getString(FieldKey.fromString("Id")) + "" + safeAppend(rs.getString(FieldKey.fromString("assignedvet/DisplayName")), "None") + "" + safeAppend(rs.getString(FieldKey.fromString("allProblemCategories")), "None") + "" + safeAppend(rs.getString(FieldKey.fromString("daysSinceLastRounds")), "") + "
"); - msg.append("
\n"); - } - } +// //Modified: 8-15-2016 R.Blasa Show Clinical open cases that were entered protected void animalsWithRounds(final Container c, User u, final StringBuilder msg) @@ -267,8 +224,10 @@ protected void animalsWithRounds(final Container c, User u, final StringBuilder TableSelector ts = new TableSelector(ti, cols.values(), filter, new Sort("Id/curLocation/room_sortValue,Id/curLocation/cage_sortValue")); long count = ts.getRowCount(); + if (count > 0) { + msg.append("Clinical Rounds Process Alerts: Active cases that have observations.
"); msg.append("CONFIRMATION: There are " + count + " active cases that have their obs entered today.
"); msg.append(""); msg.append(""); @@ -295,4 +254,54 @@ public void exec(ResultSet object) throws SQLException } } + + // protected void animalsWithoutRounds2(final Container c, User u, final StringBuilder msg) +// { +// SimpleFilter filter = new SimpleFilter(FieldKey.fromString("daysSinceLastRounds"), 0, CompareType.GT); +// filter.addCondition(FieldKey.fromString("isActive"), true, CompareType.EQUAL); +// filter.addCondition(FieldKey.fromString("category"), "Clinical", CompareType.EQUAL); +// filter.addCondition(FieldKey.fromString("Id/demographics/calculated_status"), "Alive", CompareType.EQUAL); +// +// TableInfo ti = getStudySchema(c, u).getTable("cases"); +// Set keys = new HashSet<>(); +// keys.add(FieldKey.fromString("Id")); +// keys.add(FieldKey.fromString("Id/curLocation/room")); +// keys.add(FieldKey.fromString("Id/curLocation/cage")); +// keys.add(FieldKey.fromString("daysSinceLastRounds")); +// keys.add(FieldKey.fromString("assignedvet/DisplayName")); +// keys.add(FieldKey.fromString("allProblemCategories")); +// final Map cols = QueryService.get().getColumns(ti, keys); +// +// TableSelector ts = new TableSelector(ti, cols.values(), filter, new Sort("Id/curLocation/room_sortValue,Id/curLocation/cage_sortValue")); +// long count = ts.getRowCount(); +// +// if (count > 0) +// { +// msg.append("Clinical Rounds Process Alerts: Active cases that do not have observations entered today.
"); +// msg.append("WARNING: There are " + count + " active cases that do not have obs entered today.
"); +// msg.append("
RoomCageIdAssigned VetProblem(s)
"); +// msg.append(""); +// +// ts.forEach(new Selector.ForEachBlock() +// { +// @Override +// public void exec(ResultSet object) throws SQLException +// { +// Results rs = new ResultsImpl(object, cols); +// msg.append(""); +// msg.append(""); +// msg.append(""); +// msg.append(""); +// msg.append(""); +// msg.append(""); +// msg.append(""); +// msg.append(""); +// } +// }); +// +// msg.append("
RoomCageIdAssigned VetProblem(s)Days Since Last Rounds
" + safeAppend(rs.getString(FieldKey.fromString("Id/curLocation/room")), "None") + "" + safeAppend(rs.getString(FieldKey.fromString("Id/curLocation/cage")), "") + "" + rs.getString(FieldKey.fromString("Id")) + "" + safeAppend(rs.getString(FieldKey.fromString("assignedvet/DisplayName")), "None") + "" + safeAppend(rs.getString(FieldKey.fromString("allProblemCategories")), "None") + "" + safeAppend(rs.getString(FieldKey.fromString("daysSinceLastRounds")), "") + "
"); +// msg.append("
\n"); +// } +// } + } From 82b00476fb1703d37db40362454f319c809c28b3 Mon Sep 17 00:00:00 2001 From: kollil Date: Mon, 17 Oct 2022 18:29:48 -0700 Subject: [PATCH 11/12] Updated #2 --- .../notification/ClinicalRoundsNotification.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/notification/ClinicalRoundsNotification.java b/onprc_ehr/src/org/labkey/onprc_ehr/notification/ClinicalRoundsNotification.java index 7bfbfce88..e1324b62b 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/notification/ClinicalRoundsNotification.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/notification/ClinicalRoundsNotification.java @@ -90,9 +90,9 @@ public String getMessageBodyHTML(Container c, User u) { StringBuilder msg = new StringBuilder(); - //duplicateCases(c, u, msg); + duplicateCases(c, u, msg); animalsWithoutRounds(c, u, msg); - animalsWithoutVetReview(c, u, msg); + animalsWithoutVetReview(c, u, msg); //Clinical process alerts : Kollil, 10/13/22 animalsWithRounds(c, u, msg); //Added: 8-22-2016 R.Blasa @@ -123,7 +123,7 @@ protected void animalsWithoutRounds(final Container c, User u, final StringBuild if (count > 0) { msg.append("Clinical Rounds Alerts: Active cases that do not have observations.
"); - msg.append("WARNING: There are " + count + " active cases that do not have obs entered today.
"); + msg.append("WARNING: " + count + " active case(s) found that do not have obs entered today.
"); msg.append(""); msg.append(""); @@ -175,7 +175,7 @@ protected void animalsWithoutVetReview(final Container c, User u, final StringBu if (count > 0) { msg.append("Clinical Rounds Alerts: Active cases with no Vet review.
"); - msg.append("WARNING: There are " + count + " active cases that have not been vet reviewed in the past 7 days.
"); + msg.append("WARNING: " + count + " active case(s) found that have not been vet reviewed in the past 7 days.
"); msg.append("
RoomCageIdAssigned VetProblem(s)Days Since Last Rounds
"); msg.append(""); @@ -228,7 +228,7 @@ protected void animalsWithRounds(final Container c, User u, final StringBuilder if (count > 0) { msg.append("Clinical Rounds Process Alerts: Active cases that have observations.
"); - msg.append("CONFIRMATION: There are " + count + " active cases that have their obs entered today.
"); + msg.append("CONFIRMATION: " + count + " active case(s) found that have their obs entered today.
"); msg.append("
RoomCageIdAssigned VetProblem(s)Days Since last Vet Review
"); msg.append(""); From f94b41949552176a9c682f0021af341c1cfdfa7f Mon Sep 17 00:00:00 2001 From: kollil Date: Tue, 29 Nov 2022 15:38:30 -0800 Subject: [PATCH 12/12] Tattoo alert updated --- onprc_ehr/resources/queries/study/TattooAlert.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onprc_ehr/resources/queries/study/TattooAlert.sql b/onprc_ehr/resources/queries/study/TattooAlert.sql index bfb0475cd..46018da83 100644 --- a/onprc_ehr/resources/queries/study/TattooAlert.sql +++ b/onprc_ehr/resources/queries/study/TattooAlert.sql @@ -1,4 +1,4 @@ --- Displays all animals with no tattoo procedure recorded excluding the purchased animals +-- Displays all animals with tattoo procedure missing in the encounters table. Excluding the purchased animals Select Id, birth, gender from study.demographics a Where a.calculated_status = 'Alive' And a.id not in (Select id from study.arrival where acquisitiontype = 6) --6= Purchase
RoomCageIdAssigned VetProblem(s)