diff --git a/ehr/resources/queries/study/animalIdsAsDamAndSire.sql b/ehr/resources/queries/study/animalIdsAsDamAndSire.sql new file mode 100644 index 000000000..4943ca5ab --- /dev/null +++ b/ehr/resources/queries/study/animalIdsAsDamAndSire.sql @@ -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); diff --git a/ehr/resources/queries/study/parentsDifferentSpecies.sql b/ehr/resources/queries/study/parentsDifferentSpecies.sql new file mode 100644 index 000000000..7c2617fea --- /dev/null +++ b/ehr/resources/queries/study/parentsDifferentSpecies.sql @@ -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 \ No newline at end of file diff --git a/ehr/resources/queries/study/parentsIncorrectGender.sql b/ehr/resources/queries/study/parentsIncorrectGender.sql new file mode 100644 index 000000000..c014d7b04 --- /dev/null +++ b/ehr/resources/queries/study/parentsIncorrectGender.sql @@ -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 \ No newline at end of file diff --git a/ehr/resources/queries/study/parentsYoungerThanOffspring.sql b/ehr/resources/queries/study/parentsYoungerThanOffspring.sql new file mode 100644 index 000000000..5c35edeae --- /dev/null +++ b/ehr/resources/queries/study/parentsYoungerThanOffspring.sql @@ -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) \ No newline at end of file diff --git a/ehr/resources/views/ehrDataValidationReport.html b/ehr/resources/views/ehrDataValidationReport.html new file mode 100644 index 000000000..add65f512 --- /dev/null +++ b/ehr/resources/views/ehrDataValidationReport.html @@ -0,0 +1,37 @@ +
+ + + + + \ No newline at end of file