Skip to content

Commit d768382

Browse files
authored
Modified Offspring reporting to include surrogate mom. (#1612)
* Modified Offspring reporting to include surrogate mom. * Modified Offspring reporting to include surrogate mom.
1 parent d4ae1a0 commit d768382

6 files changed

Lines changed: 43 additions & 6 deletions

File tree

onprc_ehr/resources/queries/study/demographicsOffspringBSU.query.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@
4343
<column columnName="fosterMom">
4444
<columnTitle>Foster Dam</columnTitle>
4545
</column>
46+
<column columnName="surrogateMom">
47+
<columnTitle>Surrogate Dam</columnTitle>
48+
<fk>
49+
<fkDbSchema>study</fkDbSchema>
50+
<fkTable>animal</fkTable>
51+
<fkColumnName>id</fkColumnName>
52+
</fk>
53+
</column>
4654

4755
<column columnName="sire">
4856
<columnTitle>Sire</columnTitle>

onprc_ehr/resources/queries/study/demographicsOffspringBSU.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ d2.status,
1717
d2.geneticdam,
1818
d2.observeddam,
1919
d2.fosterMom,
20+
d2.surrogateMom,
2021
d2.sire,
2122
d2.sireType,
2223
d.qcstate
@@ -25,7 +26,7 @@ FROM study.Demographics d
2526

2627
INNER JOIN study.demographicsParentsBSU d2
2728

28-
ON ((d2.sire = d.id OR d2.geneticdam = d.id OR d2.fostermom = d.id OR d2.observeddam = d.id) AND d.id != d2.id)
29+
ON ((d2.sire = d.id OR d2.geneticdam = d.id OR d2.fosterMom = d.id OR d2.observeddam = d.id) AND d.id != d2.id)
2930

3031

3132

onprc_ehr/resources/queries/study/demographicsOffspringBSU/.qview.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<column name="geneticdam"/>
1616
<column name="observeddam"/>
1717
<column name="fosterMom"/>
18+
<column name="surrogateMom"/>
1819
<column name="sire"/>
1920
<column name="sireType"/>
2021

onprc_ehr/resources/queries/study/demographicsParents/.qview.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<column name="sire"/>
77
<column name="sireType"/>
88
<column name="fostermom"/>
9+
<column name="surrogateMom"/>
910
<column name="fosterType"/>
1011
<column name="numParents"/>
1112
</columns>

onprc_ehr/resources/queries/study/demographicsParentsBSU.query.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@
4848
<fkColumnName>id</fkColumnName>
4949
</fk>
5050
</column>
51+
<column columnName="surrogateMom">
52+
<columnTitle>Surrogate Dam</columnTitle>
53+
<fk>
54+
<fkDbSchema>study</fkDbSchema>
55+
<fkTable>animal</fkTable>
56+
<fkColumnName>id</fkColumnName>
57+
</fk>
58+
</column>
5159

5260
<column columnName="numParents">
5361
<columnTitle>Number of Parents Known</columnTitle>

onprc_ehr/resources/queries/study/demographicsParentsBSU.sql

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,23 @@ SELECT
3939
ELSE null
4040
END as sireType,
4141

42-
p3.parent as fosterMom,
43-
p3.method as fosterType,
4442

45-
(CASE WHEN p3.parent IS NOT NULL THEN 1 ELSE 0 END +
46-
CASE WHEN coalesce(p2.parent, b.dam) IS NOT NULL THEN 1 ELSE 0 END +
47-
CASE WHEN coalesce(p1.parent, b.sire) IS NOT NULL THEN 1 ELSE 0 END) as numParents
43+
coalesce(p3.parent, '') as fosterMom,
44+
CASE
45+
WHEN p3.parent IS NOT NULL THEN p3.method
46+
ELSE null
47+
END as fosterType,
48+
49+
coalesce(p4.parent, '') as surrogateMom,
50+
CASE
51+
WHEN p4.parent IS NOT NULL THEN p4.method
52+
ELSE null
53+
END as surrogateType,
54+
55+
(CASE WHEN p4.parent IS NOT NULL THEN 1 ELSE 0 END +
56+
CASE WHEN p3.parent IS NOT NULL THEN 1 ELSE 0 END +
57+
CASE WHEN coalesce(p2.parent, b.dam) IS NOT NULL THEN 1 ELSE 0 END +
58+
CASE WHEN coalesce(p1.parent, b.sire) IS NOT NULL THEN 1 ELSE 0 END) as numParents
4859

4960
FROM study.demographics d
5061

@@ -68,5 +79,12 @@ LEFT JOIN (
6879
WHERE p3.relationship = 'Foster Dam' AND p3.enddate IS NULL
6980
GROUP BY p3.Id
7081
) p3 ON (d.Id = p3.id)
82+
83+
LEFT JOIN (
84+
select p4.id, min(p4.method) as method, max(p4.parent) as parent
85+
FROM study.parentage p4
86+
WHERE p4.relationship = 'Surrogate Dam' AND p4.enddate IS NULL
87+
GROUP BY p4.Id
88+
) p4 ON (d.Id = p4.id)
7189
LEFT JOIN study.birth b ON (b.id = d.id)
7290

0 commit comments

Comments
 (0)