Skip to content

Commit f744bfe

Browse files
Merge 25.11 to 26.3
2 parents 482c895 + 543577d commit f744bfe

7 files changed

Lines changed: 332 additions & 60 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<query xmlns="http://labkey.org/data/xml/query">
2+
<metadata>
3+
<tables xmlns="http://labkey.org/data/xml">
4+
<table tableName="Demographics_NotInMMA" tableDbType="NOT_IN_DB">
5+
<tableTitle>Demographics (Excluding animals in Weight MMA regimen)</tableTitle>
6+
</table>
7+
</tables>
8+
</metadata>
9+
</query>
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
Created by Kollil in Dec 2025
3+
Tkt # 13461
4+
Added two filters to the Demographics dataset:
5+
1. Filter out any animal with the following SNOMED Codes:
6+
Begin active weight management regimen (P-YY961)
7+
However, we would need to include animals that have this additional SNOMED Code if it's entered AFTER the one above
8+
Release from active weight management regimen (P-YY960)
9+
2. Remove Shelters, Corral and Hospital locations from the lists
10+
*/
11+
12+
SELECT
13+
d.Id.curlocation.area AS Area,
14+
d.Id.curlocation.room AS Room,
15+
d.Id.curlocation.cage AS Cage,
16+
d.Id,
17+
d.Id.utilization.use AS ProjectsAndGroups,
18+
d.species,
19+
d.geographic_origin,
20+
d.gender AS Sex,
21+
d.calculated_status,
22+
d.birth,
23+
d.Id.Age.YearAndDays,
24+
d.Id.MostRecentWeight.MostRecentWeight,
25+
d.Id.MostRecentWeight.MostRecentWeightDate,
26+
d.Id.viral_status.viralStatus,
27+
d.history
28+
FROM Demographics d
29+
WHERE d.Id.curlocation.area NOT IN ('Shelters', 'Corral', 'Hospital', 'Catch Area')-- Exclude animals from these locations
30+
AND NOT (-- Exclude females under 5yrs, males under 7yrs
31+
(d.gender.code = 'f' AND d.Id.age.ageInYears < 5)
32+
OR (d.gender.code = 'm' AND d.Id.age.ageInYears < 7)
33+
)
34+
AND NOT EXISTS (
35+
-- -- Find animals whose latest 'Weight MMA BEGIN' has no later 'Weight MMA RELEASE'
36+
SELECT 1
37+
FROM study.WeightMMA b
38+
WHERE b.Id = d.Id
39+
AND b.code = 'P-YY961'
40+
AND b.date = (
41+
SELECT MAX(b2.date)
42+
FROM study.WeightMMA b2
43+
WHERE b2.Id = d.Id
44+
AND b2.code = 'P-YY961'
45+
)
46+
AND NOT EXISTS (
47+
SELECT 1
48+
FROM study.WeightMMA r
49+
WHERE r.Id = d.Id
50+
AND r.code = 'P-YY960'
51+
AND r.date > b.date
52+
)
53+
)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<query xmlns="http://labkey.org/data/xml/query">
2+
<metadata>
3+
<tables xmlns="http://labkey.org/data/xml">
4+
<table tableName="WeightMMA" tableDbType="NOT_IN_DB">
5+
<tableTitle>Animals in weight management regimen</tableTitle>
6+
<columns>
7+
<column columnName="Id">
8+
<isHidden>false</isHidden>
9+
<fk>
10+
<fkDbSchema>study</fkDbSchema>
11+
<fkTable>animal</fkTable>
12+
<fkColumnName>id</fkColumnName>
13+
</fk>
14+
</column>
15+
<column columnName="date">
16+
<isHidden>false</isHidden>
17+
<columnTitle>Prev Weight Date</columnTitle>
18+
</column>
19+
<column columnName="set_number">
20+
<columnTitle>Set Number</columnTitle>
21+
</column>
22+
<column columnName="code">
23+
<columnTitle>Snomed Code</columnTitle>
24+
</column>
25+
<column columnName="qualifier">
26+
<columnTitle>Qualifier</columnTitle>
27+
</column>
28+
</columns>
29+
</table>
30+
</tables>
31+
</metadata>
32+
</query>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
-- Created by Kolli, March 2026
2+
--New query created in the code base as the automated tests are failing.
3+
SELECT s.Id,
4+
s.date,
5+
s.set_number,
6+
s.code,
7+
s.qualifier
8+
FROM ehr.snomed_tags s
9+
where s.code like 'P-YY961'
10+
11+
Union
12+
13+
SELECT s.Id,
14+
s.date,
15+
s.set_number,
16+
s.code,
17+
s.qualifier
18+
FROM ehr.snomed_tags s
19+
where s.code like 'P-YY960'
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<query xmlns="http://labkey.org/data/xml/query">
2+
<metadata>
3+
<tables xmlns="http://labkey.org/data/xml">
4+
<table tableName="weightRelChange_NotInMMA" tableDbType="NOT_IN_DB">
5+
<tableTitle>Weight Change, Relative to Current Weight (Excluding the animals enrolled in MMA)</tableTitle>
6+
<description>This query shows the percent change of each weight, relative to the current weight</description>
7+
<columns>
8+
<column columnName="lsid">
9+
<isKeyField>true</isKeyField>
10+
<isHidden>true</isHidden>
11+
</column>
12+
<column columnName="Id">
13+
<isHidden>false</isHidden>
14+
<fk>
15+
<fkDbSchema>study</fkDbSchema>
16+
<fkTable>animal</fkTable>
17+
<fkColumnName>id</fkColumnName>
18+
</fk>
19+
</column>
20+
<column columnName="date">
21+
<isHidden>false</isHidden>
22+
<columnTitle>Prev Weight Date</columnTitle>
23+
</column>
24+
<column columnName="weight">
25+
<columnTitle>Prev Weight (kg)</columnTitle>
26+
</column>
27+
<column columnName="PctChange">
28+
<columnTitle>% Change Relative To Current</columnTitle>
29+
</column>
30+
<column columnName="AbsPctChange">
31+
<columnTitle>Abs Pct Change</columnTitle>
32+
</column>
33+
</columns>
34+
</table>
35+
</tables>
36+
</metadata>
37+
</query>
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
Created by Kollil in Dec 2025
3+
Tkt # 13461
4+
Added two filters to the Demographics dataset:
5+
1. Filter out any animal with the following SNOMED Codes:
6+
Begin active weight management regimen (P-YY961)
7+
However, we would need to include animals that have this additional SNOMED Code if it's entered AFTER the one above
8+
Release from active weight management regimen (P-YY960)
9+
2. Remove Shelters, Corral and Hospital locations from the lists
10+
*/
11+
12+
SELECT DISTINCT
13+
l.lsid,
14+
l.Id,
15+
16+
l.date AS LatestWeightDate,
17+
l.weight AS LatestWeight,
18+
19+
p.date, -- AS PrevWeightDate
20+
p.weight, -- AS PrevWeight
21+
22+
timestampdiff('SQL_TSI_DAY', p.date, l.date) AS IntervalInDays,
23+
age_in_months(p.date, l.date) AS IntervalInMonths,
24+
25+
CASE
26+
WHEN p.weight IS NOT NULL AND p.weight > 0 THEN
27+
ROUND(((l.weight - p.weight) * 100 / p.weight), 1)
28+
ELSE NULL
29+
END AS PctChange,
30+
31+
CASE
32+
WHEN p.weight IS NOT NULL AND p.weight > 0 THEN
33+
ABS(ROUND(((l.weight - p.weight) * 100 / p.weight), 1))
34+
ELSE NULL
35+
END AS AbsPctChange,
36+
37+
l.qcstate AS LatestQcState,
38+
p.qcstate AS PrevQcState
39+
40+
FROM
41+
(SELECT Id, MAX(date) AS LatestDate
42+
FROM study.weight
43+
GROUP BY Id) lw
44+
45+
JOIN study.weight l
46+
ON l.Id = lw.Id
47+
AND l.date = lw.LatestDate
48+
49+
LEFT JOIN study.weight p
50+
ON p.Id = lw.Id
51+
AND p.date = (
52+
SELECT MAX(w2.date)
53+
FROM study.weight w2
54+
WHERE w2.Id = lw.Id
55+
AND w2.date <= timestampadd('SQL_TSI_DAY', -30, lw.LatestDate)
56+
AND w2.date >= timestampadd('SQL_TSI_DAY', -100, lw.LatestDate)
57+
)
58+
59+
WHERE l.Id.curlocation.area NOT IN ('Shelters', 'Corral', 'Hospital', 'Catch Area')-- Exclude animals from these locations
60+
AND NOT (-- Exclude females under 5yrs, males under 7yrs
61+
(l.Id.demographics.gender.code = 'f' AND l.Id.age.ageInYears < 5)
62+
OR (l.Id.demographics.gender.code = 'm' AND l.Id.age.ageInYears < 7)
63+
)
64+
AND l.qcstate.publicdata = true
65+
AND NOT EXISTS (
66+
-- -- Find animals whose latest 'Weight MMA BEGIN' has no later 'Weight MMA RELEASE'
67+
SELECT 1
68+
FROM study.WeightMMA b
69+
WHERE b.Id = l.Id
70+
AND b.code = 'P-YY961'
71+
AND b.date = (
72+
SELECT MAX(b2.date)
73+
FROM study.WeightMMA b2
74+
WHERE b2.Id = l.Id
75+
AND b2.code = 'P-YY961'
76+
)
77+
AND NOT EXISTS (
78+
SELECT 1
79+
FROM study.WeightMMA r
80+
WHERE r.Id = l.Id
81+
AND r.code = 'P-YY960'
82+
AND r.date > b.date
83+
)
84+
)

0 commit comments

Comments
 (0)