Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions onprc_ehr/resources/queries/study/DVMAlertforAlopeciaCases.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* Added by Kollil 09/22/2025
When BSU creates a case AND scores the alopecia at either 4 or 5 (only those scores) THEN the vet assigned to that animal should receive an alert.
Show open cases in last 7 days
Refer to tkt # 12523
*/
SELECT
co.Id,
co.date AS MostRecentDate,
co.observation AS MostRecentAlopeciaScore,
co.performedby,
co.enteredSincevetReview,
co.Id.assignedVet.AssignedVet as AssignedVet,
c.date as BehaviorCaseOpenDate
FROM study.clinical_observations AS co
INNER JOIN study.demographics AS d
ON co.Id = d.Id
INNER JOIN study.Cases AS c
ON c.Id = co.Id
AND c.category = 'Behavior'
AND c.allProblemCategories = 'Behavioral: Alopecia'
AND c.enddate IS NULL
WHERE
co.category = 'Alopecia Score'
AND co.observation IN ('4', '5')
--AND co.date >= '2025-01-01'
AND d.calculated_status = 'Alive'
AND co.date = (
SELECT MAX(co2.date)
FROM study.clinical_observations AS co2
WHERE co2.Id = co.Id
AND co2.category = 'Alopecia Score'
AND co2.observation IN ('4', '5')
)
AND c.date >= TIMESTAMPADD(SQL_TSI_DAY, -7, now())
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,37 @@ public String getMessageBodyHTML(Container c, User u)
StringBuilder msg = new StringBuilder();

/* remarksWithoutAssignedVet(c, u, msg);*/
DVMAlopeciaAlert(c,u,msg);
vetRecordsUnderReview(c, u, msg);
animalsWithoutAssignedVet(c, u, msg);

return msg.toString();
}

/* Added by Kollil 09/22/2025
When BSU creates a case AND scores the alopecia at either 4 or 5 (only those scores) THEN the vet assigned to that animal should receive an alert. Show open cases in last 7 days
Refer to tkt # 12523
*/
private void DVMAlopeciaAlert(final Container c, User u, final StringBuilder msg)
{
TableInfo ti = getStudySchema(c, u).getTable("DVMAlertforAlopeciaCases");

TableSelector ts = new TableSelector(ti, null, null);
long total = ts.getRowCount();
// msg.append("<b>ALERT: Animals with alopecia score of 4 or 5 with open behavioral case for alopecia in last 7 days:</b><p>");
if (total > 0)
{
msg.append("<b>ALERT: Animals with alopecia score of 4 or 5 with open behavioral case for alopecia in last 7 days:</b><p>");
msg.append("There are " + total + " entries found. ");
msg.append("<p><a href='" + getExecuteQueryUrl(c, "study", "DVMAlertforAlopeciaCases", null) + "'>Click here to view them</a></p>\n");
msg.append("<hr>\n\n");
}
else
{
msg.append("<b>WARNING: No animals found with alopecia score of 4 or 5 with open behavioral case for alopecia in last 7 days!</b><br><hr>\n");
}
}

public void vetRecordsUnderReview(Container c, User u, final StringBuilder msg)
{
int duration = 7;
Expand Down