From 65380ec1d6a5191bd98cd6c3f1fa6247b077dca1 Mon Sep 17 00:00:00 2001 From: Marty Pradere Date: Tue, 22 Sep 2026 14:17:03 -0700 Subject: [PATCH 1/3] Count only current occupants in roomUtilization (#768) ## Rationale Room occupancy counts in the room utilization query report every animal ever housed in a room rather than the animals housed there now, so a count never drops when a room empties. The count feeds the "show occupied only" option in the room picker, which as a result cannot hide a room that was ever used. ## Related Pull Requests None. ## Changes - Restrict the housing join in the room utilization query to current, non-draft stays. - Keep the restriction in the join condition rather than a filter, so rooms with no current occupants are still reported. --- nirc_ehr/resources/queries/ehr_lookups/roomUtilization.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nirc_ehr/resources/queries/ehr_lookups/roomUtilization.sql b/nirc_ehr/resources/queries/ehr_lookups/roomUtilization.sql index 8abd391c..bc9d8db0 100644 --- a/nirc_ehr/resources/queries/ehr_lookups/roomUtilization.sql +++ b/nirc_ehr/resources/queries/ehr_lookups/roomUtilization.sql @@ -11,6 +11,6 @@ SELECT r.area, FROM ehr_lookups.rooms r LEFT JOIN study.housing h -ON r.room = h.room +ON r.room = h.room AND h.isActive = true AND h.qcstate.publicdata = true GROUP BY r.room, r.building, r.area \ No newline at end of file From 7106271ce927eff9fb6e40b7ad8e842bb9b809e0 Mon Sep 17 00:00:00 2001 From: Marty Pradere Date: Wed, 23 Sep 2026 13:33:54 -0700 Subject: [PATCH 2/3] Give each imported project its own id (#771) ## Rationale Multi-row project imports gave every project the same Project Id, which breaks updates and deletes by key and makes those projects indistinguishable in project lookups. ## Related Pull Requests None. ## Changes - Assign each imported row its own Project Id. --- nirc_ehr/resources/queries/ehr/project.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nirc_ehr/resources/queries/ehr/project.js b/nirc_ehr/resources/queries/ehr/project.js index 5f615b35..3d9a01bf 100644 --- a/nirc_ehr/resources/queries/ehr/project.js +++ b/nirc_ehr/resources/queries/ehr/project.js @@ -26,7 +26,7 @@ function onInit(event, helper){ function onUpsert(helper, scriptErrors, row, oldRow) { if (!helper.isETL()) { if (!row.project) { - row.project = nextProjectNum; + row.project = nextProjectNum++; } } } \ No newline at end of file From 7d11869b62660df76253ae5ee9c1bdbc57f5edcb Mon Sep 17 00:00:00 2001 From: Marty Pradere Date: Fri, 25 Sep 2026 04:48:07 -0700 Subject: [PATCH 3/3] Lock case Ids, surface arrival attachments, open the necropsy view (#770) ## Rationale Three independent corrections to EHR data entry: a saved case could have its animal reassigned, the arrival attachment file was unreachable from the data entry grids, and the necropsy tasks view could not be customized. Editing an existing case from any of the Clinical/Behavioral Cases or Rounds forms re-enabled every field, including the animal Id, so a case could silently be moved to a different animal. The attachment file column on study.arrival was hidden outright, leaving no way to reach a document while entering an arrival. The necropsy tasks default view was locked against user customization. ## Related Pull Requests None. ## Changes - The animal Id stays read-only once a saved case is loaded on the Clinical Cases, Behavioral Cases, Clinical Rounds and Behavioral Rounds forms; creating a new case is unaffected. - The arrival attachment file is visible in the Arrivals and Rearrivals grids, ordered last and given a wider column, alongside a wider birth date column. - The necropsy tasks default view can be overridden by users. --- .../queries/nirc_ehr/necropsyTasks/.qview.xml | 2 +- .../resources/queries/study/arrival.query.xml | 1 - .../resources/web/nirc_ehr/field/EditCase.js | 14 +++++++++----- .../web/nirc_ehr/model/sources/Arrival.js | 10 +++++++++- .../web/nirc_ehr/model/sources/Rearrival.js | 5 +++++ .../section/NIRCArrivalFormSection.java | 4 ++++ .../section/NIRCRearrivalFormSection.java | 16 ++++++++++++++++ 7 files changed, 44 insertions(+), 8 deletions(-) diff --git a/nirc_ehr/resources/queries/nirc_ehr/necropsyTasks/.qview.xml b/nirc_ehr/resources/queries/nirc_ehr/necropsyTasks/.qview.xml index 908527e7..ef613fe0 100644 --- a/nirc_ehr/resources/queries/nirc_ehr/necropsyTasks/.qview.xml +++ b/nirc_ehr/resources/queries/nirc_ehr/necropsyTasks/.qview.xml @@ -1,4 +1,4 @@ - + diff --git a/nirc_ehr/resources/queries/study/arrival.query.xml b/nirc_ehr/resources/queries/study/arrival.query.xml index 3b8933b1..5054e517 100644 --- a/nirc_ehr/resources/queries/study/arrival.query.xml +++ b/nirc_ehr/resources/queries/study/arrival.query.xml @@ -30,7 +30,6 @@ - true 80 diff --git a/nirc_ehr/resources/web/nirc_ehr/field/EditCase.js b/nirc_ehr/resources/web/nirc_ehr/field/EditCase.js index ca82a78e..dff6631f 100644 --- a/nirc_ehr/resources/web/nirc_ehr/field/EditCase.js +++ b/nirc_ehr/resources/web/nirc_ehr/field/EditCase.js @@ -74,10 +74,14 @@ Ext4.define('NIRC_EHR.form.EditCases', { fieldEnableChange: function(disable){ var panel = this.up('panel'); panel.items.each(function(item){ - if (item.name != 'objectid'){ - this.disableItem(item, disable); - this.disabledDisplay(item, disable); - } + if (item.name === 'objectid') + return; + + // A saved case stays bound to its animal, so Edit must never reopen the Id. + var itemDisable = disable || (this.editing && item.name === 'Id'); + + this.disableItem(item, itemDisable); + this.disabledDisplay(item, itemDisable); }, this); }, @@ -93,11 +97,11 @@ Ext4.define('NIRC_EHR.form.EditCases', { }, onCaseSelect: function(){ + this.editing = true; this.fieldEnableChange(true); if (this.readonly) { return; } - this.editing = true; this.disabled = true; this.editBtn.show(); }, diff --git a/nirc_ehr/resources/web/nirc_ehr/model/sources/Arrival.js b/nirc_ehr/resources/web/nirc_ehr/model/sources/Arrival.js index 25e29fc9..f6f4b367 100644 --- a/nirc_ehr/resources/web/nirc_ehr/model/sources/Arrival.js +++ b/nirc_ehr/resources/web/nirc_ehr/model/sources/Arrival.js @@ -39,7 +39,10 @@ EHR.model.DataModelManager.registerMetadata('Arrival', { allowBlank: false }, 'Id/demographics/birth': { - allowBlank: false + allowBlank: false, + columnConfig: { + width: 150 + } }, 'Id/demographics/gender': { allowBlank: false @@ -107,6 +110,11 @@ EHR.model.DataModelManager.registerMetadata('Arrival', { allowBlank: true, hidden: true, showInGrid: false + }, + attachmentFile: { + columnConfig: { + width: 150 + } } } } diff --git a/nirc_ehr/resources/web/nirc_ehr/model/sources/Rearrival.js b/nirc_ehr/resources/web/nirc_ehr/model/sources/Rearrival.js index 94ae9c4c..6e50ab81 100644 --- a/nirc_ehr/resources/web/nirc_ehr/model/sources/Rearrival.js +++ b/nirc_ehr/resources/web/nirc_ehr/model/sources/Rearrival.js @@ -80,6 +80,11 @@ EHR.model.DataModelManager.registerMetadata('Rearrival', { columns: 'protocol,title' }, }, + attachmentFile: { + columnConfig: { + width: 150 + } + }, } } }); diff --git a/nirc_ehr/src/org/labkey/nirc_ehr/dataentry/section/NIRCArrivalFormSection.java b/nirc_ehr/src/org/labkey/nirc_ehr/dataentry/section/NIRCArrivalFormSection.java index 73107cc6..088e6cd0 100644 --- a/nirc_ehr/src/org/labkey/nirc_ehr/dataentry/section/NIRCArrivalFormSection.java +++ b/nirc_ehr/src/org/labkey/nirc_ehr/dataentry/section/NIRCArrivalFormSection.java @@ -49,6 +49,10 @@ protected List getFieldKeys(TableInfo ti) keys.add(10, FieldKey.fromString("Id/demographics/gender")); keys.add(12, FieldKey.fromString("Id/demographics/geographic_origin")); + FieldKey attachmentFile = FieldKey.fromString("attachmentFile"); + if (keys.remove(attachmentFile)) + keys.add(attachmentFile); + return keys; } } diff --git a/nirc_ehr/src/org/labkey/nirc_ehr/dataentry/section/NIRCRearrivalFormSection.java b/nirc_ehr/src/org/labkey/nirc_ehr/dataentry/section/NIRCRearrivalFormSection.java index fd5728bf..9c66170f 100644 --- a/nirc_ehr/src/org/labkey/nirc_ehr/dataentry/section/NIRCRearrivalFormSection.java +++ b/nirc_ehr/src/org/labkey/nirc_ehr/dataentry/section/NIRCRearrivalFormSection.java @@ -16,7 +16,11 @@ package org.labkey.nirc_ehr.dataentry.section; import org.json.JSONObject; +import org.labkey.api.data.TableInfo; import org.labkey.api.ehr.dataentry.DataEntryFormContext; +import org.labkey.api.query.FieldKey; + +import java.util.List; public class NIRCRearrivalFormSection extends BaseFormSection { @@ -32,4 +36,16 @@ public JSONObject toJSON(DataEntryFormContext ctx, boolean includeFormElements) json.put("dataDependentCollapseHeader", true); return json; } + + @Override + protected List getFieldKeys(TableInfo ti) + { + List keys = super.getFieldKeys(ti); + + FieldKey attachmentFile = FieldKey.fromString("attachmentFile"); + if (keys.remove(attachmentFile)) + keys.add(attachmentFile); + + return keys; + } }