diff --git a/ehr/resources/queries/study/parentsBothDamAndSire.sql b/ehr/resources/queries/study/parentsBothDamAndSire.sql new file mode 100644 index 000000000..b7b34dc1e --- /dev/null +++ b/ehr/resources/queries/study/parentsBothDamAndSire.sql @@ -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 \ No newline at end of file diff --git a/ehr/resources/queries/study/parentsDifferentSpecies.sql b/ehr/resources/queries/study/parentsDifferentSpecies.sql new file mode 100644 index 000000000..a7062e34c --- /dev/null +++ b/ehr/resources/queries/study/parentsDifferentSpecies.sql @@ -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 diff --git a/ehr/resources/queries/study/parentsWrongGender.sql b/ehr/resources/queries/study/parentsWrongGender.sql new file mode 100644 index 000000000..7935cda24 --- /dev/null +++ b/ehr/resources/queries/study/parentsWrongGender.sql @@ -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 +) d2 +WHERE d2.parentSexMismatch = TRUE diff --git a/ehr/resources/queries/study/parentsYoungerThanOffspring.sql b/ehr/resources/queries/study/parentsYoungerThanOffspring.sql new file mode 100644 index 000000000..76bc3589c --- /dev/null +++ b/ehr/resources/queries/study/parentsYoungerThanOffspring.sql @@ -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) diff --git a/ehr/resources/views/begin.html b/ehr/resources/views/begin.html index 4739d1577..93c9a679c 100644 --- a/ehr/resources/views/begin.html +++ b/ehr/resources/views/begin.html @@ -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'}, @@ -120,4 +121,4 @@ } - \ No newline at end of file + diff --git a/ehr/resources/views/dataValidationReport.html b/ehr/resources/views/dataValidationReport.html new file mode 100644 index 000000000..32b4d0b39 --- /dev/null +++ b/ehr/resources/views/dataValidationReport.html @@ -0,0 +1,71 @@ +

+ Each of the below data grids identifies issues present in the animal colony data that would prevent the pedigree plots from working correctly.
+ 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.
+

+ +


+ + + + + + + + + +
+
+
+
+
+
+
+
+
+ + \ No newline at end of file diff --git a/ehr/resources/views/dataValidationReport.view.xml b/ehr/resources/views/dataValidationReport.view.xml new file mode 100644 index 000000000..0f0b3dc97 --- /dev/null +++ b/ehr/resources/views/dataValidationReport.view.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file