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
31 changes: 31 additions & 0 deletions ehr/resources/queries/study/demographicsParents.query.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<query xmlns="http://labkey.org/data/xml/query">
<metadata>
<tables xmlns="http://labkey.org/data/xml">
<table tableName="demographicsParents" tableDbType="NOT_IN_DB">
<tableTitle>Parents</tableTitle>
<columns>
<column columnName="Id">
<isHidden>true</isHidden>
</column>
<column columnName="dam">
<fk>
<fkDbSchema>study</fkDbSchema>
<fkTable>animal</fkTable>
<fkColumnName>id</fkColumnName>
</fk>
</column>
<column columnName="sire">
<fk>
<fkDbSchema>study</fkDbSchema>
<fkTable>animal</fkTable>
<fkColumnName>id</fkColumnName>
</fk>
</column>
<column columnName="numParents">
<columnTitle>Number of Parents Known</columnTitle>
</column>
</columns>
</table>
</tables>
</metadata>
</query>
43 changes: 43 additions & 0 deletions ehr/resources/queries/study/demographicsParents.sql
Original file line number Diff line number Diff line change
@@ -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

7 changes: 7 additions & 0 deletions ehr/src/org/labkey/ehr/table/DefaultEHRCustomizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down