Skip to content
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
14 changes: 14 additions & 0 deletions ehr/resources/queries/study/animalIdsAsDamAndSire.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

SELECT DISTINCT dam AS Id,
gender,
species
FROM demographics
WHERE dam IN (SELECT sire FROM demographics)

UNION

SELECT DISTINCT sire AS Id,
gender,
species
FROM demographics
WHERE sire IN (SELECT dam FROM demographics);
20 changes: 20 additions & 0 deletions ehr/resources/queries/study/parentsDifferentSpecies.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
SELECT *
FROM (
SELECT
d1.Id,
d1.gender,
d1.species,
d2.Id as damId,
d2.species as damSpecies,
d3.Id as sireId,
d3.species as sireSpecies,
CASE WHEN (d2.species IS NOT NULL AND d1.species != d2.species) AND
(d3.species IS NOT NULL AND d1.species != d3.species)
THEN TRUE
ELSE FALSE
END as parentSpeciesMismatch
FROM demographics d1
LEFT JOIN demographics d2 ON d1.dam = d2.Id
LEFT JOIN demographics d3 ON d1.sire = d3.Id
) d4
WHERE d4.parentSpeciesMismatch = TRUE
20 changes: 20 additions & 0 deletions ehr/resources/queries/study/parentsIncorrectGender.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
SELECT *
FROM (
SELECT
d1.Id,
d1.gender,
d1.species,
d2.Id as damId,
d2.gender as damGender,
d3.Id as sireId,
d3.gender as sireGender,
CASE WHEN (d2.gender IS NOT NULL AND upper(d2.gender.meaning) NOT IN ('FEMALE', 'UNKNOWN', 'UNDETERMINED')) OR
(d3.gender IS NOT NULL AND upper(d3.gender.meaning) NOT IN ('MALE', 'UNKNOWN', 'UNDETERMINED'))
THEN TRUE
ELSE FALSE
END as parentSpeciesMismatch
FROM demographics d1
LEFT JOIN demographics d2 ON d1.dam = d2.Id
LEFT JOIN demographics d3 ON d1.sire = d3.Id
) d4
WHERE d4.parentSpeciesMismatch = TRUE
16 changes: 16 additions & 0 deletions ehr/resources/queries/study/parentsYoungerThanOffspring.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
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)
37 changes: 37 additions & 0 deletions ehr/resources/views/ehrDataValidationReport.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<div id="incorrect-gender"></div>
<div id="incorrect-species"></div>
<div id="incorrect-ids"></div>
<div id="incorrect-age"></div>

<script type="text/javascript">
Ext4.onReady(function (){

new LABKEY.QueryWebPart({
renderTo: 'incorrect-gender',
title: 'Parents having incorect gender',
schemaName: 'study',
queryName: 'parentsIncorrectGender',
})

new LABKEY.QueryWebPart({
renderTo: 'incorrect-species',
title: 'Parents having different species than offspring',
schemaName: 'study',
queryName: 'parentsDifferentSpecies',
})

new LABKEY.QueryWebPart({
renderTo: 'incorrect-ids',
title: 'Parents that are listed as both dam and sire',
schemaName: 'study',
queryName: 'animalIdsAsDamAndSire',
})

new LABKEY.QueryWebPart({
renderTo: 'incorrect-age',
title: 'Dam/Sire younger than offspring',
schemaName: 'study',
queryName: 'parentsYoungerThanOffspring',
})
});
</script>