Skip to content
Open
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
30 changes: 30 additions & 0 deletions ehr/resources/queries/study/parentsBothDamAndSire.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
SELECT t.Id as Parent, GROUP_CONCAT(t.DamChildren, ',') as DamChildren, GROUP_CONCAT(t.SireChildren, ',') as SireChildren FROM
(

SELECT d.Id, d.DamChildren, s.SireChildren FROM (

SELECT Id as DamChildren,
dam as Id
FROM demographics
WHERE dam IN (
SELECT Distinct dam as Id
FROM demographics
WHERE dam IN (SELECT Distinct sire FROM demographics))
) d

JOIN

(SELECT * FROM (

SELECT Id as SireChildren,
sire as Id
FROM demographics
WHERE sire IN (
SELECT Distinct dam as Id
FROM demographics
WHERE dam IN (SELECT Distinct sire FROM demographics))
) si ) s

ON s.Id = d.Id
) t
GROUP BY t.Id
15 changes: 15 additions & 0 deletions ehr/resources/queries/study/parentsDifferentSpecies.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
SELECT * FROM (
SELECT d1.Id,
d1.Dataset.Demographics.gender,
d1.Dataset.Demographics.species,
d1.Parents.dam,
d1.Parents.dam.Demographics.species as damSpecies,
d1.Parents.sire,
d1.Parents.sire.Demographics.species as sireSpecies,
CASE WHEN (d1.Parents.dam.Demographics.species IS NOT NULL AND d1.Parents.dam.Demographics.species != d1.Dataset.Demographics.species) OR (d1.Parents.sire.Demographics.species IS NOT NULL AND d1.Parents.sire.Demographics.species != d1.Dataset.Demographics.species)
THEN TRUE
ELSE FALSE
END as parentSpeciesMismatch
FROM study.Animal d1
) d2
WHERE d2.parentSpeciesMismatch = TRUE
15 changes: 15 additions & 0 deletions ehr/resources/queries/study/parentsWrongGender.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
SELECT * FROM (
SELECT d1.Id,
d1.Dataset.Demographics.gender,
d1.Dataset.Demographics.species,
d1.Parents.dam,
d1.Parents.dam.Demographics.gender as damSex,
d1.Parents.sire,
d1.Parents.sire.Demographics.gender as sireSex,
CASE WHEN (d1.Parents.dam.Demographics.gender.code IS NOT NULL AND d1.Parents.dam.Demographics.gender.code != 'f') OR (d1.Parents.sire.Demographics.gender.code IS NOT NULL AND d1.Parents.sire.Demographics.gender.code != 'm')
THEN TRUE
ELSE FALSE
END as parentSexMismatch
FROM study.Animal d1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is fine, but wouldnt it be a little better to just base this on study.demographicsParents rather than animal? you're filtering anything not present in animal, arent you?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, yes it would be better, but not all centers have study.demographicsParents working. I'm honestly just trying to keep things simple. we can always improve on it later if necessary.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it was my suggestion to use Animal. Only one center doesn't have demographicsParents, but this won't work for them anyway. We should probably look into bringing demographicsParents into core EHR and setting up the Parents column in DefaultEHRCustomizer. @jryurkanin we can sync on this.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like it might be useful to create a demographicsPedigree.sql in core EHR, and have this SQL select from study.demographics, and then merge in ehr.supplemental_pedigree. That would make columns consistent across EHR instances, and by default support supplemental_pedigree.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have something along those lines for the base demographicsParents in this PR. Most centers already have it overwritten, but we can use whatever version of demographicsParents is active for these queries.

#541

) d2
WHERE d2.parentSexMismatch = TRUE
15 changes: 15 additions & 0 deletions ehr/resources/queries/study/parentsYoungerThanOffspring.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
SELECT * FROM (
SELECT
dem.Id,
dem.gender,
dem.species,
dem.birth,
dem.dam,
damDem.birth as damBirth,
dem.sire,
sireDem.birth as sireBirth
FROM demographics dem
LEFT JOIN demographics damDem ON dem.dam = damDem.Id
LEFT JOIN demographics sireDem ON dem.sire = sireDem.Id
) t
WHERE (t.birth <= t.damBirth OR t.birth <= t.sireBirth)
3 changes: 2 additions & 1 deletion ehr/resources/views/begin.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
{header: 'Misc',
items: [
{name: 'About the EHR Project', url: '<%=contextPath%>/project' + ctx['EHRStudyContainer'] + '/About The EHR/begin.view?'},
{name: 'Data Validation', url: '<%=contextPath%>/ehr' + ctx['EHRStudyContainer'] + '/dataValidationReport.view?'},
{name: 'Compare Lists of Animals', url: '<%=contextPath%>/ehr' + ctx['EHRStudyContainer'] + '/utilities.view?'},
{name: 'Run SQL Directly', url: '<%=contextPath%>/ehr' + ctx['EHRStudyContainer'] + '/executeSql.view?'},
{name: 'Search Center SNOMED Codes', url: '<%=contextPath%>/query' + ctx['EHRStudyContainer'] + '/executeQuery.view?schemaName=ehr_lookups&query.queryName=snomed'},
Expand Down Expand Up @@ -120,4 +121,4 @@

}

</script>
</script>
71 changes: 71 additions & 0 deletions ehr/resources/views/dataValidationReport.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<p>
Each of the below data grids identifies issues present in the animal colony data that would prevent the pedigree plots from working correctly.<br>
To correct any data consistency issues, use this report as a reference for identifying the data issues, and then correct them on the demographics dataset, which can be access with the below button.<br>
</p>
<button onclick = "linkBrowseData()">
Correct Data
</button>
<p><br></p>
<table>
<tr>
<td>
<div name="webpart" id='parentsDifferentSpeciesReport' />
</td>
<td>
<div name="webpart" id='parentsBothDamAndSireReport' />
</td>
</tr>
<tr>
<td>
<div name="webpart" id='parentsWrongGenderReport' />
</td>
<td>
<div name="webpart" id='parentsYoungerThanOffspringReport' />
</td>
</tr>
</table>

<script>

function linkBrowseData() {
window.location = LABKEY.ActionURL.buildURL(
"ehr",
"updateQuery",
LABKEY.ActionURL.getContainer(),
{
schemaName: "study",
queryName: "demographics",
returnUrl: window.location
}
);
}

new LABKEY.QueryWebPart({
renderTo: 'parentsDifferentSpeciesReport',
title: 'Parents that are wrong species',
schemaName: 'study',
queryName: 'parentsDifferentSpecies'
});

new LABKEY.QueryWebPart({
renderTo: 'parentsBothDamAndSireReport',
title: 'Parents that are listed as both dam and sire',
schemaName: 'study',
queryName: 'parentsBothDamAndSire'
});

new LABKEY.QueryWebPart({
renderTo: 'parentsWrongGenderReport',
title: 'Parents that are listed as both dam and sire',
schemaName: 'study',
queryName: 'parentsWrongGender'
});

new LABKEY.QueryWebPart({
renderTo: 'parentsYoungerThanOffspringReport',
title: 'Parents that are listed as both dam and sire',
schemaName: 'study',
queryName: 'parentsYoungerThanOffspring'
});

</script>
5 changes: 5 additions & 0 deletions ehr/resources/views/dataValidationReport.view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<view xmlns="http://labkey.org/data/xml/view" frame="none" title="Data Validation Report">
<dependencies>
<dependency path="ehr.context" />
</dependencies>
</view>