Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions snprc_ehr/resources/queries/study/GenDemoCustomizer.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ Select d.Id,
d.species,
d.species.arc_species_code as ARC_species,
*/
IFNULL(g.HasGeneExpressionData,0) as HasGeneExpressionData,
IFNULL(s.HasSNPData,0) as HasSNPData,
IFNULL(m.HasMicrosatellitesData,0) as HasMicrosatellitesData,
IFNULL(p.HasphenotypesData,0) as HasPhenotypeData
-- Cast boolean → integer first so the IFNULL result type is INTEGER, not BOOLEAN.
-- Both args matching as BOOLEAN triggers SQL Server's BIT→BOOLEAN CASE-wrap (error 4145);
-- mixing BOOLEAN with integer 0 fails on Postgres ("COALESCE types boolean and integer cannot be matched").
IFNULL(CAST(g.HasGeneExpressionData AS INTEGER), 0) as HasGeneExpressionData,
IFNULL(CAST(s.HasSNPData AS INTEGER), 0) as HasSNPData,
IFNULL(CAST(m.HasMicrosatellitesData AS INTEGER), 0) as HasMicrosatellitesData,
IFNULL(CAST(p.HasphenotypesData AS INTEGER), 0) as HasPhenotypeData

From study.demographics d
LEFT OUTER JOIN study.GenFlagSNP s
Expand Down
8 changes: 4 additions & 4 deletions snprc_ehr/resources/queries/study/GenDemoHasData.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ Select d.Id,
d.gender,
d.species,
d.species.arc_species_code as ARC_species,
IFNULL(g.HasGeneExpressionData,0) as HasGeneExpressionData,
IFNULL(s.HasSNPData,0) as HasSNPData,
IFNULL(m.HasMicrosatellitesData,0) as HasMicrosatellitesData,
IFNULL(p.HasphenotypesData,0) as HasPhenotypeData
IFNULL(CAST(g.HasGeneExpressionData AS INTEGER), 0) as HasGeneExpressionData,
IFNULL(CAST(s.HasSNPData AS INTEGER), 0) as HasSNPData,
IFNULL(CAST(m.HasMicrosatellitesData AS INTEGER), 0) as HasMicrosatellitesData,
IFNULL(CAST(p.HasphenotypesData AS INTEGER), 0) as HasPhenotypeData

From study.demographics d
LEFT OUTER JOIN study.GenFlagSNP s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<fkTable>animal</fkTable>
<fkColumnName>Id</fkColumnName>
</fk>
<columnIndex></columnIndex>
</column>
</columns>
<indices>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<fkTable>animal</fkTable>
<fkColumnName>Id</fkColumnName>
</fk>
<columnIndex></columnIndex>
</column>
</columns>
<indices>
Expand Down
1 change: 0 additions & 1 deletion snprc_ehr/resources/queries/study/GenHasSNP.query.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<fkTable>animal</fkTable>
<fkColumnName>Id</fkColumnName>
</fk>
<columnIndex></columnIndex>
</column>
</columns>
<indices>
Expand Down
44 changes: 0 additions & 44 deletions snprc_ehr/resources/queries/study/LabworkOvaParasite.sql

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
<columnTitle>First Date</columnTitle>
</column>
</columns>
<sorts>
<sort column="MinDate" descending="true"/>
</sorts>
</table>
</tables>
</metadata>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
<columnTitle>Test Count</columnTitle>
</column>
</columns>
<sorts>
<sort column="MinDate" descending="true"/>
</sorts>
</table>
</tables>
</metadata>
Expand Down
9 changes: 6 additions & 3 deletions snprc_ehr/resources/queries/study/chemMisc.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ SELECT
b.id,
b.date,
b.testId,
b.testId.Name,
lt.testName,

b.resultOORIndicator,
b.result,
Expand All @@ -17,6 +17,9 @@ SELECT
b.taskid,
b.runId
FROM study.labworkResults b

WHERE b.testId.Type = 'Biochemistry' AND (b.testId.includeInPanel = false OR b.testId.includeInPanel IS NULL) AND b.qcstate.publicdata = true
INNER JOIN snprc_ehr.labwork_panels AS lt
ON b.serviceTestid = lt.rowId
AND lt.ServiceId.Dataset='Biochemistry'
AND (b.serviceTestid.includeInPanel = false OR b.serviceTestid.includeInPanel IS NULL)
AND b.qcstate.publicdata = true

58 changes: 58 additions & 0 deletions snprc_ehr/resources/queries/study/colonyPopulationChange.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (c) 2026 LabKey Corporation
*
* Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
*/
PARAMETERS(StartDate TIMESTAMP, EndDate TIMESTAMP)

SELECT
T1.id,
T1.id.dataset.demographics.species as species,
'Births' AS Category,
T1.date,
convert(year(T1.date), integer) AS Year

FROM study.Birth T1
WHERE T1.date IS NOT NULL
and cast(COALESCE(STARTDATE, '1900-01-01') as date) <= T1.date and cast(COALESCE(ENDDATE, curdate()) as date) >= cast(T1.date as date)

UNION ALL

SELECT
T2.id,
T2.id.dataset.demographics.species,
'Arrivals' AS Category,
T2.date,
convert(year(T2.date), INTEGER) AS Year

FROM study.Arrival T2
WHERE T2.date IS NOT NULL
AND T2.qcstate.publicdata = true
and cast(COALESCE(STARTDATE, '1900-01-01') as date) <= T2.date and cast(COALESCE(ENDDATE, curdate()) as date) >= cast(T2.date as date)

UNION ALL

SELECT
T3.id,
T3.id.dataset.demographics.species,
'Departures' AS Category,
T3.date,
convert(year(T3.date), INTEGER) AS Year

FROM study.Departure T3
WHERE T3.date IS NOT NULL
AND T3.qcstate.publicdata = true
and cast(COALESCE(STARTDATE, '1900-01-01') as date) <= T3.date and cast(COALESCE(ENDDATE, curdate()) as date) >= cast(T3.date as date)

UNION ALL

SELECT
T4.id,
T4.id.dataset.demographics.species,
'Deaths' AS Category,
T4.date,
convert(year(T4.date), INTEGER) AS Year

FROM study.Deaths T4
WHERE T4.date IS NOT NULL
and cast(COALESCE(STARTDATE, '1900-01-01') as date) <= T4.date and cast(COALESCE(ENDDATE, curdate()) as date) >= cast(T4.date as date)
7 changes: 5 additions & 2 deletions snprc_ehr/resources/queries/study/hematologyMisc.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@ SELECT
b.taskid,
b.runId
FROM study.labworkResults b

WHERE (testId.includeInPanel = FALSE OR b.testid.includeInPanel IS NULL) and b.qcstate.publicdata = true
INNER JOIN snprc_ehr.labwork_panels AS lt
ON b.serviceTestid = lt.rowId
AND lt.ServiceId.Dataset='Hematology'
AND (b.serviceTestid.includeInPanel = false OR b.serviceTestid.includeInPanel IS NULL)
AND b.qcstate.publicdata = true
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
<fkColumnName>UserId</fkColumnName>
<fkTable>Users</fkTable>
<fkDbSchema>core</fkDbSchema>
</fk>`
</fk>
</column>
<column columnName="qcstate">
<isHidden>true</isHidden>
Expand Down
Loading