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 @@ -44,7 +44,12 @@ public DefaultClinicalRemarksDataSource(Module module)
protected String getCategoryText(Results rs) throws SQLException
{
String category = rs.getString("category");
return (category == null || REPLACED_SOAP.equals(category) || REPLACEMENT_SOAP.equals(category) ? "Clinical" : category) + " Remark";

FieldKey titleFk = FieldKey.fromString("category/title");
if (rs.hasColumn(titleFk))
category = rs.getString(titleFk);

return (category == null || REPLACED_SOAP.equals(category) || REPLACEMENT_SOAP.equals(category) ? "Clinical" : category) + " - Remark";
}

// @Override
Expand Down
4 changes: 2 additions & 2 deletions ehr/src/org/labkey/ehr/query/EHRLookupsUserSchema.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
import org.labkey.api.data.TableSelector;
import org.labkey.api.ehr.security.EHRDataAdminPermission;
import org.labkey.api.ehr.security.EHRHousingTransferPermission;
import org.labkey.api.ehr.security.EHRSnomedEditPermission;
import org.labkey.api.ehr.security.EHRLocationEditPermission;
import org.labkey.api.ehr.security.EHRProcedureManagementPermission;
import org.labkey.api.ehr.security.EHRSnomedEditPermission;
import org.labkey.api.ldk.table.ContainerScopedTable;
import org.labkey.api.query.FieldKey;
import org.labkey.api.query.FilteredTable;
Expand Down Expand Up @@ -204,7 +204,7 @@ else if (TABLE_VETERINARIANS.equalsIgnoreCase(name))
return createVeterinariansTable(name, cf);
else if (EHRSchema.TABLE_LOOKUP_SETS.equalsIgnoreCase(name))
{
ContainerScopedTable ret = new ContainerScopedTable<>(this, createSourceTable(name), cf, "setname");
ContainerScopedTable<SimpleUserSchema> ret = new LookupSetsTable<>(this, createSourceTable(name), cf, "setname");
ret.addPermissionMapping(InsertPermission.class, EHRDataAdminPermission.class);
ret.addPermissionMapping(UpdatePermission.class, EHRDataAdminPermission.class);
ret.addPermissionMapping(DeletePermission.class, EHRDataAdminPermission.class);
Expand Down
65 changes: 65 additions & 0 deletions ehr/src/org/labkey/ehr/query/LookupSetsTable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package org.labkey.ehr.query;

import org.labkey.api.data.Container;
import org.labkey.api.data.ContainerFilter;
import org.labkey.api.data.TableInfo;
import org.labkey.api.ldk.table.ContainerScopedTable;
import org.labkey.api.query.BatchValidationException;
import org.labkey.api.query.InvalidKeyException;
import org.labkey.api.query.QueryUpdateService;
import org.labkey.api.query.QueryUpdateServiceException;
import org.labkey.api.query.SimpleUserSchema;
import org.labkey.api.query.UserSchema;
import org.labkey.api.security.User;
import org.labkey.ehr.dataentry.DataEntryManager;

import java.sql.SQLException;
import java.util.Map;

/**
* This TableInfo is for the actual ehr.lookupsets table. It is not a duplicate of LookupSetTable which
* is for the virtual tables created from the data in ehr.lookupsets.
*/
public class LookupSetsTable<SchemaType extends UserSchema> extends ContainerScopedTable<SchemaType>
{
public LookupSetsTable(SchemaType schema, TableInfo st, ContainerFilter cf, String newPk)
{
super(schema, st, cf, newPk);
}

@Override
public QueryUpdateService getUpdateService()
{
return new UpdateService(this);
}

private class UpdateService extends ContainerScopedTable<SchemaType>.UpdateService
{
public UpdateService(SimpleUserSchema.SimpleTable<SchemaType> ti)
{
super(ti);
}

@Override
protected void afterInsertUpdate(int count, BatchValidationException errors)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For completeness should hook into deleteRows() as well. truncateRows() gets called when the whole table is being cleared, but won't be invoked for individual rows being deleted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, added.

{
DataEntryManager.get().getCache().clear();
}

@Override
protected Map<String, Object> deleteRow(User user, Container container, Map<String, Object> oldRowMap) throws QueryUpdateServiceException, SQLException, InvalidKeyException
{
Map<String, Object> row = super.deleteRow(user, container, oldRowMap);
DataEntryManager.get().getCache().clear();
return row;
}

@Override
protected int truncateRows(User user, Container container) throws QueryUpdateServiceException, SQLException
{
int i = super.truncateRows(user, container);
DataEntryManager.get().getCache().clear();
return i;
}
}
}