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
3 changes: 3 additions & 0 deletions nbri_ehr/resources/domain-templates/ehr_lookups.template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
<dat:column columnName="floor">
<dat:rangeURI>string</dat:rangeURI>
</dat:column>
<dat:column columnName="morningHealth">
<dat:rangeURI>boolean</dat:rangeURI>
</dat:column>
</dat:columns>
</table>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ EHR.model.DataModelManager.registerMetadata('Default', {
},
reason: {
defaultValue: null,
allowBlank: false,
allowBlank: true,
columnConfig: {
width: 180
},
Expand Down
2 changes: 1 addition & 1 deletion nbri_ehr/resources/web/nbri_ehr/panel/SnapshotPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ Ext4.define('NBRI_EHR.panel.SnapshotPanel', {
var housingRow = row.getActiveHousing();
location = '';
if (housingRow)
location += LABKEY.Utils.encodeHtml(housingRow[0]?.['cage/cage']);
location += LABKEY.Utils.encodeHtml(housingRow[0]?.['location']);

if (location){
if (this.showLocationDuration && housingRow[0].date){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public NBRIHousingDataSource(Module module)
@Override
protected Set<String> getColumnNames()
{
return PageFlowUtil.set("Id", "date", "cage/cage", "room/room", "reason", "remark");
return PageFlowUtil.set("Id", "date", "cage", "room/room", "reason", "remark");
}

@Override
Expand All @@ -45,11 +45,12 @@ protected String getHtml(Container c, Results rs, boolean redacted) throws SQLEx
StringBuilder sb = new StringBuilder();

FieldKey room = FieldKey.fromString("room/room");
FieldKey cage = FieldKey.fromString("cage/cage");
// housing.cage holds the room-qualified location key; traversing it to the cage lookup would drop the room.
FieldKey location = FieldKey.fromString("cage");
String value = "Unknown";
if (rs.hasColumn(cage) && rs.getObject(cage) != null)
if (rs.hasColumn(location) && rs.getObject(location) != null)
{
value = rs.getString(cage);
value = rs.getString(location);
}
else if(rs.hasColumn(room) && rs.getObject(room) != null)
{
Expand Down
19 changes: 19 additions & 0 deletions nbri_ehr/test/src/org.labkey.test/tests.nbri_ehr/NBRI_EHRTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ public class NBRI_EHRTest extends AbstractGenericEHRTest implements PostgresOnly
private static final String ROOMLESS_CAGE = cageLocation("R1", ROOMLESS_CAGE_NAME);
private static final String[] ROOMLESS_ANIMALS = {"CAGE0001", "CAGE0002"};

// Housed by testSnapshotShowsFullLocation against its own animal, so a sibling test relocating a shared one
// cannot change what the snapshot reports.
private static final String[] LOCATION_ANIMALS = {"LOC0001"};

private final String[] weightFields = {"Id", "date", "enddate", "project", "weight", FIELD_QCSTATELABEL, FIELD_OBJECTID, FIELD_LSID, "_recordid", "performedby"};
private final Object[] weightData1 = {getExpectedAnimalIDCasing("TESTSUBJECT1"), EHRClientAPIHelper.DATE_SUBSTITUTION, null, null, "12", EHRQCState.IN_PROGRESS.label, null, null, "_recordID", 1004};

Expand Down Expand Up @@ -2148,6 +2152,21 @@ public void testCagematesWithoutRoom() throws Exception
assertCagemates(ROOMLESS_ANIMALS[0], 2, ROOMLESS_ANIMALS[1]);
}

@Test
public void testSnapshotShowsFullLocation() throws Exception
{
createAliveAnimals(LOCATION_ANIMALS);

log("Housing an animal against a cage location");
houseAnimals(LOCATION_ANIMALS, CAGE_IN_R1);

log("Verifying Animal Details reports the room-qualified location rather than the bare cage");
// The panel appends the housing date, so the location is a prefix of the field rather than the whole of it.
String location = getSnapshotFieldValue(LOCATION_ANIMALS[0], "Location");
Assert.assertTrue("Animal Details reported an unexpected location: " + location,
location.startsWith(CAGE_IN_R1));
}

/**
* Creates living demographics records for the given animals, replacing any left behind by an earlier run.
*/
Expand Down