diff --git a/nbri_ehr/resources/domain-templates/ehr_lookups.template.xml b/nbri_ehr/resources/domain-templates/ehr_lookups.template.xml
index 008fafb..051dfb2 100644
--- a/nbri_ehr/resources/domain-templates/ehr_lookups.template.xml
+++ b/nbri_ehr/resources/domain-templates/ehr_lookups.template.xml
@@ -41,6 +41,9 @@
string
+
+ boolean
+
diff --git a/nbri_ehr/resources/web/nbri_ehr/model/sources/NBRIDefault.js b/nbri_ehr/resources/web/nbri_ehr/model/sources/NBRIDefault.js
index 1bca93c..c853d8e 100644
--- a/nbri_ehr/resources/web/nbri_ehr/model/sources/NBRIDefault.js
+++ b/nbri_ehr/resources/web/nbri_ehr/model/sources/NBRIDefault.js
@@ -127,7 +127,7 @@ EHR.model.DataModelManager.registerMetadata('Default', {
},
reason: {
defaultValue: null,
- allowBlank: false,
+ allowBlank: true,
columnConfig: {
width: 180
},
diff --git a/nbri_ehr/resources/web/nbri_ehr/panel/SnapshotPanel.js b/nbri_ehr/resources/web/nbri_ehr/panel/SnapshotPanel.js
index 9bcccb7..069d96c 100644
--- a/nbri_ehr/resources/web/nbri_ehr/panel/SnapshotPanel.js
+++ b/nbri_ehr/resources/web/nbri_ehr/panel/SnapshotPanel.js
@@ -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){
diff --git a/nbri_ehr/src/org/labkey/nbri_ehr/history/NBRIHousingDataSource.java b/nbri_ehr/src/org/labkey/nbri_ehr/history/NBRIHousingDataSource.java
index 0749f01..934f33e 100644
--- a/nbri_ehr/src/org/labkey/nbri_ehr/history/NBRIHousingDataSource.java
+++ b/nbri_ehr/src/org/labkey/nbri_ehr/history/NBRIHousingDataSource.java
@@ -36,7 +36,7 @@ public NBRIHousingDataSource(Module module)
@Override
protected Set getColumnNames()
{
- return PageFlowUtil.set("Id", "date", "cage/cage", "room/room", "reason", "remark");
+ return PageFlowUtil.set("Id", "date", "cage", "room/room", "reason", "remark");
}
@Override
@@ -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)
{
diff --git a/nbri_ehr/test/src/org.labkey.test/tests.nbri_ehr/NBRI_EHRTest.java b/nbri_ehr/test/src/org.labkey.test/tests.nbri_ehr/NBRI_EHRTest.java
index 9861c69..9904e60 100644
--- a/nbri_ehr/test/src/org.labkey.test/tests.nbri_ehr/NBRI_EHRTest.java
+++ b/nbri_ehr/test/src/org.labkey.test/tests.nbri_ehr/NBRI_EHRTest.java
@@ -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};
@@ -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.
*/