Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
d421f8e
Created a new Clinpath Chemistry email notification to alert lab valu…
Ohsudev Oct 7, 2025
fb88321
Merge branch 'release25.7-SNAPSHOT' into 25.7_fb_ClinpathPanicNotific…
Ohsudev Oct 10, 2025
3cf6ef1
Modified program to allow immediate notifcation when
Ohsudev Oct 13, 2025
32ecb6a
Modified Clinpath notification to include one set of recipeints.
Ohsudev Oct 17, 2025
d28209a
Merge branch 'release25.7-SNAPSHOT' into 25.7_fb_ClinpathPanicNotific…
Ohsudev Oct 17, 2025
30b31d1
Merge branch 'release25.7-SNAPSHOT' into 25.7_fb_ClinpathPanicNotific…
Ohsudev Oct 23, 2025
d26da5f
Created clinpath notification for Chemistry results that shows "Panic…
Ohsudev Oct 30, 2025
de5fcf6
Merge branch 'release25.7-SNAPSHOT' into 25.7_fb_ClinpathPanicNotific…
Ohsudev Oct 30, 2025
f24507a
Created clinpath notification for Chemistry results that shows "Panic…
Ohsudev Oct 31, 2025
935e8da
Merge branch 'release25.7-SNAPSHOT' into 25.7_fb_ClinpathPanicNotific…
Ohsudev Nov 3, 2025
4149404
Created clinpath notification for Chemistry results that shows "Panic…
Ohsudev Nov 3, 2025
321eb1c
Modified program implement Chemistry email notifications.
Ohsudev Nov 6, 2025
f61b730
Modified program implement Chemistry email notifications.
Ohsudev Nov 6, 2025
b3b435f
Modified program implement Chemistry email notifications.
Ohsudev Nov 6, 2025
8d8d00d
Merge branch 'refs/heads/release25.7-SNAPSHOT' into 25.7_fb_ClinpathP…
Ohsudev Nov 10, 2025
4326fbe
Merge branch 'release25.7-SNAPSHOT' into 25.7_fb_ClinpathPanicNotific…
Ohsudev Nov 12, 2025
ba75075
Modified Chemistry Results to flag Panic values.
Ohsudev Nov 13, 2025
69f6766
Created a email notification for Chemistry entries that shows a "qual…
Ohsudev Nov 18, 2025
e11a13e
Created a email notification for Chemistry entries that shows a "qual…
Ohsudev Nov 19, 2025
0118d49
Created a email notification for Chemistry entries that shows a "qual…
Ohsudev Nov 19, 2025
1e8ffab
Created a email notification for Chemistry entries that shows a "qual…
Ohsudev Nov 19, 2025
f398bc4
Created a email notification for Chemistry entries that shows a "qual…
Ohsudev Nov 20, 2025
59294f3
Created a email notification for Chemistry entries that shows a "qual…
Ohsudev Nov 20, 2025
1c6f7cf
Created a email notification for Chemistry entries that shows a "qual…
Ohsudev Nov 20, 2025
18ad4ad
Merge branch 'release25.7-SNAPSHOT' into 25.7_fb_ClinpathPanicNotific…
Ohsudev Dec 2, 2025
9c83687
Created Clinpath email notification
Ohsudev Dec 5, 2025
3e687ef
Merge branch 'release25.7-SNAPSHOT' into 25.7_fb_ClinpathPanicNotific…
Ohsudev Dec 9, 2025
9121e0e
Modified Clinpath panic value notifications.
Ohsudev Dec 10, 2025
2dd9407
Modified Clinpath panic value notifications.
Ohsudev Dec 10, 2025
db4fdb3
Modified Clinpath panic value notification to include task ids.
Ohsudev Dec 23, 2025
3cde11f
Merge branch 'release25.7-SNAPSHOT' into 25.7_fb_ClinpathPanicNotific…
Ohsudev Dec 23, 2025
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
select a.Id,
a.date,
a.servicerequested,
b.testid,
b.qualresult,
a.vet,
a.created,
a.objectid,
(select j.rowid from ehr.tasks j where j.taskid = a.taskid) as taskid


from study.ClinpathRuns a, study.chemistryResults b
Where a.objectid = b.runid
And a.type = 'biochemistry'
And b.qualresult like '%panic%'
And a.qcstate = 18
And b.qcstate = 18
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<query xmlns="http://labkey.org/data/xml/query">
<metadata>
<tables xmlns="http://labkey.org/data/xml">
<table tableName="Chemistry Panic Test Values" tableDbType="NOT_IN_DB">
<columns>
<column columnName="userId">
<columnTitle>user ID</columnTitle>
<isKeyField>true</isKeyField>
</column>
</columns>
</table>
</tables>
</metadata>
</query>
9 changes: 9 additions & 0 deletions onprc_ehr/resources/scripts/onprc_ehr/onprc_triggers.js
Original file line number Diff line number Diff line change
Expand Up @@ -1378,6 +1378,15 @@ exports.init = function(EHR){
});
});

// Added: 10-6-2025
EHR.Server.TriggerManager.registerHandlerForQuery(EHR.Server.TriggerManager.Events.AFTER_UPSERT, 'study', 'chemistryResults', function (helper, scriptErrors, row, oldRow) {

if (row.Id && row.qualresult && row.qualresult.indexOf('panic') !== -1) {
console.log("panic values: " + row.qualresult);
triggerHelper.sendClinpathPanicEmail(row.Id, row.runid);
}
});

//Added: 10-4-2022 R.Blasa
EHR.Server.TriggerManager.registerHandler(EHR.Server.TriggerManager.Events.COMPLETE, function(event, errors, helper){
// Send notifications when requests approved
Expand Down
147 changes: 145 additions & 2 deletions onprc_ehr/src/org/labkey/onprc_ehr/query/ONPRC_EHRTriggerHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
import org.labkey.api.query.QueryService;
import org.labkey.api.query.QueryUpdateServiceException;
import org.labkey.api.query.UserSchema;
import org.labkey.api.security.Group;
import org.labkey.api.security.MemberType;
import org.labkey.api.security.SecurityManager;
import org.labkey.api.security.User;
import org.labkey.api.security.UserManager;
import org.labkey.api.security.UserPrincipal;
Expand All @@ -63,6 +66,7 @@
import org.labkey.api.util.MailHelper;
import org.labkey.api.util.PageFlowUtil;
import org.labkey.api.util.Pair;
import org.labkey.api.util.logging.LogHelper;
import org.labkey.onprc_ehr.ONPRC_EHRManager;
import org.labkey.onprc_ehr.ONPRC_EHRModule;
import org.labkey.onprc_ehr.ONPRC_EHRSchema;
Expand Down Expand Up @@ -99,7 +103,7 @@
*/
public class ONPRC_EHRTriggerHelper
{
private static final Logger _log = LogManager.getLogger(ONPRC_EHRTriggerHelper.class);
private static final Logger _log = LogHelper.getLogger(ONPRC_EHRTriggerHelper.class, "Fill in description");
private static final String NONRESTRICTED = "Nonrestricted";
private static final String EXPERIMENTAL_EUTHANASIA = "EUTHANASIA, EXPERIMENTAL";
private static final String NON_EXPERIMENTAL_EUTHANASIA = "EUTHANASIA, NONEXPERIMENTAL";
Expand Down Expand Up @@ -2600,7 +2604,6 @@ public void updateArrivalrecords(String id, Date date) throws Exception
keys.add(FieldKey.fromString("lsid"));
final Map<FieldKey, ColumnInfo> colMap = QueryService.get().getColumns(ti, keys);


final List<Map<String, Object>> toUpdate = new ArrayList<>();
final List<Map<String, Object>> oldKeys = new ArrayList<>();
TableSelector ts = new TableSelector(ti, colMap.values(), new SimpleFilter(FieldKey.fromString("Id"), id, CompareType.IN), null);
Expand Down Expand Up @@ -2633,8 +2636,148 @@ public void exec(ResultSet object) throws SQLException
}
}

public void sendClinpathPanicEmail(String id, String runid)
{
String subject = "Chemistry Results with Panic values";


final TableInfo ti = getTableInfo("onprc_ehr", "ChemistryPanicNotification");
SimpleFilter filter = new SimpleFilter(FieldKey.fromString("Id"), id, CompareType.EQUAL);
filter.addCondition(FieldKey.fromString("objectid"), runid, CompareType.EQUAL);


List<FieldKey> names= new ArrayList<>();
FieldKey clinpathFieldKey = FieldKey.fromString("objectid");
names.add(clinpathFieldKey);
names.add(FieldKey.fromString("qualResult"));
names.add(FieldKey.fromString("servicerequested"));
names.add(FieldKey.fromString("testid"));
names.add(FieldKey.fromString("date"));
names.add(FieldKey.fromString("Id"));
names.add(FieldKey.fromString("vet"));
names.add(FieldKey.fromString("taskid"));


final Map<FieldKey, ColumnInfo> colKeys = QueryService.get().getColumns(ti, names);
final ColumnInfo clinpathColumn = colKeys.get(clinpathFieldKey);
TableSelector ts = new TableSelector(ti, colKeys.values(), filter, null);

final StringBuilder html = new StringBuilder();


if (ts.getRowCount() == 0)
{
html.append("There are no Chemistry Panlc Values to display");

return;
}
else
{

html.append("<table border=1 style='border-collapse: collapse;'>");
html.append("<tr style='font-weight: bold;'><td>Animal ID</td><td>Date</td><td>Service Requested</td><td> Panel Test Name</td><td> Qual Results</td><td>Task ID </td><td> Vet/PI Name</td></tr>\n");
ts.forEach(new Selector.ForEachBlock<ResultSet>()
{

@Override
public void exec(ResultSet rs) throws SQLException
{

TableInfo ti2 = getTableInfo("onprc_ehr", "Labwork_Requestor_Vets");
SimpleFilter filter2 = new SimpleFilter(FieldKey.fromString("userid"), rs.getString("vet"));
filter2.addCondition(FieldKey.fromString("DisableDate"), true, CompareType.ISBLANK);


TableSelector ts2 = new TableSelector(ti2, PageFlowUtil.set("LastName"), filter2, null);
List<String> ret2 = ts2.getArrayList(String.class);
if (!ret2.isEmpty())
{
for (String Vetname : ret2)
{
html.append("<tr><td>" + PageFlowUtil.filter(rs.getString("Id")) +
"</td><td>" + PageFlowUtil.filter(rs.getString("date")) +
"</td><td>" + PageFlowUtil.filter(rs.getString("servicerequested")) +
" </td><td>" + PageFlowUtil.filter(rs.getString("testid")) +
" </td><td>" + PageFlowUtil.filter(rs.getString("qualResult")) +
" </td><td>" + PageFlowUtil.filter(rs.getString("taskid")) +
"</td><td>" + PageFlowUtil.filter(Vetname) + "</td></tr>\n");
break;

}
}

}

}

);

}


final TableInfo tt = getTableInfo("study", "clinpathRuns");
SimpleFilter filtert = new SimpleFilter(FieldKey.fromString("objectid"), runid, CompareType.EQUAL);
filter.addCondition(FieldKey.fromString("id"), id, CompareType.EQUAL);

TableSelector tst = new TableSelector(ti, PageFlowUtil.set("vet"), filter, null);
tst.forEach(new Selector.ForEachBlock<>()
{
@Override
public void exec(ResultSet rs) throws SQLException
{
Integer vetId = rs.getInt("vet");
Set<UserPrincipal> recipients = getRecipients(vetId);
if (recipients.isEmpty())
{
_log.warn("No recipients, unable to send EHR trigger script email");
return;
}
else
{
html.append("</table>\n");

sendMessage(subject, html.toString(), recipients);

}

}


});


}


private Set<UserPrincipal> getRecipients(Integer... userIds)
{
Set<UserPrincipal> recipients = new HashSet<>();
for (Integer userId : userIds)
{
if (userId > 0)
{
UserPrincipal up = SecurityManager.getPrincipal(userId);
if (up != null)
{
if (up instanceof User)
{
recipients.add(up);
}
else
{
for (UserPrincipal u : SecurityManager.getAllGroupMembers((Group)up, MemberType.ACTIVE_USERS))
{
if (u.isActive())
recipients.add(u);
}
}
}
}
}

return recipients;
}

//Added 9-30-2025
public String retrieveGeographic_Origin(String Id)

Expand Down