diff --git a/nbri_ehr/resources/data/lookupsManifest.tsv b/nbri_ehr/resources/data/lookupsManifest.tsv index 472d51d..b7333f7 100644 --- a/nbri_ehr/resources/data/lookupsManifest.tsv +++ b/nbri_ehr/resources/data/lookupsManifest.tsv @@ -111,6 +111,8 @@ routes sib_score source snomed +species +species_codes skin_problem status_codes stool_score diff --git a/nbri_ehr/resources/data/weight_ranges.tsv b/nbri_ehr/resources/data/weight_ranges.tsv index bb2c94f..dca47bd 100644 --- a/nbri_ehr/resources/data/weight_ranges.tsv +++ b/nbri_ehr/resources/data/weight_ranges.tsv @@ -1,3 +1,5 @@ Species Min Weight Max Weight -Cynomolgus 0.0 20.0 -Rhesus 0.0 35.0 \ No newline at end of file +CMO 0.04 2.2 +MCY 0.2 16.0 +MMU 0.2 30.0 +MNE 0.2 30.0 diff --git a/nbri_ehr/resources/queries/ehr_lookups/weight_ranges.query.xml b/nbri_ehr/resources/queries/ehr_lookups/weight_ranges.query.xml new file mode 100644 index 0000000..b5f2f4d --- /dev/null +++ b/nbri_ehr/resources/queries/ehr_lookups/weight_ranges.query.xml @@ -0,0 +1,19 @@ + + + + + + + Species + + ehr_lookups + species_codes + code + common_name + + + +
+
+
+
diff --git a/nbri_ehr/resources/queries/study/assignment.query.xml b/nbri_ehr/resources/queries/study/assignment.query.xml index 1cf7a36..df55a2e 100644 --- a/nbri_ehr/resources/queries/study/assignment.query.xml +++ b/nbri_ehr/resources/queries/study/assignment.query.xml @@ -21,6 +21,18 @@ true + + + CoAssignments + false + true + + study + assignmentTotalCoAssigned + lsid + + diff --git a/nbri_ehr/resources/queries/study/chemistryResults.query.xml b/nbri_ehr/resources/queries/study/chemistryResults.query.xml index caa0e9e..154a0ae 100644 --- a/nbri_ehr/resources/queries/study/chemistryResults.query.xml +++ b/nbri_ehr/resources/queries/study/chemistryResults.query.xml @@ -1,7 +1,7 @@ - +
@@ -15,6 +15,18 @@ Type + + + Ref Range + true + false + + study + chemistryRefRange + lsid + +
diff --git a/nbri_ehr/resources/queries/study/housing.query.xml b/nbri_ehr/resources/queries/study/housing.query.xml index eeb5e0d..cfaafa6 100644 --- a/nbri_ehr/resources/queries/study/housing.query.xml +++ b/nbri_ehr/resources/queries/study/housing.query.xml @@ -45,6 +45,19 @@ + + + Total Cagemates + false + true + + study + housingTotalRoommates + lsid + + diff --git a/nbri_ehr/resources/queries/study/weight.query.xml b/nbri_ehr/resources/queries/study/weight.query.xml index d9ee743..ca0dfdc 100644 --- a/nbri_ehr/resources/queries/study/weight.query.xml +++ b/nbri_ehr/resources/queries/study/weight.query.xml @@ -29,6 +29,28 @@ + + + Percent Change + false + true + + study + weightPctChange + lsid + + + + Relative Change + false + true + + study + weightRelChange + lsid + + diff --git a/nbri_ehr/test/sampledata/nbri_ehr/study/study/datasets/datasetDemographics.tsv b/nbri_ehr/test/sampledata/nbri_ehr/study/study/datasets/datasetDemographics.tsv index 8dc76ff..93872c6 100644 --- a/nbri_ehr/test/sampledata/nbri_ehr/study/study/datasets/datasetDemographics.tsv +++ b/nbri_ehr/test/sampledata/nbri_ehr/study/study/datasets/datasetDemographics.tsv @@ -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 diff --git a/nbri_ehr/test/sampledata/nbri_ehr/study/study/datasets/datasetWeight.tsv b/nbri_ehr/test/sampledata/nbri_ehr/study/study/datasets/datasetWeight.tsv index 75fd789..c47b7f7 100644 --- a/nbri_ehr/test/sampledata/nbri_ehr/study/study/datasets/datasetWeight.tsv +++ b/nbri_ehr/test/sampledata/nbri_ehr/study/study/datasets/datasetWeight.tsv @@ -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 diff --git a/nbri_ehr/test/src/org.labkey.test/tests.nbri_ehr/NBRI_EHRTest.java b/nbri_ehr/test/src/org.labkey.test/tests.nbri_ehr/NBRI_EHRTest.java index a06c389..a513403 100644 --- a/nbri_ehr/test/src/org.labkey.test/tests.nbri_ehr/NBRI_EHRTest.java +++ b/nbri_ehr/test/src/org.labkey.test/tests.nbri_ehr/NBRI_EHRTest.java @@ -407,13 +407,15 @@ 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)); @@ -421,11 +423,11 @@ protected void createTestSubjects() throws Exception //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)); @@ -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)); @@ -535,7 +537,7 @@ public void testWeightValidation() }; Map> 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); @@ -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()); @@ -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"};