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
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@labkey-martyp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ protected Collection<FieldKey> getFieldKeys()
keys.add(FieldKey.fromString("date"));
keys.add(FieldKey.fromString("cond"));
keys.add(FieldKey.fromString("reason"));

//cnprc
keys.add(FieldKey.fromString("location"));

return keys;
Expand Down
4 changes: 2 additions & 2 deletions ehr/resources/web/ehr/DataEntryUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ EHR.DataEntryUtils = new function(){
type: 'labkey-store',
schemaName: 'ehr_lookups',
queryName: 'drug_defaults',
columns: 'code,code/meaning,dosage,dosage_units,concentration,conc_units,amount,amount_units,amount_rounding,volume,vol_units,volume_rounding,route,frequency,duration,remark,offset',
columns: 'code,code/meaning,dosage,dosage_units,concentration,conc_units,amount,amount_units,amount_rounding,volume,vol_units,volume_rounding,route,frequency,frequency/meaning,duration,remark,offset',
sort: 'code',
storeId: storeId,
autoLoad: true,
Expand Down Expand Up @@ -874,7 +874,7 @@ EHR.DataEntryUtils = new function(){
}
}

if (!amount && Ext4.isEmpty(rounding)){
if (amount && !Ext4.isEmpty(rounding)){
amount = EHR.Utils.roundToNearest(amount, rounding);
}

Expand Down
16 changes: 3 additions & 13 deletions ehr/resources/web/ehr/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -497,19 +497,9 @@ EHR.Utils = new function(){
return val;
}

var remainder = val % round;
var remainderPct = remainder / round;
var base = Math.floor(val / round);
if (remainder === 0){
return val;
}
//note: JS seems to handle division poorly in situations like 4 / 0.1
else if (remainderPct < 0.5 || remainderPct > 0.9999){
return (base * round);
}
else {
return (base * round) + round;
}
let rounded = Math.round(val / round) * round;
let precision = (round.toString().split('.')[1] || "").length; // Get decimal places in `round`
return rounded.toFixed(precision); // toFixed handles floating point precision issues
},

editUIButtonCore: function(schemaName, queryName, dataRegionName, paramMap, copyFilters, params){
Expand Down
3 changes: 2 additions & 1 deletion ehr/resources/web/ehr/window/DrugAmountWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,8 @@ Ext4.define('EHR.window.DrugAmountWindow', {
found = true;
editor = {
xtype: 'ldk-numberfield',
fieldName: fieldName
fieldName: fieldName,
decimalPrecision: 6
}
}

Expand Down
11 changes: 9 additions & 2 deletions ehr/src/org/labkey/ehr/EHRController.java
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ public ModelAndView getView(EHRQueryForm form, BindException errors)

ActionURL url = getViewContext().getActionURL().clone();

if (keyField != null)
if (keyField != null && ti.getUpdateService() != null)
{
String detailsStr;
String importStr;
Expand Down Expand Up @@ -1427,7 +1427,14 @@ public Object execute(PopulateLookupsForm form, BindException errors) throws Exc
return null;

List<String> lookups = new ArrayList<>();
lookups.add("All");

// This is too dangerous to leave in production so only include it if a manifest is provided as a URL parameter
// such as in automated testing
if (form.getManifest() != null)
{
lookups.add("All");
}

lookups.add("lookup_sets");

BufferedReader reader = Readers.getReader(_lookupsManifest.getInputStream());
Expand Down
2 changes: 1 addition & 1 deletion ehr/src/org/labkey/ehr/table/DefaultEHRCustomizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -1216,7 +1216,7 @@ private void customizeAnimalTable(AbstractTableInfo ds)
ds.addColumn(col20);

var col8 = getWrappedIdCol(us, ds, "CageClass", "demographicsCageClass");
col8.setLabel("Required Case Size");
col8.setLabel("Required Cage Size");
col8.setDescription("Calculates the cage size necessary for this animal, based on weight using The Guide requirements");
ds.addColumn(col8);

Expand Down
110 changes: 98 additions & 12 deletions snd/test/src/org/labkey/test/tests/snd/SNDTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.labkey.test.tests.snd;

import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
Expand Down Expand Up @@ -48,6 +49,7 @@
import org.labkey.test.components.snd.PackageViewerResult;
import org.labkey.test.components.snd.ProjectViewerResult;
import org.labkey.test.components.snd.SuperPackageRow;
import org.labkey.test.pages.query.SourceQueryPage;
import org.labkey.test.pages.snd.EditCategoriesPage;
import org.labkey.test.pages.snd.EditPackagePage;
import org.labkey.test.pages.snd.EditProjectPage;
Expand All @@ -56,7 +58,10 @@
import org.labkey.test.util.ApiPermissionsHelper;
import org.labkey.test.util.DataRegionTable;
import org.labkey.test.util.Maps;
import org.labkey.test.util.OptionalFeatureHelper;
import org.labkey.test.util.PortalHelper;
import org.labkey.test.util.SqlserverOnlyTest;
import org.labkey.test.util.StudyHelper;
import org.labkey.test.util.core.webdav.WebDavUploadHelper;
import org.openqa.selenium.WebElement;

Expand Down Expand Up @@ -107,6 +112,7 @@ public class SNDTest extends BaseWebDriverTest implements SqlserverOnlyTest
private static final int TEST_CATEGORY_ID2 = 51;
private static final int TEST_CATEGORY_ID3 = 52;
private static final int TEST_CATEGORY_ID4 = 53;
private static final int TEST_CATEGORY_ID5 = 54;
private static final int TEST_SUPER_PKG_START_ID1 = 130;
private static final int TEST_SUPER_PKG_START_ID2 = 140;
private static final int TEST_SUPER_PKG_START_ID3 = 150;
Expand Down Expand Up @@ -141,6 +147,8 @@ public class SNDTest extends BaseWebDriverTest implements SqlserverOnlyTest
private static final String UITEST_PROJECT_SUBPKG2 = "Vet Comment";
private static final String UITEST_PROJECT_SUBPKG3 = "Ketamine Sedation";

private static final String STUDY_NAME = "Query provisioned snapshot test";

private static final String CREATEDOMAINSAPI ="LABKEY.Domain.create({\n" +
" domainGroup: 'test', \n" +
" domainKind: 'SND', \n" +
Expand Down Expand Up @@ -553,7 +561,12 @@ private static String getPackageWithId(String packageId)
" 'Description': 'Weight', \n"+
" 'Active': true, \n"+
" 'Comment': 'This is a weight' \n"+
" },{ \n"+
" },{ \n" +
" 'CategoryId': " + TEST_CATEGORY_ID5 + " ,\n" +
" 'Description': 'Sodium', \n" +
" 'Active': true, \n" +
" 'Comment': 'This is Sodium' \n" +
" },{ \n"+
" 'CategoryId': " + TEST_CATEGORY_ID4 + ",\n"+
" 'Description': 'Vitals', \n"+
" 'Active': true, \n"+
Expand Down Expand Up @@ -870,16 +883,16 @@ public void checkLinks()
@BeforeClass
public static void setupProject()
{
SNDTest init = (SNDTest) getCurrentTest();

SNDTest init = getCurrentTest();
init.doSetup();
}

private void doSetup()
{
_containerHelper.createProject(getProjectName(), "Collaboration");
goToProjectHome();
_containerHelper.enableModules(Arrays.asList("SND"));
_containerHelper.enableModules(Arrays.asList("SND", "Study"));

_containerHelper.createSubfolder(getProjectName(), getProjectName(), TEST1SUBFOLDER, "Collaboration", new String[]{"SND"});
setupTest1Project();

Expand Down Expand Up @@ -2089,8 +2102,7 @@ public void reviseProjectViaUI() throws Exception
assertFalse("Unassigned package found assigned.", viewPage.isAssignedPackagePresent(UITEST_PROJECT_SUBPKG2));
}

@Test
public void verifyTestFrameworkAPITests()
private void runTestsInAPIFrameWork()
{
log("Launching the Testing framework");
goToProjectHome();
Expand All @@ -2101,11 +2113,10 @@ public void verifyTestFrameworkAPITests()
clickButton("Run tests", 0);
waitForText("Total tests:", 1, WAIT_FOR_PAGE);

log("Verifying no test failed");
assertTextPresent("Complete","Failed tests: 0");
}

private String getPerimissionTableValue(int row, int col)
private String getPermissionTableValue(int row, int col)
{
List<WebElement> els = ((Locator.XPathLocator)getSimpleTableCell(Locator.id("category-security"), row, col)).child("div").child("a").child("input").findElements(getDriver());
if (els.size() > 0)
Expand Down Expand Up @@ -2157,7 +2168,7 @@ public void categoryPermissionsUI() throws Exception
{
if (categories.contains(getTableCellText(Locator.id("category-security"), i, 0)))
{
value = getPerimissionTableValue(i, 1);
value = getPermissionTableValue(i, 1);
assertNotNull(value);
assertTrue(value.equals("None"));
categoryRows.add(i);
Expand All @@ -2169,7 +2180,7 @@ public void categoryPermissionsUI() throws Exception

for (Integer r : categoryRows)
{
value = getPerimissionTableValue(r, 1);
value = getPermissionTableValue(r, 1);
assertNotNull(value);
assertTrue(value.equals("SND Reader"));
}
Expand All @@ -2179,7 +2190,7 @@ public void categoryPermissionsUI() throws Exception

for (int k = 0; k < categoryRows.size(); k++)
{
value = getPerimissionTableValue(categoryRows.get(k), 1);
value = getPermissionTableValue(categoryRows.get(k), 1);
assertNotNull(value);
assertTrue(value.equals("None"));
click(getSimpleTableCell(Locator.id("category-security"), categoryRows.get(k), 1));
Expand All @@ -2190,13 +2201,88 @@ public void categoryPermissionsUI() throws Exception

for (int j = 0; j < categoryRows.size(); j++)
{
value = getPerimissionTableValue(categoryRows.get(j), 1);
value = getPermissionTableValue(categoryRows.get(j), 1);
assertNotNull(value);
assertTrue(value.equals(permissions.get(j)));
}

}

@Test
public void testQueryProvisionedSnapshot()
{
String sourceQueryName = "SND: Source query";
String snapshotName = sourceQueryName + " Snapshot";
String sourceQuery = "SELECT\n" +
"lsid AS _key,\n" +
"SubjectId AS participantid,\n" +
"date,\n" +
"SequenceNum,\n" +
"qcstate,\n" +
"lsid,\n" +
"amount,\n" +
"units,\n" +
"kit_type\n" +
"FROM SND.Categories.Sodium\n";

String updatedSourceQuery = sourceQuery.replace(
"amount,",
"'8976' AS amount,");

log("Enable Allow query based dataset snapshots");
OptionalFeatureHelper.enableOptionalFeature(createDefaultConnection(), "queryBasedDatasets");

log("Run the tests from the framework for set up");
runTestsInAPIFrameWork();

log("Enable study module and create continuous study");
goToProjectHome();
goToManageStudy();
_studyHelper.startCreateStudy()
.setTimepointType(StudyHelper.TimepointType.CONTINUOUS)
.createStudy();

log("Adding dataset webpart");
goToProjectHome();
PortalHelper _portalHelper = new PortalHelper(getDriver());
_portalHelper.addBodyWebPart("Datasets");

log("Create source query from study");
goToSchemaBrowser();
SourceQueryPage querySourcePage = createNewQuery("study", null)
.setName(sourceQueryName)
.setBaseTable("DataSets")
.clickCreate();
querySourcePage.setSource(sourceQuery)
.clickSaveAndFinish();

log("Create the snapshot");
DataRegionTable queryTable = new DataRegionTable.DataRegionFinder(getDriver()).withName("query").waitFor();
queryTable.goToReport("Create Query Snapshot");
checkCheckbox(Locator.name("queryDataset"));
clickButton("Create Snapshot");

log("Verify the dataset snapshot");
goToProjectHome();
clickAndWait(Locator.linkWithText(snapshotName));
DataRegionTable dataRegionTable = new DataRegionTable.DataRegionFinder(getDriver()).withName("Dataset").waitFor();
Assert.assertEquals("Incorrect number of rows", 3, dataRegionTable.getDataRowCount());
Assert.assertEquals("Incorrect column titles", Arrays.asList("ParticipantId", "_key", "date", "amount", "units", "kit_type"),
dataRegionTable.getColumnNames());
Assert.assertEquals("Incorrect value in amount column", Arrays.asList("100", "100", " "), dataRegionTable.getColumnDataAsText("amount"));

log("Edit the source query and verify snapshot is updated");
goToSchemaBrowser();
querySourcePage = editQuerySource("study", sourceQueryName);
querySourcePage.setSource(updatedSourceQuery)
.clickSaveAndFinish();

goToProjectHome();
clickAndWait(Locator.linkWithText(snapshotName));
dataRegionTable = new DataRegionTable.DataRegionFinder(getDriver()).withName("Dataset").waitFor();
Assert.assertEquals("Incorrect value in amount column", Arrays.asList("8976", "8976", "8976"), dataRegionTable.getColumnDataAsText("amount"));
}

private void truncateSndPkg() throws Exception
{
//cleanup - truncate snd.pkgs
Expand Down
2 changes: 1 addition & 1 deletion snd/webapp/snd/test/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
active: true,
repeatable: true,
narrative: 'Sodium: {amount} {units} measured using {kit_type}',
categories: [],
categories: [54],
subPackages: [],
attributes: [
{
Expand Down