Skip to content

Commit 9138b77

Browse files
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 <martyp@labkey.com>
1 parent c015096 commit 9138b77

14 files changed

Lines changed: 421 additions & 420 deletions
Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,21 @@
1-
/*
2-
* Copyright (c) 2011-2019 LabKey Corporation
3-
*
4-
* Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
5-
*/
6-
71
/**
82
* This query is designed to find housing records that overlap. In this query, the overlap to calculated based on both date and time
93
* A record that ends at the same time that a second record begins is not considered an overlap.
10-
*/
11-
PARAMETERS(StartDate TIMESTAMP, EndDate TIMESTAMP, Room CHAR DEFAULT NULL, Cage CHAR DEFAULT NULL)
124
5+
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
6+
*/
137
SELECT
14-
h.lsid,
15-
h.id,
16-
h.room,
17-
h.cage,
18-
h.date,
19-
h.enddate,
20-
h.reason,
21-
h.remark,
22-
h.qcstate
23-
8+
h.lsid,
9+
h.id,
10+
h.room.area as area, -- Added by Kollil
11+
h.room,
12+
h.cage,
13+
h.date,
14+
h.enddate,
15+
h.reason,
16+
h.remark,
17+
h.qcstate
2418
FROM study.housing h
25-
2619
WHERE
20+
h.qcstate = 18
2721

28-
(h.room = ROOM OR ROOM IS NULL or ROOM = '') AND
29-
(h.cage = CAGE OR CAGE IS NULL OR CAGE = '') AND
30-
31-
/* entered startdate must be <= entered enddate */
32-
coalesce( STARTDATE , cast('1900-01-01 00:00:00.0' as timestamp)) <= coalesce(ENDDATE, now())
33-
and
34-
35-
/* entered startdate must be less than record's enddate */
36-
coalesce( STARTDATE , cast('1900-01-01 00:00:00.0' as timestamp)) < coalesce(h.enddate, now())
37-
and
38-
39-
/* entered enddate must be greater than record's startdate */
40-
coalesce(ENDDATE, now()) >= coalesce(h.date, now())

ehr/resources/queries/study/HousingOverlapsById.sql

Lines changed: 0 additions & 31 deletions
This file was deleted.

ehr/resources/queries/study/HousingOverlapsById/.qview.xml

Lines changed: 0 additions & 64 deletions
This file was deleted.

ehr/resources/queries/study/HousingOverlapsByIdDateOnly.sql

Lines changed: 0 additions & 31 deletions
This file was deleted.

ehr/resources/queries/study/HousingOverlapsByIdDateOnly/.qview.xml

Lines changed: 0 additions & 64 deletions
This file was deleted.

ehr/resources/queries/study/HousingOverlapsById.query.xml renamed to ehr/resources/queries/study/HousingOverlapsReport.query.xml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
<query xmlns="http://labkey.org/data/xml/query">
22
<metadata>
33
<tables xmlns="http://labkey.org/data/xml">
4-
<table tableName="HousingOverlapsById" tableDbType="TABLE">
4+
<table tableName="HousingOverlapsReport" tableDbType="TABLE">
55
<javaCustomizer class="org.labkey.ehr.table.DefaultEHRCustomizer" />
66
<tableTitle>Housing Overlaps</tableTitle>
7-
<description>This query identifies distinct animal IDs that overlapped with given housing records, accounting for date and time</description>
7+
<description>This query identifies distinct housing records that overlapped with the given housing records, accounting for date and time</description>
88
<tableUrl />
99
<columns>
10-
<column columnName="Id">
10+
<column columnName="lsid">
1111
<isKeyField>true</isKeyField>
12-
</column>
13-
<column columnName="date">
14-
<columnTitle>Start Date</columnTitle>
12+
<isHidden>true</isHidden>
1513
</column>
1614
</columns>
1715
<buttonBarOptions position="both" includeStandardButtons="false">
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
PARAMETERS(StartDate TIMESTAMP, EndDate TIMESTAMP)
2+
3+
SELECT
4+
h.lsid,
5+
h.id,
6+
h.room,
7+
h.cage,
8+
h.date,
9+
h.enddate,
10+
h.reason,
11+
h.remark,
12+
h.qcstate
13+
14+
FROM study.housing h
15+
16+
WHERE
17+
18+
/* entered startdate must be <= entered enddate */
19+
coalesce( STARTDATE , cast('1900-01-01 00:00:00.0' as timestamp)) <= coalesce(ENDDATE, now())
20+
and
21+
22+
/* entered startdate must be less than record's enddate */
23+
coalesce( STARTDATE , cast('1900-01-01 00:00:00.0' as timestamp)) < coalesce(h.enddate, now())
24+
and
25+
26+
/* entered enddate must be greater than record's startdate */
27+
coalesce(ENDDATE, now()) >= coalesce(h.date, now())
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<customView xmlns="http://labkey.org/data/xml/queryCustomView">
2+
<sorts>
3+
<sort column="room"/>
4+
<sort column="cage"/>
5+
</sorts>
6+
</customView>

ehr/resources/queries/study/HousingOverlapsByIdDateOnly.query.xml renamed to ehr/resources/queries/study/HousingOverlapsReportDateOnly.query.xml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
<query xmlns="http://labkey.org/data/xml/query">
22
<metadata>
33
<tables xmlns="http://labkey.org/data/xml">
4-
<table tableName="HousingOverlapsByIdDateOnly" tableDbType="TABLE">
4+
<table tableName="HousingOverlapsReportDateOnly" tableDbType="TABLE">
55
<javaCustomizer class="org.labkey.ehr.table.DefaultEHRCustomizer" />
6-
<tableTitle>Housing Overlaps</tableTitle>
7-
<description>This query identifies all distinct animal IDs that overlapped with housing records, accounting for date only, not date/time</description>
6+
<tableTitle>Housing Overlaps (Date Only)</tableTitle>
7+
<description>This query identifies overlapping housing records, accounting for date only, not date/time</description>
88
<tableUrl />
99
<columns>
10-
<column columnName="Id">
10+
<column columnName="lsid">
1111
<isKeyField>true</isKeyField>
12-
</column>
13-
<column columnName="date">
14-
<columnTitle>Start Date</columnTitle>
12+
<isHidden>true</isHidden>
1513
</column>
1614
</columns>
1715
<buttonBarOptions position="both" includeStandardButtons="false">
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
PARAMETERS(StartDate TIMESTAMP, EndDate TIMESTAMP)
2+
3+
SELECT
4+
h.lsid,
5+
h.id,
6+
h.room,
7+
h.cage,
8+
h.date,
9+
h.enddate,
10+
h.reason,
11+
h.remark,
12+
h.qcstate
13+
14+
FROM study.housing h
15+
16+
WHERE
17+
18+
(
19+
(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))
20+
OR
21+
(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))
22+
OR
23+
(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))
24+
)

0 commit comments

Comments
 (0)