Skip to content
Merged
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
21 changes: 11 additions & 10 deletions onprc_ehr/resources/queries/study/parentageSummary.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2017 LabKey Corporation
* Copyright (c) 2013-2016 LabKey Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -21,9 +21,9 @@ SELECT
p.method

FROM study.parentage p
WHERE p.qcstate.publicdata = true and p.enddateCoalesced <= now()
WHERE p.qcstate.publicdata = true and p.enddate is null

UNION ALL
UNION

SELECT
b.Id,
Expand All @@ -34,15 +34,16 @@ SELECT

FROM study.birth b
WHERE b.dam is not null and b.qcstate.publicdata = true

UNION ALL
And 'dam' not in (select k.relationship from study.parentage k where k.Id = b.Id and k.enddate is null)
UNION

SELECT
b.Id,
b.date,
b.sire,
a.Id,
a.date,
a.sire,
'Sire' as relationship,
'Observed' as method

FROM study.birth b
WHERE b.sire is not null and b.qcstate.publicdata = true
FROM study.birth a
WHERE a.sire is not null and a.qcstate.publicdata = true
And 'sire' not in (select k.relationship from study.parentage k where k.Id = a.Id and k.enddate is null)