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
2 changes: 2 additions & 0 deletions nbri_ehr/resources/data/lookupsManifest.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ routes
sib_score
source
snomed
species
species_codes
skin_problem
status_codes
stool_score
Expand Down
6 changes: 4 additions & 2 deletions nbri_ehr/resources/data/weight_ranges.tsv
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Species Min Weight Max Weight
Cynomolgus 0.0 20.0
Rhesus 0.0 35.0
CMO 0.04 2.2
MCY 0.2 16.0
MMU 0.2 30.0
MNE 0.2 30.0
19 changes: 19 additions & 0 deletions nbri_ehr/resources/queries/ehr_lookups/weight_ranges.query.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<query xmlns="http://labkey.org/data/xml/query">
<metadata>
<tables xmlns="http://labkey.org/data/xml">
<table tableName="weight_ranges" tableDbType="TABLE">
<columns>
<column columnName="species">
<columnTitle>Species</columnTitle>
<fk>
<fkDbSchema>ehr_lookups</fkDbSchema>
<fkTable>species_codes</fkTable>
<fkColumnName>code</fkColumnName>
<fkDisplayColumnName>common_name</fkDisplayColumnName>
</fk>
</column>
</columns>
</table>
</tables>
</metadata>
</query>
12 changes: 12 additions & 0 deletions nbri_ehr/resources/queries/study/assignment.query.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@
<column columnName="taskid">
<isHidden>true</isHidden>
</column>
<!-- Re-declared from ehr/queries/study/assignment.query.xml; this file

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

what is re-declared, the "CoAssignments" column?
"this file" as in assignment.query.xml?

there are more such comments in .query.xml files below - wondering if they are necessary.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah I actually trimmed down those comments a lot. They were a lot longer. It's just redeclaring since this overrides the EHR version of this .query.xml. I'll shorten them further.

replaces ehr's rather than merging with it. See weight.query.xml. -->
<column columnName="CoAssignments" wrappedColumnName="lsid">
<columnTitle>CoAssignments</columnTitle>
<isHidden>false</isHidden>
<isUnselectable>true</isUnselectable>
<fk>
<fkDbSchema>study</fkDbSchema>
<fkTable>assignmentTotalCoAssigned</fkTable>
<fkColumnName>lsid</fkColumnName>
</fk>
</column>
</columns>
</table>
</tables>
Expand Down
14 changes: 13 additions & 1 deletion nbri_ehr/resources/queries/study/chemistryResults.query.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<query xmlns="http://labkey.org/data/xml/query">
<metadata>
<tables xmlns="http://labkey.org/data/xml">
<table tableName="serology" tableDbType="TABLE" useColumnOrder="true">
<table tableName="chemistryResults" tableDbType="TABLE" useColumnOrder="true">
<tableUrl />
<insertUrl />
<importUrl />
Expand All @@ -15,6 +15,18 @@
<column columnName="type">
<columnTitle>Type</columnTitle>
</column>
<!-- Re-declared from ehr/queries/study/chemistryResults.query.xml; this file
replaces ehr's rather than merging with it. See weight.query.xml. -->
<column columnName="refRange" wrappedColumnName="lsid">
<columnTitle>Ref Range</columnTitle>
<isUnselectable>true</isUnselectable>
<isHidden>false</isHidden>
<fk>
<fkDbSchema>study</fkDbSchema>
<fkTable>chemistryRefRange</fkTable>
<fkColumnName>lsid</fkColumnName>
</fk>
</column>
</columns>
</table>
</tables>
Expand Down
13 changes: 13 additions & 0 deletions nbri_ehr/resources/queries/study/housing.query.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@
<column columnName="remark"/>
<column columnName="performedBy">
</column>
<!-- Re-declared because this file replaces ehr's metadata rather than merging
with it. Keyed on lsid, not ehr's objectid: housingTotalRoommates selects
only lsid, so objectid leaves the join silently unresolved. -->
<column columnName="TotalRoommates" wrappedColumnName="lsid">
<columnTitle>Total Cagemates</columnTitle>
<isHidden>false</isHidden>
<isUnselectable>true</isUnselectable>
<fk>
<fkDbSchema>study</fkDbSchema>
<fkTable>housingTotalRoommates</fkTable>
<fkColumnName>lsid</fkColumnName>
</fk>
</column>
</columns>
</table>
</tables>
Expand Down
22 changes: 22 additions & 0 deletions nbri_ehr/resources/queries/study/weight.query.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,28 @@
</fk>
</column>
<column columnName="performedBy" />
<!-- Re-declared because this file replaces ehr's metadata rather than merging
with it; without these the ehr "Percent Change" view cannot resolve. -->
<column columnName="percentChange" wrappedColumnName="lsid">
<columnTitle>Percent Change</columnTitle>
<isHidden>false</isHidden>
<isUnselectable>true</isUnselectable>
<fk>
<fkDbSchema>study</fkDbSchema>
<fkTable>weightPctChange</fkTable>
<fkColumnName>lsid</fkColumnName>
</fk>
</column>
<column columnName="relChange" wrappedColumnName="lsid">
<columnTitle>Relative Change</columnTitle>
<isHidden>false</isHidden>
<isUnselectable>true</isUnselectable>
<fk>
<fkDbSchema>study</fkDbSchema>
<fkTable>weightRelChange</fkTable>
<fkColumnName>lsid</fkColumnName>
</fk>
</column>
</columns>
</table>
</tables>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
objectid Id QCStateLabel date birth death calculated_status gender sire dam species origin performedby
1 44444 Completed -1381d -1381d Alive 1 44442 44443 10 00001 1004
2 44446 Completed -1406d -1406d Alive 1 44442 44443 10 00003 1004
3 44445 Completed -1414d -1414d -726d Dead 2 44442 44443 10 00004 1004
4 TEST6390238 Completed -3923d -3923d Shipped 2 3565069 5250080 9 00002 1004
5 TEST5904521 Completed -5431d -5431d Shipped 1 8377984 9 00004 1004
6 TEST3804589 Completed -5806d -5806d Shipped 1 493957 9749422 9 00005 1004
7 TEST2312318 Completed -8069d -8069d Shipped 1 5748235 8739374 9 00002 1004
8 TEST1993532 Completed -11808d -11808d -2259d Dead 2 5409336 3784452 9 00003 1004
9 TEST4551032 Completed -6362d -6362d Alive 1 5030167 8416939 9 00001 1004
11 44442 Completed -6100d -6100d Alive 1 8377984 10 00004 1004
12 44443 Completed -6100d -6100d Alive 1 8377984 10 00004 1004
13 44447 Completed -2600d -2600d Alive 1 8377984 10 00004 1004
14 8377984 Completed -2600d -2600d Alive 1 8377984 10 00004 1004
1 44444 Completed -1381d -1381d Alive M 44442 44443 MNE 00001 1004
2 44446 Completed -1406d -1406d Alive M 44442 44443 MNE 00003 1004
3 44445 Completed -1414d -1414d -726d Dead F 44442 44443 MNE 00004 1004
4 TEST6390238 Completed -3923d -3923d Shipped F 3565069 5250080 MMU 00002 1004
5 TEST5904521 Completed -5431d -5431d Shipped M 8377984 MMU 00004 1004
6 TEST3804589 Completed -5806d -5806d Shipped M 493957 9749422 CMO 00005 1004
7 TEST2312318 Completed -8069d -8069d Shipped M 5748235 8739374 MMU 00002 1004
8 TEST1993532 Completed -11808d -11808d -2259d Dead F 5409336 3784452 MMU 00003 1004
9 TEST4551032 Completed -6362d -6362d Alive M 5030167 8416939 MMU 00001 1004
11 44442 Completed -6100d -6100d Alive M 8377984 MNE 00004 1004
12 44443 Completed -6100d -6100d Alive F 8377984 MNE 00004 1004
13 44447 Completed -2600d -2600d Alive M 8377984 MNE 00004 1004
14 8377984 Completed -2600d -2600d Alive F 8377984 MNE 00004 1004
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
objectid Id date weight remark QCStateLabel units performedby
1 TEST3804589 -5735d 0.037 vel praesent tincidunt Completed 1004
2 TEST3804589 -5730d 0.035 erat et convallis Completed 1004
1 TEST3804589 -5735d 0.040 vel praesent tincidunt Completed 1004
2 TEST3804589 -5730d 0.040 erat et convallis Completed 1004
3 TEST3804589 -5727d 0.041 egestas pharetra Completed 1004
4 TEST3804589 -5722d 0.045 sed dui suscipit Completed 1004
5 TEST3804589 -5714d 0.058 a aliquet et tempus Completed 1004
Expand Down
37 changes: 19 additions & 18 deletions nbri_ehr/test/src/org.labkey.test/tests.nbri_ehr/NBRI_EHRTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -407,25 +407,27 @@ protected void createTestSubjects() throws Exception

//insert into demographics
log("Creating test subjects");
// demographics.species holds an ehr_lookups.species_codes code, and ehr_lookups.weight_ranges is keyed
// on that same code, so weight validation only fires for animals given a real code here.
fields = new String[]{"Id", "Species", "Birth", "Gender", "date", "calculated_status", "objectid", "performedby"};
data = new Object[][]{
{SUBJECTS[0], "Rhesus", (new Date()).toString(), getMale(), new Date(), "Alive", UUID.randomUUID().toString(), 1004},
{SUBJECTS[1], "Cynomolgus", (new Date()).toString(), getMale(), new Date(), "Alive", UUID.randomUUID().toString(), 1004},
{SUBJECTS[2], "Marmoset", (new Date()).toString(), getFemale(), new Date(), "Alive", UUID.randomUUID().toString(), 1004},
{SUBJECTS[3], "Cynomolgus", (new Date()).toString(), getMale(), new Date(), "Alive", UUID.randomUUID().toString(), 1004},
{SUBJECTS[4], "Cynomolgus", (new Date()).toString(), getMale(), new Date(), "Alive", UUID.randomUUID().toString(), 1004}
{SUBJECTS[0], "MMU", (new Date()).toString(), getMale(), new Date(), "Alive", UUID.randomUUID().toString(), 1004},
{SUBJECTS[1], "MNE", (new Date()).toString(), getMale(), new Date(), "Alive", UUID.randomUUID().toString(), 1004},
{SUBJECTS[2], "CAE", (new Date()).toString(), getFemale(), new Date(), "Alive", UUID.randomUUID().toString(), 1004},
{SUBJECTS[3], "MNE", (new Date()).toString(), getMale(), new Date(), "Alive", UUID.randomUUID().toString(), 1004},
{SUBJECTS[4], "MNE", (new Date()).toString(), getMale(), new Date(), "Alive", UUID.randomUUID().toString(), 1004}
};
insertCommand = getApiHelper().prepareInsertCommand("study", "demographics", "lsid", fields, data);
getApiHelper().deleteAllRecords("study", "demographics", new Filter("Id", StringUtils.join(SUBJECTS, ";"), Filter.Operator.IN));
getApiHelper().doSaveRows(DATA_ADMIN.getEmail(), insertCommand, getExtraContext());

//for simplicity, also create the animals from MORE_ANIMAL_IDS right now
data = new Object[][]{
{MORE_ANIMAL_IDS[0], "Rhesus", (new Date()).toString(), getMale(), new Date(), "Alive", UUID.randomUUID().toString(), 1004},
{MORE_ANIMAL_IDS[1], "Cynomolgus", (new Date()).toString(), getMale(), new Date(), "Alive", UUID.randomUUID().toString(), 1004},
{MORE_ANIMAL_IDS[2], "Marmoset", (new Date()).toString(), getFemale(), new Date(), "Alive", UUID.randomUUID().toString(), 1004},
{MORE_ANIMAL_IDS[3], "Cynomolgus", (new Date()).toString(), getMale(), new Date(), "Alive", UUID.randomUUID().toString(), 1004},
{MORE_ANIMAL_IDS[4], "Cynomolgus", (new Date()).toString(), getMale(), new Date(), "Alive", UUID.randomUUID().toString(), 1004}
{MORE_ANIMAL_IDS[0], "MMU", (new Date()).toString(), getMale(), new Date(), "Alive", UUID.randomUUID().toString(), 1004},
{MORE_ANIMAL_IDS[1], "MNE", (new Date()).toString(), getMale(), new Date(), "Alive", UUID.randomUUID().toString(), 1004},
{MORE_ANIMAL_IDS[2], "CAE", (new Date()).toString(), getFemale(), new Date(), "Alive", UUID.randomUUID().toString(), 1004},
{MORE_ANIMAL_IDS[3], "MNE", (new Date()).toString(), getMale(), new Date(), "Alive", UUID.randomUUID().toString(), 1004},
{MORE_ANIMAL_IDS[4], "MNE", (new Date()).toString(), getMale(), new Date(), "Alive", UUID.randomUUID().toString(), 1004}
};
insertCommand = getApiHelper().prepareInsertCommand("study", "demographics", "lsid", fields, data);
getApiHelper().deleteAllRecords("study", "demographics", new Filter("Id", StringUtils.join(MORE_ANIMAL_IDS, ";"), Filter.Operator.IN));
Expand Down Expand Up @@ -478,7 +480,7 @@ protected void createTestSubjects() throws Exception
log("Creating task grouping test subject");
fields = new String[]{"Id", "Species", "Birth", "Gender", "date", "calculated_status", "objectid", "performedby"};
data = new Object[][]{
{taskGroupAnimalId, "Rhesus", (new Date()).toString(), getMale(), new Date(), "Alive", UUID.randomUUID().toString(), 1004}
{taskGroupAnimalId, "MMU", (new Date()).toString(), getMale(), new Date(), "Alive", UUID.randomUUID().toString(), 1004}
};
insertCommand = getApiHelper().prepareInsertCommand("study", "demographics", "lsid", fields, data);
getApiHelper().deleteAllRecords("study", "demographics", new Filter("Id", taskGroupAnimalId));
Expand Down Expand Up @@ -535,7 +537,7 @@ public void testWeightValidation()
};
Map<String, List<String>> expected = new HashMap<>();
expected.put("weight", Arrays.asList(
"WARN: Weight above the allowable value of 20.0 kg for Cynomolgus",
"WARN: Weight above the allowable value of 30.0 kg for MNE",
"INFO: Weight gain of >10%. Last weight 12 kg")
);
getApiHelper().testValidationMessage(DATA_ADMIN.getEmail(), "study", "weight", getWeightFields(), data, expected);
Expand Down Expand Up @@ -1217,9 +1219,9 @@ public void createSubjectsForDeathForm() throws IOException, CommandException
getApiHelper().doSaveRows(DATA_ADMIN.getEmail(), getApiHelper().prepareInsertCommand("study", "birth", "lsid",
new String[]{"Id", "Date", "gender", "QCStateLabel", "performedby"},
new Object[][]{
{aliveAnimalId, LocalDateTime.now().minusDays(30), "f", "Completed", 1004},
{deadAnimalId, LocalDateTime.now().minusDays(30), "m", "Completed", 1004},
{departedAnimalId, LocalDateTime.now().minusDays(30), "m", "Completed", 1004},
{aliveAnimalId, LocalDateTime.now().minusDays(30), getFemale(), "Completed", 1004},
{deadAnimalId, LocalDateTime.now().minusDays(30), getMale(), "Completed", 1004},
{departedAnimalId, LocalDateTime.now().minusDays(30), getMale(), "Completed", 1004},
}
), getExtraContext());

Expand Down Expand Up @@ -1703,9 +1705,8 @@ private int countLines(File file) throws Exception
}
}

// Creates the parents of a conception. They need a species from the ehr_lookups.species list because the
// Start with Conception window copies the dam's species onto the newborn, and the reference study's
// demographics data carries placeholder species values that no lookup entry matches.
// Creates the parents of a conception. They need an ehr_lookups.species_codes code because the Start with
// Conception window copies the dam's species onto the newborn, and the test asserts the resulting record.
private void createBreedingPair(String damId, String sireId, String species) throws Exception
{
String[] fields = new String[]{"Id", "Species", "Birth", "Gender", "date", "calculated_status", "objectid", "performedby"};
Expand Down