Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void run()
if (orchardFileLocation == null)
{
// Don't run if we don't have a location to write the file
_log.warn("Orchard file location is null, cannot generate Orchard file for taskid: " + taskid);
_log.warn("Orchard file location is null, cannot generate Orchard file for taskid: {}", taskid);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected String getJsHandler(TableInfo ti)
String pkColName = null;
if (ti.getPkColumnNames() != null && ti.getPkColumnNames().size() == 1)
{
pkColName = ti.getPkColumnNames().get(0);
pkColName = ti.getPkColumnNames().getFirst();
}

return "NIRC_EHR.window.MarkTreatmentCompletedWindow.buttonHandler(dataRegionName, " + PageFlowUtil.jsString(_schemaName) + ", " + PageFlowUtil.jsString(_queryName) + ", " + PageFlowUtil.jsString(xtype) + ", " + PageFlowUtil.jsString(pkColName) + ");";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ public Set<String> getIdsToUpdate(Container c, String id, Map<String, Object> or
List<Map<String, Object>> newList = newProps == null ? null : (List)newProps.get(_propName);
Set<String> ret = new TreeSet<>();

List<String> oldAnimals = oldList == null || oldList.isEmpty() ? Collections.emptyList() : toList(oldList.get(0).get("animals"));
List<String> newAnimals = newList == null || newList.isEmpty() ? Collections.emptyList() : toList(newList.get(0).get("animals"));
List<String> oldAnimals = oldList == null || oldList.isEmpty() ? Collections.emptyList() : toList(oldList.getFirst().get("animals"));
List<String> newAnimals = newList == null || newList.isEmpty() ? Collections.emptyList() : toList(newList.getFirst().get("animals"));

ret.addAll(newAnimals);
ret.addAll(oldAnimals);
ret.remove(id);

if (!ret.isEmpty())
{
_log.info(id + ": Triggered additional housing updates for " + ret.size() + " ids: " + StringUtils.join(ret, ";"));
_log.info("{}: Triggered additional housing updates for {} ids: {}", id, ret.size(), StringUtils.join(ret, ";"));
}

return ret;
Expand All @@ -75,7 +75,7 @@ else if (input instanceof String)
}
else
{
_log.error("Unknown type: " + input.getClass().getName() + ", " + input);
_log.error("Unknown type: {}, {}", input.getClass().getName(), input);
return Collections.emptyList();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@ public String getEmailSubject(Container c)
return "Death Alert " + getDateTimeFormat(c).format(new Date());
}

@Override
public String getCronString()
{
return null;
}

@Override
public String getScheduleDescription()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@ public String getEmailSubject(Container c)
return "Pregnancy Outcome Alert " + getDateTimeFormat(c).format(new Date());
}

@Override
public String getCronString()
{
return null;
}

@Override
public String getScheduleDescription()
{
Expand Down
46 changes: 22 additions & 24 deletions nirc_ehr/src/org/labkey/nirc_ehr/query/NIRC_EHRTriggerHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ else if (enddate == null || enddate.after(deathDate))
TableSelector ts = new TableSelector(ti, PageFlowUtil.set("date"), nextFilter, new Sort("date"));
List<Date> dates = ts.getArrayList(Date.class);
if (!dates.isEmpty())
enddate = dates.get(0);
enddate = dates.getFirst();
}

String qcstate = ConvertHelper.convert(row.get("qcstate"), String.class);
Expand Down Expand Up @@ -383,8 +383,8 @@ public void clinicalMoveNotification(final String animalId, final String date)
return;
}

String remark = (String) EHRDemographicsService.get().getAnimal(container, animalId).getActiveHousing().get(0).get("remark");
String performedBy = (String) EHRDemographicsService.get().getAnimal(container, animalId).getActiveHousing().get(0).get("performedBy");
String remark = (String) EHRDemographicsService.get().getAnimal(container, animalId).getActiveHousing().getFirst().get("remark");
String performedBy = (String) EHRDemographicsService.get().getAnimal(container, animalId).getActiveHousing().getFirst().get("performedBy");

//construct html for email notification
final StringBuilder html = new StringBuilder();
Expand All @@ -396,15 +396,15 @@ public void clinicalMoveNotification(final String animalId, final String date)
appendAnimalDetails(html, animalId, container);

// send Clinical Move Notification
_log.debug("NIRC Clinical Move notification job sending email for animal " + animalId + " in container " + container.getPath());
_log.debug("NIRC Clinical Move notification job sending email for animal {} in container {}", animalId, container.getPath());
TriggerScriptNotification.sendMessage(subject, html.toString(), recipients, container, user);
}), DbScope.CommitTaskOption.POSTCOMMIT);

transaction.commit();
}
}

public void sendDeathNotification(final String animalId) throws Exception
public void sendDeathNotification(final String animalId)
{
//check whether Death Notification is enabled
if (!NotificationService.get().isActive(new NIRCDeathNotification(), _container) || !NotificationService.get().isServiceEnabled())
Expand Down Expand Up @@ -450,36 +450,36 @@ public void sendDeathNotification(final String animalId) throws Exception

//construct html for email notification
final StringBuilder html = new StringBuilder();
if (deathDate.getValue() == null)
if (deathDate.get() == null)
{
_log.error("NIRC death notification job found no death date for animal " + animalId + " in container " + _container.getPath());
_log.error("NIRC death notification job found no death date for animal {} in container {}", animalId, _container.getPath());
html.append("Death date not found. Please contact system administrator.").append("<br>");
return;
}
html.append("Animal '").append(PageFlowUtil.filter(animalId)).append("' has been declared dead on '").append(_dateFormat.format(deathDate.getValue())).append("'.<br>");
html.append("Performed By: ").append(PageFlowUtil.filter(performedBy.getValue())).append("<br>");
html.append("Disposition: ").append(PageFlowUtil.filter(disposition.getValue())).append("<br><br>");
html.append("Animal '").append(PageFlowUtil.filter(animalId)).append("' has been declared dead on '").append(_dateFormat.format(deathDate.get())).append("'.<br>");
html.append("Performed By: ").append(PageFlowUtil.filter(performedBy.get())).append("<br>");
html.append("Disposition: ").append(PageFlowUtil.filter(disposition.get())).append("<br><br>");

//append animal details
appendAnimalDetails(html, animalId, container);

//append link to Necropsy form
String url = AppProps.getInstance().getBaseServerUrl() + AppProps.getInstance().getContextPath() + "/ehr" +
container.getPath() + "/dataEntryForm.view?formType=Necropsy&taskid=" + taskId.getValue();
container.getPath() + "/dataEntryForm.view?formType=Necropsy&taskid=" + taskId.get();
html.append("<a href='").append(PageFlowUtil.filter(url)).append("'>");

html.append("Click here to record Necropsy</a><br>");

// send Death Notification
_log.debug("NIRC Death notification job sending email for animal " + animalId + " in container " + container.getPath());
_log.debug("NIRC Death notification job sending email for animal {} in container {}", animalId, container.getPath());
TriggerScriptNotification.sendMessage(subject, html.toString(), recipients, container, user);
}), DbScope.CommitTaskOption.POSTCOMMIT);

transaction.commit();
}
}

public void generateOrchardFile(final String taskid) throws Exception
public void generateOrchardFile(final String taskid)
{
NIRCOrchardFileGenerator orchardFileGenerator = NIRC_EHRManager.getOrchardFileGenerator();
orchardFileGenerator.generateOrchardFile(_container, _user, taskid);
Expand All @@ -500,7 +500,7 @@ private void appendAnimalDetails(StringBuilder html, String id, final Container
List<Map<String, Object>> activeHousing = EHRDemographicsService.get().getAnimal(container, id).getActiveHousing();
if (null != activeHousing && !activeHousing.isEmpty())
{
cage = (String) activeHousing.get(0).get("cage/cage");
cage = (String) activeHousing.getFirst().get("cage/cage");
}
else
{
Expand All @@ -524,10 +524,8 @@ private String getProject(String id)
SimpleFilter filter = new SimpleFilter(FieldKey.fromString("Id"), id);
TableSelector ts = new TableSelector(ti, PageFlowUtil.set("project"), filter, null);
final Mutable<String> project = new MutableObject<>();
ts.forEach(rs -> {
project.setValue(rs.getString("project"));
});
return project.getValue();
ts.forEach(rs -> project.setValue(rs.getString("project")));
return project.get();
}

private String getProtocol(String id)
Expand Down Expand Up @@ -557,7 +555,7 @@ private String getProtocol(String id)
protocol.setValue(title + (inves == null ? "" : " - " + inves));
}
});
return protocol.getValue();
return protocol.get();
}

public String createAssignmentRecord(String dataset, String id, Map<String, Object> row) throws SQLException, BatchValidationException, QueryUpdateServiceException, InvalidKeyException, DuplicateKeyException
Expand Down Expand Up @@ -682,7 +680,7 @@ public boolean canCloseCase(String category)
return false;
}

public void closeDailyClinicalObs(String caseid, String enddate) throws SQLException
public void closeDailyClinicalObs(String caseid, String enddate)
{
TableInfo ti = getTableInfo("study", "observation_order");
SimpleFilter filter = new SimpleFilter(FieldKey.fromString("caseid"), caseid);
Expand All @@ -708,7 +706,7 @@ public void closeDailyClinicalObs(String caseid, String enddate) throws SQLExcep
}
}

public void ensureDailyClinicalObservationOrders(String id, String caseid, final Date date, String performedby, String qcstate, String taskid, List<Map<String, Object>> ordersInTransaction) throws SQLException
public void ensureDailyClinicalObservationOrders(String id, String caseid, final Date date, String performedby, String qcstate, String taskid, List<Map<String, Object>> ordersInTransaction)
{
TableInfo ti = getTableInfo("study", "observation_order");
SimpleFilter filter = new SimpleFilter(FieldKey.fromParts("category","value"), "Activity");
Expand Down Expand Up @@ -898,7 +896,7 @@ public boolean isProcedureOrderEntered(String orderid)
TableInfo ti = getTableInfo("study", "prc_order");
SimpleFilter filter = new SimpleFilter(FieldKey.fromString("objectid"), orderid);
TableSelector ts = new TableSelector(ti, PageFlowUtil.set("qcstate"), filter, null);
Integer qcstate = ts.getArrayList(Integer.class).get(0);
Integer qcstate = ts.getArrayList(Integer.class).getFirst();
if (EHRService.get().getQCStates(_container).get("Completed").getRowId() == qcstate)
return true;

Expand Down Expand Up @@ -967,7 +965,7 @@ public void updateProcedureOrdersToCompleted(List<String> ids)
try
{
ti.getUpdateService().updateRows(_user, _container, rows, null, null, getExtraContext());
_log.info("Successfully updated " + rows.size() + " prc_order rows to 'Completed' status");
_log.info("Successfully updated {} prc_order rows to 'Completed' status", rows.size());
}
catch (Exception e)
{
Expand Down Expand Up @@ -1023,7 +1021,7 @@ public void sendPregnancyOutcomeNotification(final String animalId, Map<String,
appendAnimalDetails(html, animalId, container);

// send Pregnancy Outcome notification
_log.debug("NIRC Pregnancy Outcome notification job sending email for animal " + animalId + " in container " + container.getPath());
_log.debug("NIRC Pregnancy Outcome notification job sending email for animal {} in container {}", animalId, container.getPath());
TriggerScriptNotification.sendMessage(subject, html.toString(), recipients, container, user);
}), DbScope.CommitTaskOption.POSTCOMMIT);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private void verifyPerformedBy(TableInfo table, @Nullable Map<String, Object> ne
}

@Override
public void beforeInsert(TableInfo table, Container c, User user, @Nullable QueryUpdateService.InsertOption insertOption, @Nullable Map<String, Object> newRow, ValidationException errors, Map<String, Object> extraContext) throws ValidationException
public void beforeInsert(TableInfo table, Container c, User user, @Nullable QueryUpdateService.InsertOption insertOption, @Nullable Map<String, Object> newRow, ValidationException errors, Map<String, Object> extraContext)
{
transformAnimalIdToUpperCase(newRow);
verifyPerformedBy(table, newRow, errors);
Expand All @@ -44,7 +44,7 @@ public void beforeInsert(TableInfo table, Container c, User user, @Nullable Quer
@Override
public void beforeUpdate(TableInfo table, Container c,
User user, @Nullable QueryUpdateService.InsertOption insertOption, @Nullable Map<String, Object> newRow, @Nullable Map<String, Object> oldRow,
ValidationException errors, Map<String, Object> extraContext) throws ValidationException
ValidationException errors, Map<String, Object> extraContext)
{
verifyPerformedBy(table, newRow, errors);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class NIRC_EHRTriggerScriptFactory extends ScriptTriggerFactory
{
@Override
@NotNull
protected Collection<Trigger> createTriggerScript(Container c, TableInfo table) throws ScriptException
protected Collection<Trigger> createTriggerScript(@NotNull Container c, TableInfo table) throws ScriptException
{
return Collections.singleton(new NIRC_EHRSharedDatasetTrigger());
}
Expand Down
Loading