Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add modified field to pedigree tables #1121

Merged
merged 1 commit into from
Sep 23, 2024
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
10 changes: 5 additions & 5 deletions onprc_ehr/resources/queries/study/demographicsParents.sql
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,26 @@ SELECT

(CASE WHEN p3.parent IS NOT NULL THEN 1 ELSE 0 END +
CASE WHEN coalesce(p2.parent, b.dam) IS NOT NULL THEN 1 ELSE 0 END +
CASE WHEN coalesce(p1.parent, b.sire) IS NOT NULL THEN 1 ELSE 0 END) as numParents

CASE WHEN coalesce(p1.parent, b.sire) IS NOT NULL THEN 1 ELSE 0 END) as numParents,
greatest(d.modified, p1.modified, p2.modified, p3.modified, b.modified) as modified
FROM study.demographics d

LEFT JOIN (
select p1.id, min(p1.method) as method, max(p1.parent) as parent
select p1.id, min(p1.method) as method, max(p1.parent) as parent, max(p1.modified) as modified
FROM study.parentage p1
WHERE (p1.method = 'Genetic' OR p1.method = 'Provisional Genetic') AND p1.relationship = 'Sire' AND p1.enddate IS NULL
GROUP BY p1.Id
) p1 ON (d.Id = p1.id)

LEFT JOIN (
select p2.id, min(p2.method) as method, max(p2.parent) as parent
select p2.id, min(p2.method) as method, max(p2.parent) as parent, max(p2.modified) as modified
FROM study.parentage p2
WHERE (p2.method = 'Genetic' OR p2.method = 'Provisional Genetic') AND p2.relationship = 'Dam' AND p2.enddate IS NULL
GROUP BY p2.Id
) p2 ON (d.Id = p2.id)

LEFT JOIN (
select p3.id, min(p3.method) as method, max(p3.parent) as parent
select p3.id, min(p3.method) as method, max(p3.parent) as parent, max(p3.modified) as modified
FROM study.parentage p3
WHERE p3.relationship = 'Foster Dam' AND p3.enddate IS NULL
GROUP BY p3.Id
Expand Down
3 changes: 2 additions & 1 deletion onprc_ehr/resources/queries/study/pedigree.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ AS status,
d.id.demographics.calculated_status as status_code,
d.id.demographics.species,
'' as Display,
'Demographics' as source
'Demographics' as source,
d.modified

FROM study.demographicsParents d
WHERE d.numParents > 0