diff --git a/ehr/resources/queries/study/demographicsParents.query.xml b/ehr/resources/queries/study/demographicsParents.query.xml new file mode 100644 index 000000000..a151cf172 --- /dev/null +++ b/ehr/resources/queries/study/demographicsParents.query.xml @@ -0,0 +1,31 @@ + + + + + Parents + + + true + + + + study + animal + id + + + + + study + animal + id + + + + Number of Parents Known + + +
+
+
+
diff --git a/ehr/resources/queries/study/demographicsParents.sql b/ehr/resources/queries/study/demographicsParents.sql new file mode 100644 index 000000000..a730c739e --- /dev/null +++ b/ehr/resources/queries/study/demographicsParents.sql @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2015 LabKey Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +SELECT + d.Id, + d.dam, + 'Observed' as damType, + d.sire, + 'Observed' as sireType, + CASE + WHEN d.dam IS NOT NULL AND d.sire IS NOT NULL THEN 2 + WHEN d.dam IS NOT NULL OR d.sire IS NOT NULL THEN 1 + ELSE 0 + END as numParents +FROM study.demographics d + +UNION ALL + +SELECT + s.Id, + s.dam, + 'Observed' as damType, + s.sire, + 'Observed' as sireType, + CASE + WHEN s.dam IS NOT NULL AND s.sire IS NOT NULL THEN 2 + WHEN s.dam IS NOT NULL OR s.sire IS NOT NULL THEN 1 + ELSE 0 + END as numParents +FROM ehr.supplemental_pedigree s + diff --git a/ehr/src/org/labkey/ehr/table/DefaultEHRCustomizer.java b/ehr/src/org/labkey/ehr/table/DefaultEHRCustomizer.java index 22f5134b1..4cbf2a377 100644 --- a/ehr/src/org/labkey/ehr/table/DefaultEHRCustomizer.java +++ b/ehr/src/org/labkey/ehr/table/DefaultEHRCustomizer.java @@ -1124,6 +1124,13 @@ private void customizeAnimalTable(AbstractTableInfo ds) return; } + if (ds.getColumn("parents") == null) + { + var col = getWrappedCol(us, ds, "Parents", "demographicsParents", "Id", "Id"); + col.setLabel("Parents"); + ds.addColumn(col); + } + if (ds.getColumn("activeAnimalGroups") == null && -1 != StudyService.get().getDatasetIdByName( ds.getUserSchema().getContainer(), "animal_group_members")) { var col21 = getWrappedIdCol(us, ds, "activeAnimalGroups", "demographicsActiveAnimalGroups");