Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
15 changes: 15 additions & 0 deletions ehr/resources/queries/study/parentDifferentSpecies.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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

see comment below about basing on another query besides animal

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

see my comment replying to your comment

) 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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)