Skip to content

Commit aec486b

Browse files
committed
Override test
1 parent 598f94d commit aec486b

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

nirc_ehr/test/src/org.labkey.test/tests.nirc_ehr/NIRC_EHRTest.java

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,50 @@ protected Object[] getWeightData1()
472472
return weightData1;
473473
}
474474

475+
@Test
476+
public void testWeightValidation()
477+
{
478+
//initialize weight of subject 3
479+
String[] fields;
480+
Object[][] data;
481+
SimplePostCommand insertCommand;
482+
fields = new String[]{"Id", "date", "weight", "QCStateLabel", "performedby"};
483+
data = new Object[][]{
484+
{SUBJECTS[3], new Date(), 12, EHRQCState.COMPLETED.label, 1004},
485+
};
486+
insertCommand = getApiHelper().prepareInsertCommand("study", "Weight", "lsid", fields, data);
487+
getApiHelper().doSaveRows(DATA_ADMIN.getEmail(), insertCommand, getExtraContext());
488+
489+
//expect weight out of range
490+
data = new Object[][]{
491+
{SUBJECTS[3], new Date(), null, null, 120, EHRQCState.IN_PROGRESS.label, null, null, "recordID", 1004}
492+
};
493+
Map<String, List<String>> expected = new HashMap<>();
494+
expected.put("weight", Arrays.asList(
495+
"WARN: Weight above the allowable value of 20.0 kg for Cynomolgus",
496+
"INFO: Weight gain of >10%. Last weight 12 kg")
497+
);
498+
getApiHelper().testValidationMessage(DATA_ADMIN.getEmail(), "study", "weight", getWeightFields(), data, expected);
499+
500+
//expect INFO for +10% diff
501+
data = new Object[][]{
502+
{SUBJECTS[3], new Date(), null, null, 20, EHRQCState.IN_PROGRESS.label, null, null, "recordID", 1004}
503+
};
504+
expected = new HashMap<>();
505+
expected.put("weight", Collections.singletonList("INFO: Weight gain of >10%. Last weight 12 kg"));
506+
getApiHelper().testValidationMessage(DATA_ADMIN.getEmail(), "study", "weight", getWeightFields(), data, expected);
507+
508+
//expect INFO for -10% diff
509+
data = new Object[][]{
510+
{SUBJECTS[3], new Date(), null, null, 5, EHRQCState.IN_PROGRESS.label, null, null, "recordID", 1004}
511+
};
512+
expected = new HashMap<>();
513+
expected.put("weight", Collections.singletonList("INFO: Weight drop of >10%. Last weight 12 kg"));
514+
getApiHelper().testValidationMessage(DATA_ADMIN.getEmail(), "study", "weight", getWeightFields(), data, expected);
515+
516+
//TODO: test error threshold
517+
}
518+
475519
@Test
476520
public void testArrivalForm()
477521
{

0 commit comments

Comments
 (0)