Skip to content
Merged
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
5 changes: 4 additions & 1 deletion ehr/src/org/labkey/ehr/utils/TriggerScriptHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.labkey.api.data.SQLFragment;
import org.labkey.api.data.Selector;
import org.labkey.api.data.SimpleFilter;
import org.labkey.api.data.Sort;
import org.labkey.api.data.SqlExecutor;
import org.labkey.api.data.SqlSelector;
import org.labkey.api.data.Table;
Expand Down Expand Up @@ -1781,7 +1782,9 @@ public void updateStatusField(List<String> ids, Map<String, List<Date>> liveBirt
ColumnInfo acquisitionColumn = columns.get(acquisitionFieldKey);
if (acquisitionColumn != null)
{
TableSelector ts = new TableSelector(arrivalTable, Collections.singleton(acquisitionColumn), new SimpleFilter(FieldKey.fromParts("Id"), id), null);
// In some cases, an animal can arrive more than once, so bound this to one row: unbounded, getObject()
// throws on the extra rows rather than picking one. Sort so the row picked is the latest arrival, not arbitrary.
TableSelector ts = new TableSelector(arrivalTable, Collections.singleton(acquisitionColumn), new SimpleFilter(FieldKey.fromParts("Id"), id), new Sort("-date")).setMaxRows(1);
acquitype = ts.getObject(String.class);
}
}
Expand Down