From d8c696aa360a5fe7f1d3388f4ecc4e8c0706a71b Mon Sep 17 00:00:00 2001 From: Ohsudev <76500320+Ohsudev@users.noreply.github.com> Date: Mon, 27 Oct 2025 17:26:13 -0700 Subject: [PATCH 1/9] Modified Parentage program so that the dam and sire information overrides information from birth records. --- .../queries/study/parentageSummary.sql | 88 +++++++++++-------- 1 file changed, 51 insertions(+), 37 deletions(-) diff --git a/onprc_ehr/resources/queries/study/parentageSummary.sql b/onprc_ehr/resources/queries/study/parentageSummary.sql index 9eecf38cc..baa1e64fd 100644 --- a/onprc_ehr/resources/queries/study/parentageSummary.sql +++ b/onprc_ehr/resources/queries/study/parentageSummary.sql @@ -1,48 +1,62 @@ -/* - * Copyright (c) 2013-2017 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ SELECT - p.Id, - p.date, - p.parent, - p.relationship, - p.method + p.Id, + p.date, + Case when p.parent is not null then p.parent + when t.dam is not null then t.dam + when t2.sire is not null then t2.sire + end as parent, + case when p.parent is not null then p.relationship + when t.dam is not null then 'dam' + when t2.sire is not null then 'sire' + end as relationship, + case when p.parent is not null then p.method + when t.dam is not null then 'observed' + when t2.sire is not null then 'observed' + end as method -FROM study.parentage p -WHERE p.qcstate.publicdata = true and p.enddateCoalesced <= now() +FROM ( -UNION ALL + select + p.Id, + p.date, + p.parent, + p.relationship, + p.method -SELECT - b.Id, + from study.parentage p + WHERE (p.qcstate.publicdata = true and p.enddateCoalesced <= now() ) + + LEFT JOIN + + ( select + b.Id, b.date, b.dam, 'Dam' as relationship, 'Observed' as method -FROM study.birth b -WHERE b.dam is not null and b.qcstate.publicdata = true -UNION ALL + from study.birth b + where b.dam is not null and b.qcstate.publicdata = true + +) t on (p.Id = t.Id ) + + LEFT JOIN + + ( SELECT + a.Id, + a.date, + a.sire, + 'Sire' as relationship, + 'Observed' as method + + FROM study.birth a + where a.sire is not null and a.qcstate.publicdata = true + + ) t2 on ( p.Id = t2.Id ) + + ------ where p.id = '43187' + + + group by p.Id -SELECT - b.Id, - b.date, - b.sire, - 'Sire' as relationship, - 'Observed' as method - -FROM study.birth b -WHERE b.sire is not null and b.qcstate.publicdata = true \ No newline at end of file From 9c0a1421016177f11b6e2d7926bb5af49afe9705 Mon Sep 17 00:00:00 2001 From: Ohsudev <76500320+Ohsudev@users.noreply.github.com> Date: Mon, 27 Oct 2025 23:35:56 -0700 Subject: [PATCH 2/9] Modified Parentage program so that the dam and sire information overrides information from birth records. --- .../queries/study/parentageSummary.sql | 57 ++++++++----------- 1 file changed, 25 insertions(+), 32 deletions(-) diff --git a/onprc_ehr/resources/queries/study/parentageSummary.sql b/onprc_ehr/resources/queries/study/parentageSummary.sql index baa1e64fd..0a2712ef6 100644 --- a/onprc_ehr/resources/queries/study/parentageSummary.sql +++ b/onprc_ehr/resources/queries/study/parentageSummary.sql @@ -14,49 +14,42 @@ SELECT when t2.sire is not null then 'observed' end as method -FROM ( - select - p.Id, - p.date, - p.parent, - p.relationship, - p.method - from study.parentage p - WHERE (p.qcstate.publicdata = true and p.enddateCoalesced <= now() ) +from study.parentage p - LEFT JOIN - - ( select - b.Id, - b.date, - b.dam, - 'Dam' as relationship, - 'Observed' as method + LEFT JOIN - from study.birth b - where b.dam is not null and b.qcstate.publicdata = true + ( select + b.Id, + b.date, + b.dam, + 'Dam' as relationship, + 'Observed' as method -) t on (p.Id = t.Id ) - LEFT JOIN + from study.birth b + where b.dam is not null and b.qcstate.publicdata = true - ( SELECT - a.Id, - a.date, - a.sire, - 'Sire' as relationship, - 'Observed' as method - FROM study.birth a - where a.sire is not null and a.qcstate.publicdata = true + )t on (t.Id = p.Id) - ) t2 on ( p.Id = t2.Id ) + LEFT JOIN + + ( SELECT + a.Id, + a.date, + a.sire, + 'Sire' as relationship, + 'Observed' as method + + FROM study.birth a + where a.sire is not null and a.qcstate.publicdata = true + + + )t2 on (t2.Id =p.Id) - ------ where p.id = '43187' - group by p.Id From 77eed12a50db2f6f2abda7116a2da4f21197605b Mon Sep 17 00:00:00 2001 From: Ohsudev <76500320+Ohsudev@users.noreply.github.com> Date: Mon, 27 Oct 2025 23:44:40 -0700 Subject: [PATCH 3/9] Modified Parentage program so that the dam and sire information overrides information from birth records. --- onprc_ehr/resources/queries/study/parentageSummary.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onprc_ehr/resources/queries/study/parentageSummary.sql b/onprc_ehr/resources/queries/study/parentageSummary.sql index 0a2712ef6..592b51568 100644 --- a/onprc_ehr/resources/queries/study/parentageSummary.sql +++ b/onprc_ehr/resources/queries/study/parentageSummary.sql @@ -50,6 +50,6 @@ from study.parentage p )t2 on (t2.Id =p.Id) - +WHERE p.qcstate.publicdata = true and p.enddateCoalesced <= now() From c3d6c20142ce0e124ec9d182ff25a560ddefd24b Mon Sep 17 00:00:00 2001 From: Ohsudev <76500320+Ohsudev@users.noreply.github.com> Date: Tue, 28 Oct 2025 12:38:45 -0700 Subject: [PATCH 4/9] Modified Parentage program so that the dam and sire information overrides information from birth records. --- .../queries/study/parentageSummary.sql | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/onprc_ehr/resources/queries/study/parentageSummary.sql b/onprc_ehr/resources/queries/study/parentageSummary.sql index 592b51568..3d4bba6bd 100644 --- a/onprc_ehr/resources/queries/study/parentageSummary.sql +++ b/onprc_ehr/resources/queries/study/parentageSummary.sql @@ -1,23 +1,35 @@ SELECT - p.Id, - p.date, - Case when p.parent is not null then p.parent + d.Id, + d.date, + Case when k.parent is not null then k.parent when t.dam is not null then t.dam when t2.sire is not null then t2.sire end as parent, - case when p.parent is not null then p.relationship + case when k.parent is not null then k.relationship when t.dam is not null then 'dam' when t2.sire is not null then 'sire' end as relationship, - case when p.parent is not null then p.method + case when k.parent is not null then k.method when t.dam is not null then 'observed' when t2.sire is not null then 'observed' end as method +from study.demographics d + LEFT JOIN + + (select + p.Id, + p.date, + p.parent, + p.relationship, + p.method + + from study.parentage p -from study.parentage p + WHERE p.qcstate.publicdata = true and p.enddateCoalesced <= now() + )k on (d.Id = k.Id) LEFT JOIN @@ -33,7 +45,7 @@ from study.parentage p where b.dam is not null and b.qcstate.publicdata = true - )t on (t.Id = p.Id) + )t on (t.Id = d.Id) LEFT JOIN @@ -47,9 +59,9 @@ from study.parentage p FROM study.birth a where a.sire is not null and a.qcstate.publicdata = true + )t2 on (t2.Id =d.Id) - )t2 on (t2.Id =p.Id) +WHERE d.calculated_status = 'Alive' -WHERE p.qcstate.publicdata = true and p.enddateCoalesced <= now() From a103f16c54a2c7bc931ccae7ee9533ca5e2b88b8 Mon Sep 17 00:00:00 2001 From: Ohsudev <76500320+Ohsudev@users.noreply.github.com> Date: Tue, 28 Oct 2025 12:39:52 -0700 Subject: [PATCH 5/9] Modified Parentage program so that the dam and sire information overrides information from birth records. --- onprc_ehr/resources/queries/study/parentageSummary.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onprc_ehr/resources/queries/study/parentageSummary.sql b/onprc_ehr/resources/queries/study/parentageSummary.sql index 3d4bba6bd..9d279bd79 100644 --- a/onprc_ehr/resources/queries/study/parentageSummary.sql +++ b/onprc_ehr/resources/queries/study/parentageSummary.sql @@ -61,7 +61,7 @@ from study.demographics d )t2 on (t2.Id =d.Id) -WHERE d.calculated_status = 'Alive' + From b181b61690afb4cef902f82b5d80d2973936aecb Mon Sep 17 00:00:00 2001 From: Ohsudev <76500320+Ohsudev@users.noreply.github.com> Date: Tue, 28 Oct 2025 12:42:09 -0700 Subject: [PATCH 6/9] Modified Parentage program so that the dam and sire information overrides information from birth records. --- .../queries/study/parentageSummary.sql | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/onprc_ehr/resources/queries/study/parentageSummary.sql b/onprc_ehr/resources/queries/study/parentageSummary.sql index 9d279bd79..dbc66cc3c 100644 --- a/onprc_ehr/resources/queries/study/parentageSummary.sql +++ b/onprc_ehr/resources/queries/study/parentageSummary.sql @@ -15,9 +15,7 @@ SELECT end as method from study.demographics d - - LEFT JOIN - + LEFT JOIN (select p.Id, p.date, @@ -26,13 +24,9 @@ from study.demographics d p.method from study.parentage p - WHERE p.qcstate.publicdata = true and p.enddateCoalesced <= now() - - )k on (d.Id = k.Id) - - LEFT JOIN - + ) k on (d.Id = k.Id) +LEFT JOIN ( select b.Id, b.date, @@ -40,15 +34,10 @@ from study.demographics d 'Dam' as relationship, 'Observed' as method - from study.birth b where b.dam is not null and b.qcstate.publicdata = true - - - )t on (t.Id = d.Id) - - LEFT JOIN - + ) t on (t.Id = d.Id) + LEFT JOIN ( SELECT a.Id, a.date, @@ -58,8 +47,7 @@ from study.demographics d FROM study.birth a where a.sire is not null and a.qcstate.publicdata = true - - )t2 on (t2.Id =d.Id) + ) t2 on (t2.Id =d.Id) From 2fa22a1bafcd8901be1f6807b0889a977fb45d43 Mon Sep 17 00:00:00 2001 From: Ohsudev <76500320+Ohsudev@users.noreply.github.com> Date: Wed, 29 Oct 2025 00:30:57 -0700 Subject: [PATCH 7/9] Modified Parentage program so that the dam and sire information overrides information from birth records. --- .../queries/study/parentageSummary.sql | 92 +++++++++---------- 1 file changed, 43 insertions(+), 49 deletions(-) diff --git a/onprc_ehr/resources/queries/study/parentageSummary.sql b/onprc_ehr/resources/queries/study/parentageSummary.sql index dbc66cc3c..2ef069c5e 100644 --- a/onprc_ehr/resources/queries/study/parentageSummary.sql +++ b/onprc_ehr/resources/queries/study/parentageSummary.sql @@ -1,55 +1,49 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ SELECT - d.Id, - d.date, - Case when k.parent is not null then k.parent - when t.dam is not null then t.dam - when t2.sire is not null then t2.sire - end as parent, - case when k.parent is not null then k.relationship - when t.dam is not null then 'dam' - when t2.sire is not null then 'sire' - end as relationship, - case when k.parent is not null then k.method - when t.dam is not null then 'observed' - when t2.sire is not null then 'observed' - end as method - -from study.demographics d - LEFT JOIN - (select - p.Id, - p.date, - p.parent, - p.relationship, - p.method - - from study.parentage p - WHERE p.qcstate.publicdata = true and p.enddateCoalesced <= now() - ) k on (d.Id = k.Id) -LEFT JOIN - ( select - b.Id, - b.date, - b.dam, - 'Dam' as relationship, - 'Observed' as method - - from study.birth b - where b.dam is not null and b.qcstate.publicdata = true - ) t on (t.Id = d.Id) - LEFT JOIN - ( SELECT - a.Id, - a.date, - a.sire, - 'Sire' as relationship, - 'Observed' as method - - FROM study.birth a - where a.sire is not null and a.qcstate.publicdata = true - ) t2 on (t2.Id =d.Id) + p.Id, + p.date, + p.parent, + p.relationship, + p.method +FROM study.parentage p +WHERE p.qcstate.publicdata = true and p.enddateCoalesced <= now() +UNION +SELECT + b.Id, + b.date, + b.dam, + 'Dam' as relationship, + 'Observed' as method +FROM study.birth b +WHERE b.dam is not null and b.qcstate.publicdata = true +---And b.dam not in (select k.parent from study.parentage k where k.Id = b.Id and k.relationship = 'dam') +UNION +SELECT + a.Id, + a.date, + a.sire, + 'Sire' as relationship, + 'Observed' as method + +FROM study.birth a +WHERE a.sire is not null and a.qcstate.publicdata = true + --- And a.sire not in (select k.parent from study.parentage k where k.Id = a.Id and k.relationship = 'sire') \ No newline at end of file From 65340ad83e4307ddbbf5cdc9b5da7d567440dfff Mon Sep 17 00:00:00 2001 From: Ohsudev <76500320+Ohsudev@users.noreply.github.com> Date: Wed, 29 Oct 2025 08:06:52 -0700 Subject: [PATCH 8/9] Modified Parentage program so that the dam and sire information overrides information from birth records. --- onprc_ehr/resources/queries/study/parentageSummary.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/onprc_ehr/resources/queries/study/parentageSummary.sql b/onprc_ehr/resources/queries/study/parentageSummary.sql index 2ef069c5e..d9dfce4ae 100644 --- a/onprc_ehr/resources/queries/study/parentageSummary.sql +++ b/onprc_ehr/resources/queries/study/parentageSummary.sql @@ -21,7 +21,7 @@ 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 @@ -34,7 +34,7 @@ SELECT FROM study.birth b WHERE b.dam is not null and b.qcstate.publicdata = true ----And b.dam not in (select k.parent from study.parentage k where k.Id = b.Id and k.relationship = 'dam') +And b.dam not in (select k.parent from study.parentage k where k.Id = b.Id and k.relationship = 'dam' and k.enddate is null) UNION SELECT @@ -46,4 +46,4 @@ SELECT FROM study.birth a WHERE a.sire is not null and a.qcstate.publicdata = true - --- And a.sire not in (select k.parent from study.parentage k where k.Id = a.Id and k.relationship = 'sire') \ No newline at end of file + And a.sire not in (select k.parent from study.parentage k where k.Id = a.Id and k.relationship = 'sire'and k.enddate is null) \ No newline at end of file From db57c788cb382de3644ced38fb53c5bf00ba3afa Mon Sep 17 00:00:00 2001 From: Ohsudev <76500320+Ohsudev@users.noreply.github.com> Date: Wed, 29 Oct 2025 10:32:53 -0700 Subject: [PATCH 9/9] Modified Parentage program so that the dam and sire information overrides information from birth records. --- onprc_ehr/resources/queries/study/parentageSummary.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/onprc_ehr/resources/queries/study/parentageSummary.sql b/onprc_ehr/resources/queries/study/parentageSummary.sql index d9dfce4ae..d410bee51 100644 --- a/onprc_ehr/resources/queries/study/parentageSummary.sql +++ b/onprc_ehr/resources/queries/study/parentageSummary.sql @@ -34,7 +34,7 @@ SELECT FROM study.birth b WHERE b.dam is not null and b.qcstate.publicdata = true -And b.dam not in (select k.parent from study.parentage k where k.Id = b.Id and k.relationship = 'dam' and k.enddate is null) +And 'dam' not in (select k.relationship from study.parentage k where k.Id = b.Id and k.enddate is null) UNION SELECT @@ -46,4 +46,4 @@ SELECT FROM study.birth a WHERE a.sire is not null and a.qcstate.publicdata = true - And a.sire not in (select k.parent from study.parentage k where k.Id = a.Id and k.relationship = 'sire'and k.enddate is null) \ No newline at end of file + And 'sire' not in (select k.relationship from study.parentage k where k.Id = a.Id and k.enddate is null) \ No newline at end of file