diff --git a/onprc_ehr/resources/queries/study/AlopeciaScoreMissingBehaviorCases.query.xml b/onprc_ehr/resources/queries/study/AlopeciaScoreMissingBehaviorCases.query.xml new file mode 100644 index 000000000..a7f5d6805 --- /dev/null +++ b/onprc_ehr/resources/queries/study/AlopeciaScoreMissingBehaviorCases.query.xml @@ -0,0 +1,10 @@ + + + + + + Animals with alopecia score 4 or 5 with missing behavior cases +
+
+
+
diff --git a/onprc_ehr/resources/queries/study/AlopeciaScoreMissingBehaviorCases.sql b/onprc_ehr/resources/queries/study/AlopeciaScoreMissingBehaviorCases.sql index 0096f2725..dc670937a 100644 --- a/onprc_ehr/resources/queries/study/AlopeciaScoreMissingBehaviorCases.sql +++ b/onprc_ehr/resources/queries/study/AlopeciaScoreMissingBehaviorCases.sql @@ -5,11 +5,18 @@ Show 1 year data. Modified by Kollil 09/15/2025 Added date comparison to check only dates and ignore time + +Modified by Kollil July 2026 +Showing only 1 month data, Refer to tkt # 14974 */ SELECT mr.Id, d.species, - d.gender, + CASE + WHEN LOWER(d.gender) = 'f' THEN 'Female' + WHEN LOWER(d.gender) = 'm' THEN 'Male' + ELSE d.gender + END AS gender, d.Id.age.ageinYearsRounded, d.Id.curLocation.area, d.Id.curLocation.room, @@ -22,14 +29,14 @@ FROM ( FROM study.clinical_observations AS co WHERE co.category = 'Alopecia Score' - AND co.created >= TIMESTAMPADD(SQL_TSI_YEAR, -1, NOW()) + AND co.created >= TIMESTAMPADD(SQL_TSI_MONTH, -1, NOW()) AND co.created = ( SELECT MAX(co2.created) FROM study.clinical_observations AS co2 WHERE co2.Id = co.Id AND co2.category = 'Alopecia Score' - AND co2.created >= TIMESTAMPADD(SQL_TSI_YEAR, -1, NOW()) + AND co2.created >= TIMESTAMPADD(SQL_TSI_MONTH, -1, NOW()) ) ) AS mr INNER JOIN study.demographics AS d ON mr.Id = d.Id @@ -43,8 +50,6 @@ WHERE c.Id = mr.Id AND c.category = 'Behavior' AND c.allProblemCategories = 'Behavioral: Alopecia' --- AND c.date <= mr.date --- AND (c.enddate IS NULL OR c.enddate > mr.date) AND CAST(c.date AS DATE) <= CAST(mr.date AS DATE) AND (c.enddate IS NULL OR CAST(c.enddate AS DATE) >= CAST(mr.date AS DATE)) ) 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 e2829e445..aaed5fe1b 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/notification/BehaviorNotification.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/notification/BehaviorNotification.java @@ -351,8 +351,7 @@ private void assignmentsReleasedInPast1Day(final Container c, User u, final Stri final Map colMap = QueryService.get().getColumns(ti, columns); TableSelector ts2 = new TableSelector(ti, colMap.values(), null, new Sort("Id")); -// msg.append("
Assignments with new \"Release date\" added within the last 24hrs:

\n"); - msg.append(""); + msg.append("
"); msg.append(""); msg.append(""); @@ -360,22 +359,22 @@ private void assignmentsReleasedInPast1Day(final Container c, User u, final Stri Results rs = new ResultsImpl(object, colMap); String url = getParticipantURL(c, rs.getString("Id")); - msg.append(""); - msg.append("\n"); - msg.append(""); - msg.append(""); - msg.append(""); - msg.append(""); - msg.append(""); - msg.append(""); - msg.append(""); - msg.append(""); - msg.append(""); - msg.append(""); - msg.append(""); - msg.append(""); - msg.append(""); - msg.append(""); + msg.append(""); + msg.append("\n"); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); msg.append(""); }); msg.append("
Id Sex Room Cage Project Protocol Title Project Investigator Assign Date Release Date Projected Release Date Assignment Type Assign Condition Projected Release Condition Condition At Release
" + PageFlowUtil.filter(rs.getString("Id")) + " " + PageFlowUtil.filter(rs.getString("Sex")) + "" + PageFlowUtil.filter(rs.getString("Room")) + "" + PageFlowUtil.filter(rs.getString("Cage")) + "" + PageFlowUtil.filter(rs.getString("project")) + "" + PageFlowUtil.filter(rs.getString("Protocol")) + "" + PageFlowUtil.filter(rs.getString("Title")) + "" + PageFlowUtil.filter(rs.getString("ProjectInvestigator")) + "" + PageFlowUtil.filter(rs.getString("AssignDate")) + "" + PageFlowUtil.filter(rs.getString("ReleaseDate")) + "" + PageFlowUtil.filter(rs.getString("ProjectedReleaseDate")) + "" + PageFlowUtil.filter(rs.getString("assignmentType")) + "" + PageFlowUtil.filter(rs.getString("assignCondition")) + "" + PageFlowUtil.filter(rs.getString("projectedReleaseCondition")) + "" + PageFlowUtil.filter(rs.getString("ConditionAtRelease")) + "
" + PageFlowUtil.filter(rs.getString("Id")) + " " + PageFlowUtil.filter(rs.getString("Sex")) + "" + PageFlowUtil.filter(rs.getString("Room")) + "" + PageFlowUtil.filter(rs.getString("Cage")) + "" + PageFlowUtil.filter(rs.getString("project")) + "" + PageFlowUtil.filter(rs.getString("Protocol")) + "" + PageFlowUtil.filter(rs.getString("Title")) + "" + PageFlowUtil.filter(rs.getString("ProjectInvestigator")) + "" + PageFlowUtil.filter(rs.getString("AssignDate")) + "" + PageFlowUtil.filter(rs.getString("ReleaseDate")) + "" + PageFlowUtil.filter(rs.getString("ProjectedReleaseDate")) + "" + PageFlowUtil.filter(rs.getString("assignmentType")) + "" + PageFlowUtil.filter(rs.getString("assignCondition")) + "" + PageFlowUtil.filter(rs.getString("projectedReleaseCondition")) + "" + PageFlowUtil.filter(rs.getString("ConditionAtRelease")) + "


"); @@ -394,17 +393,62 @@ private void AlopeciaScoreAlert(final Container c, User u, final StringBuilder m TableInfo ti = getStudySchema(c, u).getTable("AlopeciaScoreMissingBehaviorCases"); TableSelector ts = new TableSelector(ti, null, null); - long total = ts.getRowCount(); - msg.append("Animals with alopecia score of 4 or 5, but does not have an open behavioral case for alopecia:

"); - if (total > 0) - { - msg.append( total + " entries found. "); - msg.append("Click here to view them\n"); - msg.append("


\n\n"); + long count = ts.getRowCount(); + + //Get num of rows + if (count > 0) { + msg.append("Animals with alopecia score of 4 or 5, but does not have an open behavioral case for alopecia:

"); + msg.append( count + " entries found. "); + msg.append("Click here to view them in a separate window\n"); + msg.append("\n\n"); + + //Changes made byKolli, July 2026, Refer to tkt # 14974 + //Display the daily report in the email + Set columns = new HashSet<>(); + columns.add(FieldKey.fromString("Id")); + columns.add(FieldKey.fromString("species")); + columns.add(FieldKey.fromString("gender")); + columns.add(FieldKey.fromString("ageinYearsRounded")); + columns.add(FieldKey.fromString("area")); + columns.add(FieldKey.fromString("room")); + columns.add(FieldKey.fromString("cage")); + columns.add(FieldKey.fromString("MostRecentAlopeciaScore")); + columns.add(FieldKey.fromString("date")); + columns.add(FieldKey.fromString("performedby")); + + final Map colMap = QueryService.get().getColumns(ti, columns); + TableSelector ts2 = new TableSelector(ti, colMap.values(), null, new Sort("Id")); + + msg.append(""); + msg.append(""); + msg.append(""); + + ts2.forEach(object -> { + Results rs = new ResultsImpl(object, colMap); + String url = getParticipantURL(c, rs.getString("Id")); + + msg.append(""); + msg.append("\n"); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); + java.sql.Date date = rs.getDate("date"); + msg.append(""); + msg.append(""); + msg.append(""); + }); + msg.append("
Id Species Sex Age(Years, Rounded) Area Room Cage Most Recent Alopecia Score Date Performed By
" + PageFlowUtil.filter(rs.getString("Id")) + " " + PageFlowUtil.filter(rs.getString("Species")) + "" + PageFlowUtil.filter(rs.getString("gender")) + "" + PageFlowUtil.filter(rs.getString("ageinYearsRounded")) + "" + PageFlowUtil.filter(rs.getString("area")) + "" + PageFlowUtil.filter(rs.getString("room")) + "" + PageFlowUtil.filter(rs.getString("cage")) + "" + PageFlowUtil.filter(rs.getString("MostRecentAlopeciaScore")) + "") + .append(PageFlowUtil.filter( + date == null ? "" : new java.text.SimpleDateFormat("MM/dd/yyyy").format(date) + )) + .append("" + PageFlowUtil.filter(rs.getString("performedby")) + "


"); } - else - { - msg.append("WARNING: No animals found with alopecia score of 4 or 5, but does not have an open behavioral case for alopecia!

\n"); + else { + msg.append("WARNING: No animals found with alopecia score of 4 or 5, there fore no open behavioral case(s) for alopecia!

\n"); } }