From e0d7e796508736f74de0a511c2fc15e067b7659e Mon Sep 17 00:00:00 2001 From: Trey Chadick Date: Mon, 4 Aug 2025 11:44:48 -0700 Subject: [PATCH 1/3] Wait for active report panel to prevent NPEs (#999) --- ehr/test/src/org/labkey/test/pages/ehr/ParticipantViewPage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ehr/test/src/org/labkey/test/pages/ehr/ParticipantViewPage.java b/ehr/test/src/org/labkey/test/pages/ehr/ParticipantViewPage.java index 9b73ebaf2..7477a66de 100644 --- a/ehr/test/src/org/labkey/test/pages/ehr/ParticipantViewPage.java +++ b/ehr/test/src/org/labkey/test/pages/ehr/ParticipantViewPage.java @@ -115,7 +115,7 @@ public ParticipantViewPage clickReportTab(String reportLabel) public WebElement getActiveReportPanel() { - return activeReportPanel.findElementOrNull(getDriver()); + return activeReportPanel.waitForElement(getDriver(), 2_000); } public DataRegionTable getActiveReportDataRegion() From 26555f11f7a29009b0a3fa7bd0d733d0bbbda250 Mon Sep 17 00:00:00 2001 From: Jay Allen <107942890+jallentxbiomed@users.noreply.github.com> Date: Wed, 13 Aug 2025 10:19:00 -0500 Subject: [PATCH 2/3] trim spaces on eventDataNarrative attribute brackets (#1010) --- snd/src/org/labkey/snd/SNDManager.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/snd/src/org/labkey/snd/SNDManager.java b/snd/src/org/labkey/snd/SNDManager.java index d04bd0cc8..124b16018 100644 --- a/snd/src/org/labkey/snd/SNDManager.java +++ b/snd/src/org/labkey/snd/SNDManager.java @@ -3457,7 +3457,12 @@ private String generateEventDataNarrative(Container c, User u, Event event, Even value = "" + value + ""; } - eventDataNarrative = new StringBuilder(eventDataNarrative.toString().replace("{" + pd.getName() + "}", value)); + // Trim any spaces immediately inside '{' and '}' to make tokens like "{ route 2}" -> "{route 2}" + String normalized = eventDataNarrative.toString() + .replaceAll("\\{\\s+", "{") + .replaceAll("\\s+\\}", "}"); + + eventDataNarrative = new StringBuilder(normalized.replace("{" + pd.getName() + "}", value)); } } From 9138b77fb816979c4b53330ebbbefede11dd7378 Mon Sep 17 00:00:00 2001 From: Lakshmi Kolli <69940873+kollil@users.noreply.github.com> Date: Wed, 27 Aug 2025 17:06:14 -0700 Subject: [PATCH 3/3] Housing overlaps form changes (#1003) - Add Area field with multi select to pick rooms - Add Building field with multi select to pick rooms - Update to handle multi-room selection --------- Co-authored-by: Marty Pradere --- .../queries/study/HousingOverlaps.sql | 45 +- .../queries/study/HousingOverlapsById.sql | 31 -- .../study/HousingOverlapsById/.qview.xml | 64 --- .../study/HousingOverlapsByIdDateOnly.sql | 31 -- .../HousingOverlapsByIdDateOnly/.qview.xml | 64 --- ...ry.xml => HousingOverlapsReport.query.xml} | 10 +- .../queries/study/HousingOverlapsReport.sql | 27 ++ .../study/HousingOverlapsReport/.qview.xml | 6 + ...> HousingOverlapsReportDateOnly.query.xml} | 12 +- .../study/HousingOverlapsReportDateOnly.sql | 24 + ehr/resources/views/housingOverlaps.html | 436 ++++++++++-------- ehr/resources/web/ehr/ehr_api.lib.xml | 1 + .../web/ehr/form/field/BuildingField.js | 59 +++ ehr/resources/web/ehr/form/field/RoomField.js | 31 +- 14 files changed, 421 insertions(+), 420 deletions(-) delete mode 100644 ehr/resources/queries/study/HousingOverlapsById.sql delete mode 100644 ehr/resources/queries/study/HousingOverlapsById/.qview.xml delete mode 100644 ehr/resources/queries/study/HousingOverlapsByIdDateOnly.sql delete mode 100644 ehr/resources/queries/study/HousingOverlapsByIdDateOnly/.qview.xml rename ehr/resources/queries/study/{HousingOverlapsById.query.xml => HousingOverlapsReport.query.xml} (82%) create mode 100644 ehr/resources/queries/study/HousingOverlapsReport.sql create mode 100644 ehr/resources/queries/study/HousingOverlapsReport/.qview.xml rename ehr/resources/queries/study/{HousingOverlapsByIdDateOnly.query.xml => HousingOverlapsReportDateOnly.query.xml} (79%) create mode 100644 ehr/resources/queries/study/HousingOverlapsReportDateOnly.sql create mode 100644 ehr/resources/web/ehr/form/field/BuildingField.js diff --git a/ehr/resources/queries/study/HousingOverlaps.sql b/ehr/resources/queries/study/HousingOverlaps.sql index a4efd7d90..2889b8eca 100644 --- a/ehr/resources/queries/study/HousingOverlaps.sql +++ b/ehr/resources/queries/study/HousingOverlaps.sql @@ -1,40 +1,21 @@ -/* - * Copyright (c) 2011-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0 - */ - /** * This query is designed to find housing records that overlap. In this query, the overlap to calculated based on both date and time * A record that ends at the same time that a second record begins is not considered an overlap. - */ -PARAMETERS(StartDate TIMESTAMP, EndDate TIMESTAMP, Room CHAR DEFAULT NULL, Cage CHAR DEFAULT NULL) + Modified by Kollil on 7/23/25 - Added Area field to the query and the rooms are filtered by area(s) selected, refer to tkt # 12894 + */ SELECT -h.lsid, -h.id, -h.room, -h.cage, -h.date, -h.enddate, -h.reason, -h.remark, -h.qcstate - + h.lsid, + h.id, + h.room.area as area, -- Added by Kollil + h.room, + h.cage, + h.date, + h.enddate, + h.reason, + h.remark, + h.qcstate FROM study.housing h - WHERE + h.qcstate = 18 -(h.room = ROOM OR ROOM IS NULL or ROOM = '') AND -(h.cage = CAGE OR CAGE IS NULL OR CAGE = '') AND - -/* entered startdate must be <= entered enddate */ -coalesce( STARTDATE , cast('1900-01-01 00:00:00.0' as timestamp)) <= coalesce(ENDDATE, now()) -and - -/* entered startdate must be less than record's enddate */ -coalesce( STARTDATE , cast('1900-01-01 00:00:00.0' as timestamp)) < coalesce(h.enddate, now()) -and - -/* entered enddate must be greater than record's startdate */ -coalesce(ENDDATE, now()) >= coalesce(h.date, now()) \ No newline at end of file diff --git a/ehr/resources/queries/study/HousingOverlapsById.sql b/ehr/resources/queries/study/HousingOverlapsById.sql deleted file mode 100644 index 6296f7ef7..000000000 --- a/ehr/resources/queries/study/HousingOverlapsById.sql +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2011-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0 - */ - -PARAMETERS(StartDate TIMESTAMP, EndDate TIMESTAMP, Room CHAR DEFAULT NULL, Cage CHAR DEFAULT NULL) - -SELECT -h.Id, -cast(StartDate as timestamp) as date - -FROM study.housing h - -WHERE - -(h.room = ROOM OR ROOM IS NULL or ROOM = '') AND -(h.cage = CAGE OR CAGE IS NULL OR CAGE = '') AND - -/* entered startdate must be <= enddate */ -coalesce( STARTDATE , cast('1900-01-01 00:00:00.0' as timestamp)) <= coalesce(ENDDATE, now()) -and - -/* entered startdate must be less than record's enddate */ -coalesce( STARTDATE , cast('1900-01-01 00:00:00.0' as timestamp)) < coalesce(h.enddate, now()) -and - -/* entered enddate must be greater than record's startdate */ -coalesce(ENDDATE, now()) >= coalesce(h.date, now()) - -GROUP BY h.Id \ No newline at end of file diff --git a/ehr/resources/queries/study/HousingOverlapsById/.qview.xml b/ehr/resources/queries/study/HousingOverlapsById/.qview.xml deleted file mode 100644 index 603b1f172..000000000 --- a/ehr/resources/queries/study/HousingOverlapsById/.qview.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ehr/resources/queries/study/HousingOverlapsByIdDateOnly.sql b/ehr/resources/queries/study/HousingOverlapsByIdDateOnly.sql deleted file mode 100644 index a6fa7185e..000000000 --- a/ehr/resources/queries/study/HousingOverlapsByIdDateOnly.sql +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2012-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0 - */ - -PARAMETERS(StartDate TIMESTAMP, EndDate TIMESTAMP, Room CHAR DEFAULT NULL, Cage CHAR DEFAULT NULL) - -SELECT -h.Id, -cast(StartDate as timestamp) as date - -FROM study.housing h - -WHERE - -(h.room = ROOM OR ROOM IS NULL or ROOM = '') AND -(h.cage = CAGE OR CAGE IS NULL OR CAGE = '') AND - -/* entered startdate must be <= enddate */ -cast(coalesce(STARTDATE , cast('1900-01-01' as DATE)) as DATE) <= cast(coalesce(ENDDATE, now()) as DATE) -and - -/* entered startdate must be less than record's enddate */ -cast(coalesce(STARTDATE , cast('1900-01-01' as DATE)) as DATE) < cast(coalesce(h.enddate, now()) as DATE) -and - -/* entered enddate must be greater than record's startdate */ -cast(coalesce(ENDDATE, now()) as DATE) >= cast(coalesce(h.date, now()) as DATE) - -GROUP BY h.Id \ No newline at end of file diff --git a/ehr/resources/queries/study/HousingOverlapsByIdDateOnly/.qview.xml b/ehr/resources/queries/study/HousingOverlapsByIdDateOnly/.qview.xml deleted file mode 100644 index 32b8acce5..000000000 --- a/ehr/resources/queries/study/HousingOverlapsByIdDateOnly/.qview.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ehr/resources/queries/study/HousingOverlapsById.query.xml b/ehr/resources/queries/study/HousingOverlapsReport.query.xml similarity index 82% rename from ehr/resources/queries/study/HousingOverlapsById.query.xml rename to ehr/resources/queries/study/HousingOverlapsReport.query.xml index 1f1321218..1256b36ac 100644 --- a/ehr/resources/queries/study/HousingOverlapsById.query.xml +++ b/ehr/resources/queries/study/HousingOverlapsReport.query.xml @@ -1,17 +1,15 @@ - +
Housing Overlaps - This query identifies distinct animal IDs that overlapped with given housing records, accounting for date and time + This query identifies distinct housing records that overlapped with the given housing records, accounting for date and time - + true - - - Start Date + true diff --git a/ehr/resources/queries/study/HousingOverlapsReport.sql b/ehr/resources/queries/study/HousingOverlapsReport.sql new file mode 100644 index 000000000..f2cb68596 --- /dev/null +++ b/ehr/resources/queries/study/HousingOverlapsReport.sql @@ -0,0 +1,27 @@ +PARAMETERS(StartDate TIMESTAMP, EndDate TIMESTAMP) + +SELECT + h.lsid, + h.id, + h.room, + h.cage, + h.date, + h.enddate, + h.reason, + h.remark, + h.qcstate + +FROM study.housing h + +WHERE + +/* entered startdate must be <= entered enddate */ + coalesce( STARTDATE , cast('1900-01-01 00:00:00.0' as timestamp)) <= coalesce(ENDDATE, now()) + and + +/* entered startdate must be less than record's enddate */ + coalesce( STARTDATE , cast('1900-01-01 00:00:00.0' as timestamp)) < coalesce(h.enddate, now()) + and + +/* entered enddate must be greater than record's startdate */ + coalesce(ENDDATE, now()) >= coalesce(h.date, now()) \ No newline at end of file diff --git a/ehr/resources/queries/study/HousingOverlapsReport/.qview.xml b/ehr/resources/queries/study/HousingOverlapsReport/.qview.xml new file mode 100644 index 000000000..7edf3755c --- /dev/null +++ b/ehr/resources/queries/study/HousingOverlapsReport/.qview.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ehr/resources/queries/study/HousingOverlapsByIdDateOnly.query.xml b/ehr/resources/queries/study/HousingOverlapsReportDateOnly.query.xml similarity index 79% rename from ehr/resources/queries/study/HousingOverlapsByIdDateOnly.query.xml rename to ehr/resources/queries/study/HousingOverlapsReportDateOnly.query.xml index 967758d1c..ae23c19fe 100644 --- a/ehr/resources/queries/study/HousingOverlapsByIdDateOnly.query.xml +++ b/ehr/resources/queries/study/HousingOverlapsReportDateOnly.query.xml @@ -1,17 +1,15 @@ -
+
- Housing Overlaps - This query identifies all distinct animal IDs that overlapped with housing records, accounting for date only, not date/time + Housing Overlaps (Date Only) + This query identifies overlapping housing records, accounting for date only, not date/time - + true - - - Start Date + true diff --git a/ehr/resources/queries/study/HousingOverlapsReportDateOnly.sql b/ehr/resources/queries/study/HousingOverlapsReportDateOnly.sql new file mode 100644 index 000000000..65847cacd --- /dev/null +++ b/ehr/resources/queries/study/HousingOverlapsReportDateOnly.sql @@ -0,0 +1,24 @@ +PARAMETERS(StartDate TIMESTAMP, EndDate TIMESTAMP) + +SELECT + h.lsid, + h.id, + h.room, + h.cage, + h.date, + h.enddate, + h.reason, + h.remark, + h.qcstate + +FROM study.housing h + +WHERE + + ( + (cast(COALESCE(STARTDATE, '1900-01-01') AS DATE) >= cast(h.date AS DATE) AND cast(COALESCE(STARTDATE, '1900-01-01') AS DATE) < cast(COALESCE(h.enddate, now()) AS DATE)) + OR + (cast(COALESCE(ENDDATE, now()) AS DATE) > cast(h.date AS DATE) AND cast(COALESCE(ENDDATE, now()) AS DATE) <= cast(COALESCE(h.enddate, now()) AS DATE)) + OR + (cast(COALESCE(STARTDATE, '1900-01-01') AS DATE) <= cast(h.date AS DATE) AND cast(COALESCE(ENDDATE, now()) AS DATE) >= cast(COALESCE(h.enddate, now()) AS DATE)) + ) \ No newline at end of file diff --git a/ehr/resources/views/housingOverlaps.html b/ehr/resources/views/housingOverlaps.html index 9736656cc..48f211317 100644 --- a/ehr/resources/views/housingOverlaps.html +++ b/ehr/resources/views/housingOverlaps.html @@ -1,210 +1,278 @@ + + \ No newline at end of file diff --git a/ehr/resources/web/ehr/ehr_api.lib.xml b/ehr/resources/web/ehr/ehr_api.lib.xml index 59f74effe..ead5f3356 100644 --- a/ehr/resources/web/ehr/ehr_api.lib.xml +++ b/ehr/resources/web/ehr/ehr_api.lib.xml @@ -63,6 +63,7 @@